# Pause or stop the script if the button is cilicked

## Recommended Posts

Okey guys , here's the thing, My script is running fine, but when it's already running i cant   turn it off or pause by clicking the on/off button  unless i manually close it on my taskbar. What i wanted to happen is "if i click the ($switch = turn On and Off Button) to Off the script will STOP Running but not closing the entire GUI because i tried to use Exit and ExitLoop but it closes the entire GUI. and i don't want that to happen. BTW. I'm new in AutoIT and practice scripting hope somebody could help me Godbless. feel free to view my script Practice.au3 #### Share this post ##### Link to post ##### Share on other sites 23 minutes ago, Ian_Mac said: Okey guys , here's the thing, My script is running fine, but when it's already running i cant turn it off or pause by clicking the on/off button unless i manually close it on my taskbar. What i wanted to happen is "if i click the ($switch = turn On and Off Button) to Off the script will STOP Running but not closing the entire GUI because i tried to use Exit and ExitLoop but it closes the entire GUI. and i don't want that to happen.

BTW. I'm new in AutoIT and practice scripting hope somebody could help me  Godbless. feel free to view my script

So I am looking at your "onOff" function.  This line:
If $readInput ==$readInput Then

What is that meant to accomplish?  First, since it is going to be a number (since that is what the control style specified), it would be "If $readinput =$readinput then", but why is this even in the script.  It will always return true.  That being the case, why is it there?  Go into some more detail as to what you want "onoff" to do...

Edited by MattHiggs

##### Share on other sites

15 hours ago, MattHiggs said:

So I am looking at your "onOff" function.  This line:
If $readInput ==$readInput Then

What is that meant to accomplish?  First, since it is going to be a number (since that is what the control style specified), it would be "If $readinput =$readinput then", but why is this even in the script.  It will always return true.  That being the case, why is it there?

i got what u mean i can do it "If $readInput then" isntead of using == but that's not the problem. what i wanted is to stop the while loop if i turn off the button but not closing the entire gui. because exit and exitloop totally close the entire GUI Edited by Ian_Mac #### Share this post ##### Link to post ##### Share on other sites 8 minutes ago, Ian_Mac said: its, take the inputted number or the value from the ($time = the input box ) then after taking  it multiply it to 1000 then it send msgbox of the answer which means if i input 1 it will multiply to 1000 so 1*1000 = msgbox "You Inputed: 1000"  then after that run the while loop. and that's where my problem is i cant stop the loop  by turing off button by clicking the button to off.

The reason that it won't turn back off is because of this code here:

While 1
Send("0")
Sleep($readInput) WEnd While 1 creates an infinate loop, and the contents of the loop are to press the "0" key and then pause the script for the amount of time entered into the input with no way to break out of the loop. You have given me a summary of only the first couple of lines of code. In order for me to help, I need to know what you are trying to accomplish in its entirety, otherwise when I see code like the above, I don't know what you are trying to do #### Share this post ##### Link to post ##### Share on other sites im just practicing the buttons . just trying to stop the while loop. but if u mean asking me what program im gonna do. idont have idea im just trying to learn the autoit for future use. i newbie and trying to learn programming #### Share this post ##### Link to post ##### Share on other sites Ah I see. In that case, that while loop is what is causing the issue. I can appreciate you are trying to learn, so I would recommend, rather than go about it like this, take a look at these resources first. These will help: And to just explore the other resources that the community has created: I would also highly recommend going over the help file in great detail (if you are using SciteforAutoIt then just press F1 when you have clicked inside the text editor window. #### Share this post ##### Link to post ##### Share on other sites i have tried to read , googled watch vids. but i cant find answers. please help me what code to use. just to stop that loop without exiting. #### Share this post ##### Link to post ##### Share on other sites 4 minutes ago, Ian_Mac said: i have tried to read , googled watch vids. but i cant find answers. please help me what code to use. just to stop that loop without exiting. Dude. I can't help you if I don't know what you want to accomplish. If you are simply trying to display a message box with the number entered into the GUI's input box multiplied by 1000, then there is not need for that loop. Like I said, " While 1 creates an infinate loop, and the contents of the loop are to press the "0" key and then pause the script for the amount of time entered into the input with no way to break out of the loop." If you want to break the infinate loop, you need to either a) change the conditions of the While loop or put an "exitloop" statement somewhere in the while loop. But if I don't know what you are trying to accomplish, then I can't help you. I would need to know why you wanted to put the loop there in order to help you fix it. I need to be able to follow your logic, or else, its like trying to catch smoke with my bare hands. #### Share this post ##### Link to post ##### Share on other sites #### Share this post ##### Link to post ##### Share on other sites okey, ahhm, i wanted to auto press that 0 key while my button is on and i already did it using while 1 right?.. and then now i wanted it to stop if i turned it off . maybe your right to change the condition of the while loop. so how to code it or change it i'm stock ? thanks for the reply sir i really appreciated it #### Share this post ##### Link to post ##### Share on other sites ## Create an account or sign in to comment You need to be a member in order to leave a comment ## Create an account Sign up for a new account in our community. It's easy! Register a new account ## Sign in Already have an account? Sign in here. Sign In Now • ### Similar Content • By Pike Hey Everyone, I haven't been here in a while and recently picked up my old project. Still an FNG! To the point: I want to be able to push the button and either play an mp3, open a file, or open an exe program (all with the same button). The problem is that I don't know how to code for that at "case 1" Case 1 Local$sRead = IniRead("config.ini", "Config", "One", "Default")
SoundPlay($sRead, @HotKeyPressed) <------------------------------- Run($sRead, @HotKeyPressed)                                                                                 <------------------------------- This 'Run' doesn't work even by itself!
See code below for layout. If you need more information I will attach more code or answer any questions. Any help is greatly appreciated.

