I've made a loop (about a year ago) to help me AFK farm in a game, however, I'm currently trying to adapt it to a GUI toggle button instead of a keyboard shortcut. I've figured out how to create a GUI toggle button with certain parameters, but I can't find online how to have an infinite loop where the button is able to be toggled off while the loop is running. The code works as a toggle button exactly how I want it to without the loop, and if I was fine with it simply being on forever, it would also be working perfectly. However, I'd like to be able to toggle the loop off by pressing the same button again while it's running.
Thanks for any help you're able to offer!
Make GUI Toggle Button Function inside loop
Make GUI Toggle Button Function inside loop
- Attachments
-
- BikeFarmBut.ahk
- (755 Bytes) Downloaded 49 times
Re: Make GUI Toggle Button Function inside loop
Hallo,
try:
try:
Code: Select all
#SingleInstance,Force
Button_State:=0
Gui,1:+AlwaysOnTop
Gui,1:Color,Green
Gui,1:Add,Text,x0 y0 w960 h100 gButton_Press
Gui,1:Add,Progress,x0 y0 w960 h100 BackgroundRed cRed vMy_Button,100
Gui,1:Show,w960 h100, T Button
return
GuiClose:
*^ESC::
ExitApp
Button_Press:
if(Button_state=0)
{
GuiControl,+cLime,My_Button
Button_State:=1
SetTimer, Bike_Farm_Start, -1
}
else if(Button_State=1)
{
GuiControl,+cRed,My_Button
Button_State:=0
}
Return
Bike_Farm_Start:
send, {. down}
send, {lshift down}
While Button_State=1
{
GuiControl,Text,x0 y0 w960 h100 gButton_Press
send, {w down}
sleep, 750
send, {w up}
send, {s down}
sleep, 750
send, {s up}
}
send, {. up}
send, { down}
send, { up}
return