GithubHelp home page GithubHelp logo

desktoptips / hotstring Goto Github PK

View Code? Open in Web Editor NEW

This project forked from menixator/hotstring

0.0 2.0 0.0 25 KB

Trigger a Hotstring through dynamic means with Autohotkey

License: Other

AutoHotkey 100.00%

hotstring's Introduction

Hotstring

This is a library that adds a dynamic hotstring feature for Autohotkey.

Arguments:

  • trigger - A string/regex that triggers the hotstrings.

  • label - A string to replace the trigger/label to goto/ name of function to call when the hotstring is triggered. If it's a label, the variable $ will contain either the phrase that triggered the hotstring or a MatchObject (If mode == 3) If it's a function and the function takes atleast 1 parameter, the first parameter will be the trigger string, or the Match Object.

  • mode - A number between 1 & 3. 1 creates a case insenstive hotstring, 2 creates a case sensitive hotstring, 3 creates a regex hotstring. Defaults to 1.

  • clearTrigger - Wheather or not to clear the trigger. Defaults to true.

  • cond - A name of a function that is to be called everytime the hotstring is triggered. If this function returns a false value or if it returns nothing, the hotstring is not triggered.

##Examples:

#Include Hotstring.ahk

Hotstring("btw", "by the way") ; Case insensitive.
; btw -> by the way
; BTW -> by the way
; BtW -> by the way
; bTw -> by the way.
; annd so on.

Hotstring("ahk", "autohotkey", 2) ; Case sensitive. 
; only ahk will trigger it. AHK, aHk, or AhK won't trigger it
#Include Hotstring.ahk

Hotstring("toLabel", "label")
return

label:
; $ == "toLabel"
return
#Include Hotstring.ahk
Hotstring("(\d+)\/(\d+)%", "percent",3)
return

percent:
; now $ is a match object.
sendInput, % Round(($.Value(1)/$.Value(2))*100)
; 2/2% -> 100
; 70/100 -> 70%
return
#Include Hotstring.ahk

Hotstring("i)((d|w)on)(t)", "$1'$3",3) 
;DONT -> DON'T
;dont -> don't
;dOnt -> dOn't
;WONT -> WON'T
;and so on.

Hotstring("i)colou?rs","$0 $0 everywhere!", 3) ; Regex, Case insensitive
; colors -> 'colors colors everywhere!'
; colours -> 'colours colours everywhere!'
#Include Hotstring.ahk

Hotstring("trigger", "replace") ;Case Insensitive
return

replace($){
	; $ == 'trigger'
	Msgbox %$% was entered!
}
#Include Hotstring.ahk

Hotstring("i)regex_(trigger)", "replace",3) ;Regex
return

replace($){
	;$ is a match Object
	Msgbox % $.Value(0) . " was entered."
	Msgbox % $.Value(1) . " == 'trigger'"
}
#Include Hotstring.ahk

Hotstring("trigger", "replace")
Sleep,4000
Hotstring("trigger","") ; Removes the hotstring

hotstring's People

Contributors

menixator avatar

Watchers

Trey Brister avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.