@boiler
I am sorry, I have copied above code, like this:
Code: Select all
^j::
SoundBeep, (toggle := !toggle) ? 1500 : 1000, 20
SplashTextOn, 300, 100, title, % "Mouse switch " (toggle ? "ON" : "OFF") "!"
SetTimer, SplashOff, -2000
return
LButton::
Send % toggle ? "{RButton down}" : "{LButton down}"
KeyWait, LButton
Send, % toggle ? "{RButton up}" : "{LButton up}"
return
RButton::
Send % toggle ? "{LButton down}" : "{RButton down}"
KeyWait, RButton
Send, % toggle ? "{LButton up}" : "{RButton up}"
return
If I run it, I get an error:
---------------------------
ttz.ahk
---------------------------
Error: Target label does not exist.
Line#
003: SendMode,Input
004: SetWorkingDir,%A_ScriptDir%
011: Return
012: SoundBeep,(toggle := !toggle) ? 1500 : 1000,20
013: SplashTextOn,300,100,title,"Mouse switch " (toggle ? "ON" : "OFF") "!"
---> 014: SetTimer,SplashOff,-2000
015: Return
018: Send,toggle ? "{RButton down}" : "{LButton down}"
019: KeyWait,LButton
020: Send,toggle ? "{RButton up}" : "{LButton up}"
021: Return
024: Send,toggle ? "{LButton down}" : "{RButton down}"
025: KeyWait,RButton
The program will exit.
---------------------------
OK
---------------------------
Also, I have to say (I am sorry to), but above code has a lot of lines I simply don't understand. You see, I am trying to understand the code what it is actually doing. In stead of just copying/pasting it. I try to understand as well. This is no critism to you coding, but I think you're coding has a compact style, and for me my knowledge of Autohotkey commands is too limited to understand your code.
Would be helpfull to me and go through the code lines of above code and explain exactly line by line what it is doing???
For example:
SoundBeep, (toggle := !toggle) ? 1500 : 1000, 20
seems to be combination commanding a soundbeep and also toggling a switch, in one line.
For me, as a beginner in Autohotkey thats hard to learn.
Next question:
why do you use -2000 as a parameter for SetTimer?
according to the syntax this is a priority value but why -2000?
What exactly means the line:
Send,toggle ? "{RButton up}" : "{LButton up}"
this send commando uses to send a keystroke/mousebutton but why use a ? ternary operator in that line?