Example in docs not working

Report problems with documented functionality
User avatar
waetherman
Posts: 112
Joined: 05 Feb 2016, 17:00

Example in docs not working

23 Jul 2017, 11:24

https://autohotkey.com/docs/commands/Hotkey.htm#IfWin
The bottom-most example doesn't work for me:

Code: Select all

; This GUI allows you to register primitive three-key combination hotkeys:
Gui Add, Text, xm, Prefix key:
Gui Add, Edit, yp x100 w100 vPrefix, Space
Gui Add, Text, xm, Suffix hotkey:
Gui Add, Edit, yp x100 w100  vSuffix, f & j
Gui Add, Button, Default, Register
Gui Show
return

ButtonRegister() {
    global
    Gui Submit, NoHide
    local fn
    fn := Func("HotkeyShouldFire").Bind(Prefix)
    Hotkey If, % fn
    Hotkey % Suffix, FireHotkey
}

HotkeyShouldFire(prefix, thisHotkey) {
    return GetKeyState(prefix)
}

FireHotkey() {
    MsgBox %A_ThisHotkey%
}

GuiClose:
GuiEscape:
ExitApp
FireHotkey() is called regardless of the HotkeyShouldFire() return value, meaning that only the suffix hotkey field matters in the example. I wasn't able to make the Hotkey If command work together with a function.
Win 10
AHKv1.1.24.05
Image
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Example in docs not working

23 Jul 2017, 12:42

If, % FunctionObject [v1.1.25+]
User avatar
waetherman
Posts: 112
Joined: 05 Feb 2016, 17:00

Re: Example in docs not working

24 Jul 2017, 03:51

Oh, it seems I installed an old version. :D
Image

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 59 guests