Jump to content

Starting script paused?


Recommended Posts

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.
Link to comment
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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...