# 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 • ### Recently Browsing 0 members No registered users viewing this page. • ### Similar Content • By Zobu Hey Guys, I want to add a new checkbox with its own variable every time the add button is clicked. The added checkboxes should remain when I close the window or exit the script and when I reopen I should be able to add new checkboxes aswell. here is what I have so far.. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3>$test = GUICreate("adding test", 475, 345, 500, 175) $Check1 = GUICtrlCreateCheckbox("Checkbox 1", 15, 25, 300, 25)$Button = GUICtrlCreateButton("Add", 365, 25, 90, 20) $Check2 = GUICtrlCreateCheckbox("Checkbox 2", 15, 50, 300, 25)$Check3 = GUICtrlCreateCheckbox("Checkbox 3", 15, 75, 300, 25) GUICtrlSetState($Check2,$GUI_HIDE) GUICtrlSetState($Check3,$GUI_HIDE) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Exit Case$Button GUICtrlSetPos($Check2, 15, 50, 300, 25) GUICtrlSetState($Check2, $GUI_SHOW) Case$Button GUICtrlSetPos($Check3, 15, 75, 300, 25) GUICtrlSetState($Check3, $GUI_SHOW) EndSwitch WEnd • Hello Everyone, Hoping someone can help me, I am totally stuck on this problem, I cannot reach the textarea and the button in a maps page that I get by clicking on a button in a previus page, the only way I can interact with this is using tab and mouseclick but this is a danger method as you know. I get the handle by using:$Posizione = _IEAttach("Ricerca Indirizzo su mappa")

then I tried a lot of things but nothing works, can someone give me a hint?
--------------------
WinWait("Ricerca Indirizzo su mappa")
sleep(1000)
$Posizione = _IEAttach("Ricerca Indirizzo su mappa") WinSetState ("Ricerca Indirizzo su mappa", "", @SW_MAXIMIZE ) WinActivate("Ricerca Indirizzo su mappa") sleep(500) ;~$oForm = _IEFormGetObjByName($Posizione, "form1");Punta il Form$oText = _IEFormElementGetObjByName($Posizione,"indirizzo")$oText = _IEFormElementGetObjByName($Posizione,"writeAddress") ;~$LenteTestoMess = _IEFormElementGetValue($oText);Inserisce il PrimoRepertorio nella variabile ;~ _IELinkClickByText($Posizione, $oForm);Clicca su Aggiorna ed invia il form _IEFormElementSetValue ($oText,"via Ravenna 12" );Completamento campo testo
----------------------------------------------------
Mappa.odt Ricerca Indirizzo su mappa.htm

• Good morning,

I am trying to align a two-line text in a button so that it would be centered in the button but can't succeed to do it for the vertical part.
Can someone tell me what I do wrong ?
Here is my code:
$btn3 = GUICtrlCreateButton("Execute " & @LF & " file 1", 100, 65, 60, 50, _ BitOr($BS_CENTER,$BS_BOTTOM,$BS_MULTILINE)) and here is the resulting layout I get in my window.
I tried to follow the help, made a lot of different parameter combinations (here it's $BS_BOTTOM, but I tried $BS_VCENTER and BS_TOP), still get the same result : vertical alignement is a no go for me. Can someone help ? TIA Gilles • 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 LocalsRead = 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?
×

• Wiki

• Back

• #### Beta

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