Much Respect,
Pike

Func _HandleButton() $iClickCount += 1$iTimer = TimerInit() AdlibRegister("CheckButtonPress", $CheckTime) EndFunc Func CheckButtonPress() If TimerDiff($iTimer) < $CheckTime Or$iTimer = 0 Then Return Switch $iClickCount Case 1 Local$sRead = IniRead("config.ini", "Config", "One", "Default") SoundPlay($sRead, @HotKeyPressed) Run($sRead, @HotKeyPressed) Case 2 MsgBox(0, "INFORMATION:", "Choose the file you want designated to this button") Local $sFileOpenDialog = FileOpenDialog(0, @ScriptDir & "\", "All (*.*)",$FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") EndIf Local $sFileName = InputBox("INFORMATION:", "Please Name Your File?" & @CRLF _ & @CRLF _ & "6 Characters or Less", "") IniWrite(@ScriptDir & "\config.ini", "Config", "One",$sFileOpenDialog) IniWrite(@ScriptDir & "\config.ini", "Config", "NameOne", $sFileName) EndSwitch$iClickCount = 0 AdlibUnRegister() EndFunc

• By misioooo
Hi!

I am writing some GUI and i need to use images as buttons, but with text on them (text is from INI file).
Part with button looks like this:
$ankieta1 = GUICtrlCreateButton($txtAnk1, 100,350,765,164) GUICtrlSetFont(-1, 22, 800, -1, "Arial") ;GUICtrlSetColor(-1,0xffffff) $hImageBtn_1 = _GUIImageList_Create(765, 164) _GUIImageList_AddBitmap($hImageBtn_1, "c:\path\to\ankieta_clean.bmp") _GUICtrlButton_SetImageList($ankieta1,$hImageBtn_1, 4) GUICtrlSetOnEvent(-1, "On_Ankieta1") The problem - if i uncomment GUICtrlSetColor, color of text changes, but button is just plain gray (no image). How i can change text color not touching image on a button here?
• By XinYoung
Quick question: How can I click this "Select All" button in IE? There's no ID, and the href is "#"
Am I looking at the wrong html code?
Am I looking
• By XinYoung
Hello again
I need to click this Submit button, but it's in a lightbox and has no ID (i think) and I can't figure out a way to target it. _IEFormSubmit doesn't work.

Thank you

• Hello again, I am in phase two of my help bot. I cannot figure out how to properly code Autoit to click on a webpage button using the I.E UDF. I want to click on the button that I have attached as an image. This button does not have a name but it has an ID. Here is the HTML code for this button that I found using chromes developer inspector.
HTML Code:
<img role="button" tabindex="-1" id="toolactions_INSERT-tbb_image" src="nav_icon_insertkey.gif" alt="New Work Order CTRL+ALT+I" draggable="false"> Here is the code that I have so far:
;******************************************************************************* ; Opens IE and fill out a New Workorder ;******************************************************************************* ; Start IE at the ** Tracking Application in ****** $oIE = _IECreate("https:I_am_Bound_by_my_company_to_not_reveal_this_webpage") ; Wait for a browser page load to complete _IELoadWait($oIE) Sleep(6000) ; Store the field names where the important data will be sent Local $nWorkOrderB = _IEGetObjById($oIE, "toolactions_INSERT-tbb_image") _IEAction(\$nWorkOrderB, "click")  I want my program to click on the button that looks like a piece of paper with a blue #
(For those wondering, I am allowed to send images just not the URL.)
As always any help would be appreciated.

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...