Hello,
I'm trying to get a hotkey to Stop/Start my macro. I know I can use Suspend, Toggle and have. I just want my buttons to correspond with what is. Below you can test the code, when the GUI is activated press F1 and it will disable the "Run" button. I want to be able to press F1 again, and Enable the run button but disable the stop button, as a visual indicator of the current toggle state.
Any help is appreciated. Thanks!
---------------------
#SingleInstance, Force
Gui, Add, Button, x5 y10 w60 h30 gRun, Run
Gui, Add, Button, x65 y10 w60 h30 gStop, Stop
Hotkey, F1, RadioSub
Gui, Show, w130 h50, Assistant
return
Run:
Suspend, off
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
return
Stop:
Suspend, on
Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
return
RadioSub:
pawse := 0
If pawse = 0
{
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
}
Else
{ Control, Disable, , Button2, Assistant
Control, Enable, , Button2, Assistant
}
return
GuiClose:
ExitApp
"Radio" Style buttons with a hotkey
Re: "Radio" Style buttons with a hotkey
Code: Select all
#SingleInstance, Force
pawse := false
Gui, Add, Button, x5 y10 w60 h30 gRun, Run
Gui, Add, Button, x65 y10 w60 h30 gStop, Stop
Hotkey, F1, RadioSub
Gui, Show, w130 h50, Assistant
return
Run:
Suspend, off
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
return
Stop:
Suspend, on
Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
return
RadioSub:
If (pawse:=!pawse)
{
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
}
Else
{ Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
}
EDIT:
In you RadioSublabel pawse always resolved to 0 just before enter in the if-statement:
Code: Select all
RadioSub:
pawse := 0
If pawse = 0
{
MsgBox, test
}
Else
{
MsgBox, this msgbox will never be displayed
}
Control, Enable, , Button2, Assistant
Hope this helps you!
Re: "Radio" Style buttons with a hotkey
BEAUTIFUL <3_<3
That sure did. It works!!!
Now, just to understand; I see we put the pawse := false up top and now it works. What i don't understand is, what is pawse? I just got that from somewhere on a forum to beable to do if statement with it. (pawse was my word) I think this is called a function or variable?
Thanks for the assistance, and the typo at the end
Bottoms up!
Edit to post:
So after a little testing, if you manually click "Stop" (Button2) then the F1 won't work. Any ideas?
----------------
-
---------------------------
-
----------------
#NoTrayIcon
#SingleInstance, Force
pawse := false
Gui, Add, Button, x5 y10 w60 h30 gRun, Run
Gui, Add, Button, x65 y10 w60 h30 gStop, Stop
Hotkey, F1, RadioSub
Gui, Show, w130 h50, Assistant
return
Run:
Suspend, off
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
return
Stop:
Suspend, on
Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
return
RadioSub:
If (pawse:=!pawse)
{
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
}
Else
{ Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
}
return
GuiClose:
ExitApp
That sure did. It works!!!
Now, just to understand; I see we put the pawse := false up top and now it works. What i don't understand is, what is pawse? I just got that from somewhere on a forum to beable to do if statement with it. (pawse was my word) I think this is called a function or variable?
Thanks for the assistance, and the typo at the end
Bottoms up!
Edit to post:
So after a little testing, if you manually click "Stop" (Button2) then the F1 won't work. Any ideas?
----------------
-
---------------------------
-
----------------
#NoTrayIcon
#SingleInstance, Force
pawse := false
Gui, Add, Button, x5 y10 w60 h30 gRun, Run
Gui, Add, Button, x65 y10 w60 h30 gStop, Stop
Hotkey, F1, RadioSub
Gui, Show, w130 h50, Assistant
return
Run:
Suspend, off
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
return
Stop:
Suspend, on
Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
return
RadioSub:
If (pawse:=!pawse)
{
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
}
Else
{ Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
}
return
GuiClose:
ExitApp
Re: "Radio" Style buttons with a hotkey
RESOLVED: IRC CHANNEL.
Thanks, sogpotato!
Here is the winning code:
Cheers!
--------------
#SingleInstance, Force
pawse := false
Gui, Add, Button, x5 y10 w60 h30 gRadioSub , Run
Gui, Add, Button, x65 y10 w60 h30 gRadioSub, Stop
Hotkey, F1, RadioSub
Gui, Show, w130 h50, Assistant
return
q::
Msgbox,
return
RadioSub:
pawse := !pawse
Hotkey, q, toggle
If (pawse == false)
{
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
}
Else
{
Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
return
}
return
GuiClose:
ExitApp
Thanks, sogpotato!
Here is the winning code:
Cheers!
--------------
#SingleInstance, Force
pawse := false
Gui, Add, Button, x5 y10 w60 h30 gRadioSub , Run
Gui, Add, Button, x65 y10 w60 h30 gRadioSub, Stop
Hotkey, F1, RadioSub
Gui, Show, w130 h50, Assistant
return
q::
Msgbox,
return
RadioSub:
pawse := !pawse
Hotkey, q, toggle
If (pawse == false)
{
Control, Disable, , Button1, Assistant
Control, Enable, , Button2, Assistant
}
Else
{
Control, Disable, , Button2, Assistant
Control, Enable, , Button1, Assistant
return
}
return
GuiClose:
ExitApp
Who is online
Users browsing this forum: Joey5 and 460 guests