Unbind hotkey on GUI control

Get help with using AutoHotkey and its commands and hotkeys
PumpkinShortie
Posts: 10
Joined: 14 Nov 2015, 13:17

Unbind hotkey on GUI control

29 Dec 2015, 15:25

I am using a Hotkey box in a GUI and I want to use a button or something to unset the hotkey.

This is what I have :

Code: Select all

Gui, Add, Hotkey, x110 y30 w190 h21 vstartTaxiHotkey, Hotkey
Gui, Add, Button, x310 y29 w43 h23 gunsetStartTaxiHotkey, Unset
[...]
    
unsetStartTaxiHotkey:
    vstopTaxiHotkey := None
    Return
But I don't know what to set the value to nor how to make the text in the box update.
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Unbind hotkey on GUI control

29 Dec 2015, 17:40

Code: Select all

unsetStartTaxiHotkey:
    startTaxiHotkey =
	GuiControl,,startTaxiHotkey
Return
PumpkinShortie
Posts: 10
Joined: 14 Nov 2015, 13:17

Re: Unbind hotkey on GUI control

30 Dec 2015, 13:25

Okay this works, but can you enlighten me as to why putting

Code: Select all

startTaxiHotkey = GuiControl,,startTaxiHotkey
on the same line does not work?

Edit : Actually, startTaxiHotkey = is not needed. Thanks!
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Unbind hotkey on GUI control

30 Dec 2015, 17:08

While possibly (depending on the rest of your code) not needed, startTaxiHotkey = on a line by itself is good practice, as that clears the value from the variable. The GuiControl,,startTaxiHotkey line updates the GUI, but does not actually clear the value.
lexikos
Posts: 6589
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Unbind hotkey on GUI control

30 Dec 2015, 23:01

If you have called Gui Submit or GuiControlGet, startTaxiHotkey, the variable will not be empty and GuiControl,,startTaxiHotkey will not clear it.

As for why your one-liner doesn't work, perhaps this will enlighten you:

Code: Select all

startTaxiHotkey = GuiControl,,startTaxiHotkey
MsgBox % startTaxiHotkey

Return to “Ask For Help”

Who is online

Users browsing this forum: elvisautohotkey, takayo97 and 226 guests