Jump to content

A way to start/ stop a script.


Recommended Posts

This is a noob question. I basically have a script that when I turn it on it does what I want it to do. But I always have to close and alt tab out and double click the icon to start it.

Is there some sort of function I can add to it so I can keep the script turned on, then just hit a hotkey to start the script again? Also, is their a way to start the script from the beginning? Since I am still trying to get it to only run once, so for now I just pause it as soon as it's done and then was wondering if their is a way to make a start button that will start from the beginning again instead of where it left off.

Link to comment
Share on other sites

It really depends on the complexity of your script. If it something simple you could just make it all in one code. Somewhat like this:

HotKeySet("^a", "FuncA"); Ctrl + a

While 1
    Sleep(100)
WEnd

Func FuncA()
    Msgbox(0, 'FuncA', 'Put whatever code you want here.')
EndFunc
If it's more complex just use this but replace the Msgbox function with one that runs your script.
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Hey noob99

I'm kind of a noob too, but use AutoIT everyday now. One way I keep a script going or "paused" while a say program runs is to have it check for a process, if it finds the process, sleep for a given amount of time, then check again. Pretty simple, but effective for what I do. Here is the code, maybe it will help. Little twist on achilles script.

$pid = ProcessExists("Process of program");set to process created by installing program
While ProcessExists ($pid) 
    Sleep(5000);While the Installing program process exists script sleeps or waits
    if NOT ProcessExists ($pid) Then 
    ExitLoop;Obvious if process does not exist the program continues
    EndIf
WEnd
Link to comment
Share on other sites

Well all my script does is have like 10-20 clicks in certain x/y positions to do what I want it to do. However, for now I am working on how to make it only do 1 loop and not keep going and going.

But my main thing is whenever I want to run it I have to alt tab and double click the script icon to make it start. I was wondering if after I double click it and have it running. Once it stops I mainly want to make a hotkey so when it stops as soon as I am ready again I can just hit the hot key and it will run the script again.

So basically I want to be able to activate the script from a hotkey inside the script if possible.

Link to comment
Share on other sites

Basically, when I start it it hits a few keys and does mouse clicks for where I want it to. Then all I basically want is a way to start the script again as soon as I hit a hotkey. There is a pause in it, however usually I pause it and it didn't finish all the way so it didn't help any.

HotKeySet("{END}","_exitit")
HotKeySet("{PAUSE}", "_TogglePause")
Global $Paused
Global $mousespeed = 4





Func _exitit()
exit 0
EndFunc

Func _TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("Script is running")
        If Not WinActivate("Guild Wars") Then
            WinActivate("Guild Wars")
        EndIf
        Sleep(2000)
EndFunc



Func _mk()
    
    
    
    Send("{PGUP}")                                      
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(620, 624), Random(224, 226), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    Send("{INSERT}")                                        
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(511, 515), Random(221, 225), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    Send("{HOME}")                                      
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(785, 795), Random(305, 315), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    Send("{PGDN}")                                      
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(741, 743), Random(656, 658), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(984, 1004), Random(746, 767), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(984, 1004), Random(862, 884), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(984, 1004), Random(979, 1000), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    $rndnumber = Random(900, 1100)
    Sleep($rndnumber)
    MouseClick("left", Random(1057, 1080), Random(746, 767), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(1057, 1080), Random(862, 884), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(1057, 1080), Random(979, 1000), 1, $mousespeed)
    $rndnumber = Random(100, 150)
    Sleep($rndnumber)
    MouseClick("left", Random(1238, 1264), Random(982, 1005), 1, $mousespeed)
    $rndnumber = Random(8000, 8100)
    Sleep($rndnumber)
    MouseClick("left", Random(1238, 1264), Random(982, 1005), 1, $mousespeed)
    $rndnumber = Random(8000, 8100)
    Sleep($rndnumber)
    MouseClick("left", Random(1238, 1264), Random(982, 1005), 1, $mousespeed)
    $rndnumber = Random(100, 200)
    Sleep($rndnumber)
    MouseClick("left", Random(1057, 1080), Random(979, 1000), 1, $mousespeed)
    $rndnumber = Random(200, 250)
    Sleep($rndnumber)
    Send("{PGUP}")                                      
    $rndnumber = Random(200, 250)
    Sleep($rndnumber)
    MouseClick("left", Random(678, 679), Random(120, 122), 1, $mousespeed)
    $rndnumber = Random(7000, 7100)
    Sleep($rndnumber)
    MouseClick("left", Random(1238, 1264), Random(982, 1005), 1, $mousespeed)
    $rndnumber = Random(8000, 8100)
    Sleep($rndnumber)
    MouseClick("left", Random(1238, 1264), Random(982, 1005), 1, $mousespeed)
    $rndnumber = Random(8000, 8100)
    Sleep($rndnumber)
    MouseClick("left", Random(1238, 1264), Random(982, 1005), 1, $mousespeed)
    $rndnumber = Random(500, 1000)
    Sleep($rndnumber)
EndFunc

Edited by noob99
Link to comment
Share on other sites

What do you really want? Couldnt understand the last reply:)

In your script you already have that:)

Do a HotKeySet("{Your key here}","_k") and you will have it:)

Hope it helps, Roofel

Never argue with an idiot, he will just bring you down to his own level and beat you with experience! :D

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...