Batandball91 Posted August 27, 2009 Share Posted August 27, 2009 Hey. I'm unable to stop a function call upon request. Under the part: Func SkipInstructions() Send("{CTRLDOWN}") Send("a") Send("{DEL}") Send("{CTRLUP}") EndFunc I'd like to have something like: Call("Instructions") = False ;(obviously would be written differently, not sure how) Just under the: Func SkipInstructions() ...bit so that it stops the 'Instructions' function from being sent, and then I'd like it to skip to the bit JUST after where it starts at: ;START----------------------------------------------------------------------------------------------------------------------------- Run("notepad.exe") WinWaitActive("Untitled - Notepad") Call("Instructions") So basically if you run the program and read the instructions, I'd like it so that when you press F2 it stops Func Instructions() from playing and skips to where you are required to enter some text. Here's the code so you can play around with it: expandcollapse popupFunc TimeUp() Send("{CTRLDOWN}") Send("a") Send("c") Send("{CTRLUP}") Send("Now loading Mozilla Firefox...") Sleep(1000) Send("!f") Send("x") WinWaitActive("Notepad") Send("n") EndFunc Func AddWindow() Send("{CTRLDOWN}") Send("t") Send("{CTRLUP}") Send("omegle") Send("{CTRLDOWN}") Send("{ENTER}") Send("{CTRLUP}") WinGetTitle( "Omegle - Mozilla Firefox" ) If WinWaitActive("Omegle - Mozilla Firefox") Then Sleep(500) Else Send("{F5}") EndIf Mouseclick("left",415,375,1,0) WinGetTitle( "___Omegle___ - Mozilla Firefox" ) If WinWaitActive( "___Omegle___ - Mozilla Firefox" ) Then Sleep(100) Else Sleep(500) EndIf Sleep(200) Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Send("{ENTER}") Mouseclick("left",415,375,1,0) Sleep(200) EndFunc Func Pause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('**Script has been paused**',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func Instructions() Send("Script created by Bullseye 27/08/2009 - Just1n91@hotmail.co.uk") Sleep(700) Send("{ENTER}{ENTER}Legend:{ENTER}F2 - Skip instructions{ENTER}ESC key - Terminate script{ENTER}Pause key - Pause script") Sleep(1800) Send("{ENTER}{ENTER}Welcome to Omegle Firefox Script (x6) v1.0{ENTER}Released: 27.08.09") Sleep(1000) Send("{ENTER}{ENTER}Upon deletion of this message, you must type an opening sentence for greeting strangers on Omegle.com") Sleep(2300) Send("{ENTER}{ENTER}Example: 'Hello. I'm Age/Gender/Location. You?'") Sleep(1450) Send("{ENTER}{ENTER}Press ENTER once you have typed your greeting message.") Sleep(1500) Send("{ENTER}{ENTER}Six Omegle windows will be opened by this script. Just wait once you are finished.") Sleep(2000) Send("{ENTER}{ENTER}At times you may need to assist the script once Omegle.com is open by pressing 'Start a chat'.") Sleep(2400) Send("{ENTER}{ENTER}Get ready...") Sleep(800) Send("{CTRLDOWN}") Send("a") Send("{DEL}") Send("{CTRLUP}") EndFunc Func SkipInstructions() Call("Instructions") = False Send("{CTRLDOWN}") Send("a") Send("{DEL}") Send("{CTRLUP}") EndFunc Func Skip() Send("{CTRLDOWN}") Send("a") Send("c") Send("{CTRLUP}") EndFunc ;Defines pause/skip/terminate buttons Global $Paused HotKeySet("{PAUSE}", "Pause") HotKeySet("{F2}", "SkipInstructions") HotKeySet("{ESC}", "Terminate") ;START----------------------------------------------------------------------------------------------------------------------------- Run("notepad.exe") WinWaitActive("Untitled - Notepad") Call("Instructions") #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(100) If _IsPressed("0D", $dll) Then Skip() ExitLoop EndIf WEnd DllClose($dll) Send("{BACKSPACE}") Call("TimeUp") Run("C:\Program Files\Mozilla Firefox\firefox.exe") WinGetTitle( "iGoogle - Mozilla Firefox" ) WinWaitActive("iGoogle - Mozilla Firefox") Send("{ALTDOWN}") Send("d") Send("{ALTUP}") Send("omegle") Send("{CTRLDOWN}") Send("{ENTER}") Send("{CTRLUP}") WinGetTitle( "Omegle - Mozilla Firefox" ) If WinWaitActive("Omegle - Mozilla Firefox") Then Sleep(500) Else Send("{F5}") EndIf Mouseclick("left",415,375,1,0) WinGetTitle( "___Omegle___ - Mozilla Firefox" ) If WinWaitActive( "___Omegle___ - Mozilla Firefox" ) Then Sleep(100) Else Sleep(500) EndIf Sleep(200) Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Send("{ENTER}") Mouseclick("left",415,375,1,0) Sleep(200) Send("{CTRLDOWN}") Send("t") Send("{CTRLUP}") Send("omegle") Send("{CTRLDOWN}") Send("{ENTER}") Send("{CTRLUP}") WinGetTitle( "Omegle - Mozilla Firefox" ) If WinWaitActive("Omegle - Mozilla Firefox") Then Sleep(500) Else Send("{F5}") EndIf Mouseclick("left",415,375,1,0) WinGetTitle( "Omegle - Mozilla Firefox" ) If WinWaitActive( "Omegle - Mozilla Firefox" ) Then Sleep(500) Else Sleep(500) EndIf Sleep(200) Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Send("{ENTER}") Mouseclick("left",415,375,1,0) Sleep(200) Call("AddWindow") Call("AddWindow") Call("AddWindow") Call("AddWindow") Send("{ESC}") Link to comment Share on other sites More sharing options...
qazwsx Posted August 27, 2009 Share Posted August 27, 2009 Encase it in an if statement? Link to comment Share on other sites More sharing options...
Zedna Posted August 27, 2009 Share Posted August 27, 2009 (edited) Use global variable as flag determining state (running/disabled) like in this my old example: expandcollapse popup#include <GUIConstants.au3> GUICreate("Test",220,100) ;, -1,-1, $WS_CAPTION, $WS_EX_TOPMOST) $progressbar = GUICtrlCreateProgress (10,15,200,20,$PBS_SMOOTH) $procent = GUICtrlCreateLabel ('0 %', 10,40,200,20,$SS_CENTER) $start = GUICtrlCreateButton ("Start",35,68,70,22) $stop = GUICtrlCreateButton ("Stop",115,68,70,22) GUICtrlSetState($stop,$GUI_DISABLE) GUISetState() $run = 0 $i = 0 While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $start Then $run = 1 GUICtrlSetState($start,$GUI_DISABLE) GUICtrlSetState($stop,$GUI_ENABLE) EndIf If $msg = $stop Then $run = 0 GUICtrlSetState($start,$GUI_ENABLE) GUICtrlSetState($stop,$GUI_DISABLE) EndIf If $run Then $i = $i + 1 If $i > 100 Then $i = 0 GUICtrlSetData ($progressbar,$i) GUICtrlSetData ($procent,$i & ' %') Sleep(100) EndIf Wend Edited August 27, 2009 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Batandball91 Posted August 27, 2009 Author Share Posted August 27, 2009 Use global variable as flag determining state (running/disabled) like in this my old example: expandcollapse popup#include <GUIConstants.au3> GUICreate("Test",220,100) ;, -1,-1, $WS_CAPTION, $WS_EX_TOPMOST) $progressbar = GUICtrlCreateProgress (10,15,200,20,$PBS_SMOOTH) $procent = GUICtrlCreateLabel ('0 %', 10,40,200,20,$SS_CENTER) $start = GUICtrlCreateButton ("Start",35,68,70,22) $stop = GUICtrlCreateButton ("Stop",115,68,70,22) GUICtrlSetState($stop,$GUI_DISABLE) GUISetState() $run = 0 $i = 0 While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $start Then $run = 1 GUICtrlSetState($start,$GUI_DISABLE) GUICtrlSetState($stop,$GUI_ENABLE) EndIf If $msg = $stop Then $run = 0 GUICtrlSetState($start,$GUI_ENABLE) GUICtrlSetState($stop,$GUI_DISABLE) EndIf If $run Then $i = $i + 1 If $i > 100 Then $i = 0 GUICtrlSetData ($progressbar,$i) GUICtrlSetData ($procent,$i & ' %') Sleep(100) EndIf Wend I have no idea what any of this does, sorry. I want it to be something like this... except the 'False' bit doesn't seem to want to work: Func SkipInstructions() If Call("Instructions") = True Then Call("Instructions") = False Send("{CTRLDOWN}") Send("a") Send("{DEL}") Send("{CTRLUP}") EndIf EndFunc Link to comment Share on other sites More sharing options...
qazwsx Posted August 27, 2009 Share Posted August 27, 2009 (edited) So you want your function to return a value? Edit: or you want to pass an argument to it. I'm still confused. Edited August 27, 2009 by qazwsx Link to comment Share on other sites More sharing options...
Batandball91 Posted August 27, 2009 Author Share Posted August 27, 2009 (edited) So you want your function to return a value? Edit: or you want to pass an argument to it. I'm still confused. Within this script: Func SkipInstructions() Send("{CTRLDOWN}") Send("a") Send("{DEL}") Send("{CTRLUP}") EndIf EndFunc When: Func SkipInstructions() ..is called, I want: Func Instructions() ..to STOP running (make it stop writing out instructions - I want it to SKIP the instructions) and then continue the script JUST after: Call("Instructions") ..is executed, so that it doesn't actually run Func Instructions() again, but the script runs AFTER that execution. Here's the whole thing: expandcollapse popupFunc TimeUp() Send("{CTRLDOWN}") Send("a") Send("c") Send("{CTRLUP}") Send("Now loading Mozilla Firefox...") Sleep(1000) Send("!f") Send("x") WinWaitActive("Notepad") Send("n") EndFunc Func AddWindow() Send("{CTRLDOWN}") Send("t") Send("{CTRLUP}") Send("omegle") Send("{CTRLDOWN}") Send("{ENTER}") Send("{CTRLUP}") WinGetTitle( "Omegle - Mozilla Firefox" ) If WinWaitActive("Omegle - Mozilla Firefox") Then Sleep(500) Else Send("{F5}") EndIf Mouseclick("left",415,375,1,0) WinGetTitle( "___Omegle___ - Mozilla Firefox" ) If WinWaitActive( "___Omegle___ - Mozilla Firefox" ) Then Sleep(100) Else Sleep(500) EndIf Sleep(200) Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Send("{ENTER}") Mouseclick("left",415,375,1,0) Sleep(200) EndFunc Func Pause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('**Script has been paused**',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func Instructions() Send("Script created by Bullseye 27/08/2009 - Just1n91@hotmail.co.uk") Sleep(700) Send("{ENTER}{ENTER}Legend:{ENTER}F2 - Skip instructions{ENTER}ESC key - Terminate script{ENTER}Pause key - Pause script") Sleep(1800) Send("{ENTER}{ENTER}Welcome to Omegle Firefox Script (x6) v1.0{ENTER}Released: 27.08.09") Sleep(1000) Send("{ENTER}{ENTER}Upon deletion of this message, you must type an opening sentence for greeting strangers on Omegle.com") Sleep(2300) Send("{ENTER}{ENTER}Example: 'Hello. I'm Age/Gender/Location. You?'") Sleep(1450) Send("{ENTER}{ENTER}Press ENTER once you have typed your greeting message.") Sleep(1500) Send("{ENTER}{ENTER}Six Omegle windows will be opened by this script. Just wait once you are finished.") Sleep(2000) Send("{ENTER}{ENTER}At times you may need to assist the script once Omegle.com is open by pressing 'Start a chat'.") Sleep(2500) Send("{ENTER}{ENTER}Get ready...") Sleep(800) Send("{CTRLDOWN}") Send("a") Send("{DEL}") Send("{CTRLUP}") EndFunc Func SkipInstructions() If Call("Instructions") = True Then Call("Instructions") = False Send("{CTRLDOWN}") Send("a") Send("{DEL}") Send("{CTRLUP}") EndIf EndFunc Func Skip() Send("{CTRLDOWN}") Send("a") Send("c") Send("{CTRLUP}") EndFunc ;Defines pause/skip/terminate buttons Global $Paused HotKeySet("{PAUSE}", "Pause") HotKeySet("{F2}", "SkipInstructions") HotKeySet("{ESC}", "Terminate") ;START----------------------------------------------------------------------------------------------------------------------------- Run("notepad.exe") WinWaitActive("Untitled - Notepad") Call("Instructions") #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(100) If _IsPressed("0D", $dll) Then Skip() ExitLoop EndIf WEnd DllClose($dll) Send("{BACKSPACE}") Call("TimeUp") Run("C:\Program Files\Mozilla Firefox\firefox.exe") WinGetTitle( "iGoogle - Mozilla Firefox" ) WinWaitActive("iGoogle - Mozilla Firefox") Send("{ALTDOWN}") Send("d") Send("{ALTUP}") Send("omegle") Send("{CTRLDOWN}") Send("{ENTER}") Send("{CTRLUP}") WinGetTitle( "Omegle - Mozilla Firefox" ) If WinWaitActive("Omegle - Mozilla Firefox") Then Sleep(500) Else Send("{F5}") EndIf Mouseclick("left",415,375,1,0) WinGetTitle( "___Omegle___ - Mozilla Firefox" ) If WinWaitActive( "___Omegle___ - Mozilla Firefox" ) Then Sleep(100) Else Sleep(500) EndIf Sleep(200) Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Send("{ENTER}") Mouseclick("left",415,375,1,0) Sleep(200) Send("{CTRLDOWN}") Send("t") Send("{CTRLUP}") Send("omegle") Send("{CTRLDOWN}") Send("{ENTER}") Send("{CTRLUP}") WinGetTitle( "Omegle - Mozilla Firefox" ) If WinWaitActive("Omegle - Mozilla Firefox") Then Sleep(500) Else Send("{F5}") EndIf Mouseclick("left",415,375,1,0) WinGetTitle( "Omegle - Mozilla Firefox" ) If WinWaitActive( "Omegle - Mozilla Firefox" ) Then Sleep(500) Else Sleep(500) EndIf Sleep(200) Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Send("{ENTER}") Mouseclick("left",415,375,1,0) Sleep(200) Call("AddWindow") Call("AddWindow") Call("AddWindow") Call("AddWindow") Send("{ESC}") Edited August 27, 2009 by Batandball91 Link to comment Share on other sites More sharing options...
qazwsx Posted August 28, 2009 Share Posted August 28, 2009 How is skipInstructions called? Usually your functions go at the end of the script. This makes it more readable. And you don't need to write call("funcNAme"); you can just write the name of the function. Link to comment Share on other sites More sharing options...
Batandball91 Posted August 28, 2009 Author Share Posted August 28, 2009 How is skipInstructions called? Usually your functions go at the end of the script. This makes it more readable. And you don't need to write call("funcNAme"); you can just write the name of the function. Func SkipInstructions() is called via the F2 key: HotKeySet("{F2}", "SkipInstructions") Oh I see. My functions are all at the top of the script Link to comment Share on other sites More sharing options...
qazwsx Posted August 28, 2009 Share Posted August 28, 2009 Global skip = false func hotkeyFunc () skip = true endfunc func instructions ;code if skip = true then return ;code if skip = true then return endfunc There is probably a better way, but that should work. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now