Jump to content
Sign in to follow this  
jimmer

How do you pause a script?

Recommended Posts

jimmer

1. Can somene simply explain to me, how to pause a script? :idiot:

I would like to make it so, I can pause it by pushing something like "ctrl + p"

2. How do I make a yellow balloon on the bottom right? To keep me updated on the task the autoit has performed? Also, make the yellow balloon stay at the bottom right.

3. How do I make it keep track of how many times the script has looped that certain function? (If possible, allow the balloons to display the number of times the function has been looped)

4. How can I allow the script to performs it's loops 50 times, and then close all apps. and restart the entire script?

Share this post


Link to post
Share on other sites
CyberSlug

See the help file for HotKeySet and TrayTip.

In this example I use Tooltip instead of TrayTip.

Global $COUNT = 0, $PAUSED = 0

HotKeySet("^p", "TogglePause")
HotKeySet("!^t", "Foo")

; Essentially do nothing except wait for hotkeys
While 1
   ToolTip("You have pressed Ctrl+Alt+T " & $count & " times", @DesktopWidth - 200, @DesktopHeight - 50)
   sleep(10)
WEnd

Func Foo()
   $COUNT = $COUNT + 1
   If $COUNT >= 5 Then
      Tooltip('');get rid of tooltip
      MsgBox(4096,"Quitting","You pressed Ctrl+Alt+T five times")
      EXIT
   EndIf
EndFunc

Func TogglePause()
    $PAUSED = NOT $PAUSED
    While $PAUSED
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites
Wolvereness

1. Can somene simply explain to me, how to pause a script? :idiot:

I would like to make it so, I can pause it by pushing something like "ctrl + p"

2. How do I make a yellow balloon on the bottom right? To keep me updated on the task the autoit has performed? Also, make the yellow balloon stay at the bottom right.

3. How do I make it keep track of how many times the script has looped that certain function? (If possible, allow the balloons to display the number of times the function has been looped)

4. How can I allow the script to performs it's loops 50 times, and then close all apps. and restart the entire script?

<{POST_SNAPBACK}>

I was also working on this when cyber posted.

All of these go at the start of the script:

1.

Global $Pause = 0
HotKeySet('^p','Pause')
Func Pause()
   $Pause = 1
   HotKeySet('^p','UnPause')
   Do
      Sleep(10)
   Until $Pause <> 1
   HotKeySet('^p','Pause')
EndFunc
Func UnPause()
   $Pause = 0
EndFunc

2. There are 2 parts to this code:

Global $TrayMsg
AdlibEnable("Tray",10000)
Func Tray()
   $SomethingTemp = StringSplit($TrayMsg, '|')
   If $SomethingTemp[0] = 2 Then TrayTip($SomethingTemp[1], $SomethingTemp[2], 20)
EndFunc
The next part is houw you would set a new traytip:
$TrayMsg = 'Title|Msg'
Tray()
Please note, the msg will not work if you don't have it in format 'Title|Msg' (please note the '|')

3 & 4. I take it you wanted the counting for the entire script?

For $Loops = 1 To 50
;->the script
Next
;->Closing of aps here
Run('"' & @ScriptFullPath & '"')
Exit
And to set the tray:
$TrayMsg = String($Loops) & ' times|Msg'
Tray()
Edited by Wolvereness

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites
jimmer

Thank you, those were very helpful.

Alright, I have one last question =)

1) Lets say B is not able to load with out A

2) A is not allowed to load more then once.

how would I make it so? this is how I currently have it

;A <--

For $Loop = 1 To 150

;B <-- to be looped 150 times

Next

WinClose("app.")

WinWaitClose("app.")

Sleep(3000)

Run("C:\Program Files\app.")

WinWaitActive("app.")

after the 150 loops, I made it basically restart the application.

But how do I apply A into the loop once, with out making A loop?

Edited by jimmer

Share this post


Link to post
Share on other sites
Jos

something like :

;A <--
For $Loop = 1 To 150
   If $loop = 1 then
     ; A
   EndIf 
;B <-- to be looped 150 times
Next

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jimmer

For $Loop = 1 To 150

If $Loop = 1 Then

;A <--

EndIf

;B <-- will be looped 150 times yes?

What I'm trying to accomplish is to use A once, B 150 times, and then repeat the process infiitely, I would think this will stop after 150

Share this post


Link to post
Share on other sites
SlimShady

While 1
  ;A <--
   For $Loop = 1 To 150
      If $Loop = 1 then
       ; A
      EndIf
  ;B <-- to be looped 150 times
   Next
WEnd

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.