Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Use a variable as a hotkey?



  • Please log in to reply
1 reply to this topic
YesHello
  • Members
  • 1 posts
  • Last active: Dec 12 2015 01:38 AM
  • Joined: 24 Oct 2015

I have a script where I want to change a variable using gui, then use that variable as a hotkey that will run the bottom segment of code. But when I change the variable and press gui submit the hotkey doesn't change.

 

(The variable is Hotkey)

Gui, +resize
Gui, Add, Checkbox, vThrowpot, Throwpot
Gui, add, edit, vPotdelay, Delay (MS)
Gui, Add, Edit, vHotkey, Hotkey
Gui, add, dropdownlist, vSlotone, 1st Hotkey|1|2|3|4|5|6|7|8|9
Gui, add, dropdownlist, vSlottwo, 2nd Hotkey|1|2|3|4|5|6|7|8|9
Gui, add, dropdownlist, vSlotthree, 3rd Hotkey|1|2|3|4|5|6|7|8|9
Gui, add, dropdownlist, vSlotfour, 4th Hotkey|1|2|3|4|5|6|7|8|9
Gui, add, dropdownlist, vSlotfive, 5th Hotkey|1|2|3|4|5|6|7|8|9
Gui, add, dropdownlist, vSlotsix, 6th Hotkey|1|2|3|4|5|6|7|8|9
Gui, add, button, default, submit
Gui, Show
Buttonsubmit:
gui, submit, nohide
GuiClose(GuiHwnd) {
ExitApp
}

*e::
send e
Tc = 6
return

Hotkey,%Hotkey%,Button
Return

Button:

Tc++

If (Tc = 7)

Tc := 1

If (Tc = 1) {

send %Slotone%
sleep %Potdelay%
If (%Throwpot% = yes){
click right
}

} Else If (Tc = 2) {

send %Slottwo%
sleep %Potdelay%
If (%Throwpot% = yes){
click right
}


} Else If (Tc = 3) {

send %Slotthree%
sleep %Potdelay%
If (%Throwpot% = yes){
click right
}

} Else If (Tc = 4) {

send %Slotfour%
sleep %Potdelay%
If (%Throwpot% = yes){
click right
}

} Else If (Tc = 5) {

send %Slotfive%
sleep %Potdelay%
If (%Throwpot% = yes){
click right
}

} Else If (Tc = 6) {

send %Slotsix%
sleep %Potdelay%
If (%Throwpot% = yes){
click right
}

} Return



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012
✓  Best Answer

Hotkey,%Hotkey%,Button

 

This should be underneath the Gui, Submit, NoHide. Your function is in the way, and so an implicit return is being reached.

 

Additionally, you should want a return after the Gui Show so that the auto-execute section does not run the Hotkey, %Hotkey%, Button line with an undefined variable.

 

Finally, there is a Gui control called Hotkey that you may well be interested in. http://ahkscript.org...rols.htm#Hotkey