Ian_Mac

Pause or stop the script if the button is cilicked

10 posts in this topic

#1 ·  Posted

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



#2 ·  Posted (edited)

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

Practice.au3

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 this post


Link to post
Share on other sites

#3 ·  Posted (edited)

 

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

#4 ·  Posted

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

#5 ·  Posted

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

#6 ·  Posted

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:

https://www.autoitscript.com/forum/files/file/351-learn-to-program-using-free-tools-with-autoit/

https://www.autoitscript.com/forum/files/file/100-welcome-to-autoit-1-2-3/

And to just explore the other resources that the community has created:

https://www.autoitscript.com/forum/files/

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

#7 ·  Posted

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

#8 ·  Posted

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 B) 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

#10 ·  Posted

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

    • thoms
      By thoms
      Hello Forum,
      As said in the title, I'm searching a way to disable all tabstops in a GUI. My GUI includes 15 buttons and 3 edit controls.
      My questions:
      - is there a way to disable all tabstops at a time
      - is there a way to list all controls of a GUI and then disable tabstops one by one
      - or should I use the following line after each button creation:
      _WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP))) Thanks in advance for your valuable help!
      Thoms
      Edit: or maybe disable TAB key? I don't remember how to do!
    • AppSoftwareVld
      By AppSoftwareVld
      Hello,
       
      I need this for a project and I don't find a method for the next problem.
      I want when I click a button to create a variable ("$variable1") so if I press one more time to create one more ("$variable2") and create more and more how many times you press the button.
       
      Do you have an idea ? 
      Thank you for your attention !
    • LOWLIFE
      By LOWLIFE
      This is a personal project to log into several facebook accounts and send a message to a specific person on their birthday. I need to stop a script in a few different ways for several different reasons. For example, it might start sending the email to the wrong account, it might do something other than send a message, it might fail to logout of one account, etc. 
      1) Pause the script at it's exact location with a resume feature in case I need to put it on hold while I do another task. 
      2) Pause the script at it's current location with the option to start over or execute another part of the script (example in GUI with multiple buttons). 
      Also, is there a way to interact with menus? If I log into facebook how can I force it to go straight to sending a message to the proper person? I tried automating a mouseclick but the window opens in different places. I also tried searching for specific text and I couldn't get any information from the windows info tool on the facebook page. 
      Also, how do I get my code in here to show like it does in my editor? (scite)
      Thanks for looking at it, and any help/suggestions I sgreatly appreciated!
      <snip>
    • rte7
      By rte7
      Hello. We work with the BMC Remedy site to manage incidents and would like to automate the processes of clicking through this button code:
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a> I use firefox with mozrepl and autoit with include FF.au3
      I need your help
      I read the topic https://www.autoitscript.com/forum/topic/95595-ffau3-v0601b-10/ but I could not run the code from the listed commands
      ...
      It is necessary to press the button and from the list of the menu of cahorsations to select the item = "zone of trust abonent"
      Screen # 1 http://joxi.ru/52aJK7bh4a7ypA or below.
      1) Press button
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a>
      2) After pressing the button, I need to choose in this menu of 4 items to select an item called "zone of trust abonent", Screen # 2 - http://joxi.ru/p27gwQKHo71VQ2
      html code table items
      <table class="MenuTable" cellpadding="0" cellspacing="0" style="width: 179px;"> <tbody class="MenuTableBody"> <tr class="MenuTableRow"> <td class="MenuEntryName" nowrap="">zone of trust abonent</td> <td class="MenuEntryNoSub" arvalue="zone of trust abonent"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust operator"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust third operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust third operator"></td></tr> <tr class="MenuTableRow"><td class="MenuEntryNameHover" nowrap="">No settings</td> <td class="MenuEntryNoSubHover" arvalue="No settings"></td> </tr> </tbody> </table>
       
       
      More in detail, I choose from the menu item "zone of trust abonent" Screen # 3 - http://joxi.ru/GrqVq4ZIQEPW4m

       
      3) The choice is made, Screen # 4 http://joxi.ru/v297w6aC3PovLr
      <textarea class="text sr " wrap="off" id="arid_WIN_0_1000002488" cols="20" maxlen="60" style="top:21; left:0; width:179; height:21;" armenu="CFG:PRC:CategoryHPD-Res-T1-Q" mstyle="2" arautoc="1" arautocmb="1" arautocak="0" arautoctt="400" rows="1"> </textarea>
       
      It's all. I would be very grateful to you =) !!!!!!!!!!
      Here are more detailed codes in the attachment. 
      button1.txt
      menu - table.txt
      all.txt
    • Nareshm
      By Nareshm
      I create message box but i dont know how to add button action when i click it.

      Help for : Add script for Button : Left, Right, Right Finger
      example when i press Left finger button do Case $idNotepad
                      $iPID = WinActivate ( " :PS :: Version - 2.8.0.0  - [eFS Bill]")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:btnReset]", "{esc}")
                              ControlClick ( " :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]")
                              ControlSend(" :DS  - eF:: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "^v")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "{enter}")
      How to add like above ?
                    
                                                                sorry for my bad english