Log in

View Full Version : [HotKeyNet] Trouble with If Blocks



Ghallo
12-11-2010, 06:24 PM
So I wrote some code to try a toggle:


<Hotkey LWin>
<If KeyToggleVar Is 1>
<TargetButton ToggleKeysBtn>
<SetButtonText ToggleKeysBtn "Broadcast: Default">
<ShowWin>
<Override Hotkey All; Shift All; Alt All; Ctrl All>
<Hotkey DefaultList; Shift All; Alt All; Ctrl All>
<SendLabel w1, w2, w3, w4, w5>
<Key %Trigger%>
<SetVar KeyToggleVar 2>
<wait 400>
<HideWin>
<Else If KeyToggleVar Is 2>
<TargetButton ToggleKeysBtn>
<SetButtonText ToggleKeysBtn "Broadcast: All">
<ShowWin>
<Override Hotkey DefaultList; Shift All; Alt All; Ctrl All>
<Hotkey All; Shift All; Alt All; Ctrl All>
<SendLabel w1, w2, w3, w4, w5>
<Key %Trigger%>
<SetVar KeyToggleVar 3>
<wait 400>
<HideWin>
<Else>
<TargetButton ToggleKeysBtn>
<SetButtonText ToggleKeysBtn "Broadcast: Off">
<ShowWin>
<Override Hotkey All; Shift All; Alt All; Ctrl All>
<SetVar KeyToggleVar 1>
<wait 400>
<HideWin>


But when I load this script I get an error
"Else If" can only follow "If".
Not sure why I am getting this error - since it IS following the If...

Any thoughts?

Freddie
12-11-2010, 07:22 PM
Not sure why I am getting this error - since it IS following the If...
It has to follow inside the same hotkey definition.

Each time the keyword <Hotkey...> appears in your script, you are terminating the previous hotkey definition and starting a new definition from scratch.

<Override ...> and <Hotkey ...> always happen at load time. The program interprets these keywords when it loads the script, not when you press a hotkey.

Some keywords, since they always happen at load time, are intended to be used outside of hotkey definitions. Examples of such keywords are <Hotkey ...>, <Override ...>, <Template>, <UseKeyAsModifier>, etc.

If you want to redefine hotkeys when you press a hotkey, the pressed hotkey must reload an entire script.