Sign in to follow this  
Followers 0
Blasphemy

Starting script paused?

8 posts in this topic

How would I start the script paused?

So i open it, I can do other things for a while. Hit a certain key, The script unpauses and at the end returns to start (Paused)

If you understand me, Cheers.

Share this post


Link to post
Share on other sites



How would I start the script paused?

So i open it, I can do other things for a while. Hit a certain key, The script unpauses and at the end returns to start (Paused)

If you understand me, Cheers.

Maybe use HotKeyset?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

HotKeySet("{PAUSE}", "TogglePause"); This goes at the beginning of the code
;===> Everything before while 1 here. 
TogglePause()

While 1
[...]
Wend

Func TogglePause()
    Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
    WEnd
EndFunc;Goes at the end

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Cheers, I'll search for that and probably post again If i can't figure out :)

Edit: Thanks delta I'll try that.

Edited by Blasphemy

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Np

Edited by Delta01

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Edit: I got it working..

Now I have it so it can come up with a message when i hit pause. But not move mouse/Keyboard key.

Code is:

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
 
While 1



Wend



    Func TogglePause()
    $Paused =  $Paused
    While $Paused
        sleep(100)
    WEnd
    
    MsgBox(0, "Hai", "Hai")
EndFunc
Edited by Blasphemy

Share this post


Link to post
Share on other sites

I've tried that script. It doesn't pause the script imediately when started, a user has to intervene by pressing the keboard's 'Pause' button.

is there any way to pause the script automatically on its own when it starts but also allows other functions to run, like 'start' and 'exit'(assuming I made those in tray icon menu using TrayCreateItem())

You can try this:

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")

; this pauses your script
Send("{PAUSE}")


; insert your code after the above line



; modified pause function to allow reading tray messages
Func TogglePause()
    $Paused =  $Paused
    While $Paused
        sleep(10)
        $msg = TrayGetMsg()
        Select
            Case $msg = $exit
                Exit
            Case $msg = $start
                ;; place whatever here
        EndSelect
    WEnd
EndFunc

I use a modified pause function frequently for some of the scripts I build. Lemme know if this helps.

Share this post


Link to post
Share on other sites

what about allowing other functions to work while the script is paused? Is that possible?

as in???

you can add functions before or after the select/endselect or you can use an Adlib command. depends on the desired effect. all the pause script is is just a loop that normally does nothing so your script does nothing but loop. It isnt any different than any while/wend script.

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  
Followers 0