Reputation: 1185
I don't understand why the script in my example doesn't work as expected.
Open any text editor, select some text, press Ctrl-C to copy it in clipboard. Then, launch the script.
Expected behaviour: If I press Ctrl-V, it should be shown message box ok
. If I press Ctrl-Shift-V, it should be shown the same message box. (There should be no difference).
Actual behaviour: If I press Ctrl-Shift-V, there shown error
message box. Why?
^v::MsgBox, ok
return
^+v::MsgBox, error
return
^+v::^v
return
Upvotes: 1
Views: 89
Reputation: 3366
You cannot redefine hotkeys; you cannot define them more than once. When it comes to defining HotKeys and HotStrings, autohotkey is more a declarative language than a procedural one.
If you want to change the behavior of a key combination, put logic in the script. For example:
; Press F2 to change the behavior of ^+v
f2::
condition := !condition
return
^+v::
if (condition)
MsgBox, ok
else
MsgBox, error
return
Upvotes: 1