One-Line Operators in AutoHotkey are a great way

One-Line Operators in AutoHotkey

One-Line Operators in AutoHotkey are a great way to streamline / condense your code!  In the below video I walks through how to use them.  While I use them in a loop, this was merely an easy way to demonstrate them.

One-Line Operators in AutoHotkey Video Tutorial

Example AutoHotkey code of One-Line Operators in AutoHotkey

 
A_enter:="`r`n"
Browser_Back::
my:="hello"
var=
(
one
two
three

five
six
seven
)

Loop, parse, Var, `n, `r ;loop over Var line by line
{
    myVar:=A_Index ;increment myVar

IfEqual, A_Index,1,continue ;skip processing header/1st row
IfEqual, A_LoopField,,continue ;Skip loop if A_Loopfiled is blank
IfEqual, A_Index,3,SetEnv,Data,New Value ;If A_Index is 3 set data:="New Value"
IfEqual, A_Index,5, Sleep, 2000 ;Sleep for 2 seconds on 3 
IfEqual, myVar,6,EnvAdd,myVar, 2 ;If myVar=6 add 2 to myVar
IfEqual, A_LoopField,three,break ;Note- need to use percents if variable    
IfEqual, A_index, 4, ExitApp ;Exit app if get to 10
IfLess, A_Index,6,FileAppend,%A_Loopfield%`r`n,test.txt,utf-8  ;If A_Index <6, write A_loopfield to test.txt
IfEqual, A_Index,4,ListVars
    
MsgBox % "index: " A_Index A_Enter "LoopField: " A_LoopField A_Enter "Data: " Data A_Enter "myVar: " myVar
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.