invis2 Posted September 21, 2010 Share Posted September 21, 2010 Hi hope someone can help me please. I have managed to create 4 working scripts (very basic) but they work well. is it possible to amalgamate them into one script, and make provision for a keypress such that by pressing one of 4 preselected keys the script would run in one of the 4 ways that they work now. in other words the scripts would work exactly as they do now but would need a key to be pressed to select the relevant one. The keypress would basically be a mode button making the script behave in 4 different ways. As i say the scripts themselves work flawlessly but I need them making into one script. Any and all help really appreciated as my programming skills are very limited. Regards Invis2 Link to comment Share on other sites More sharing options...
wakillon Posted September 21, 2010 Share Posted September 21, 2010 (edited) Welcome to the forum !Define a hotkey for launch each script like a function ! Edited September 21, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Tvern Posted September 21, 2010 Share Posted September 21, 2010 Without any example code this is the only thing I can come up with: HotKeySet("!1","_Script1") ;Hotkey Alt+1 HotKeySet("!2","_Script2") ;Hotkey Alt+2 HotKeySet("!3","_Script3") ;Hotkey Alt+3 HotKeySet("!4","_Script4") ;Hotkey Alt+4 While True Sleep(100) WEnd Func _Script1() Run(@ScriptDir & "\script1.exe") EndFunc Func _Script2() Run(@ScriptDir & "\script2.exe") EndFunc Func _Script3() Run(@ScriptDir & "\script3.exe") EndFunc Func _Script4() Run(@ScriptDir & "\script4.exe") EndFunc Actually having one script being able to do everything the other four scripts does can be easy, or difficult depending on how well you have organised your functions and variables. A good way to start is by making all four scripts run entirely inside functions with just an initial function call at the start. Then you can look through your variables and make sure you have as few global varaibles as possible in each script. The remaining global variables have to be unique for each script. Use Ctrl+h to rename them if needed. Once you have your scripts running in functions and made sure your global variables are unique you can copy/paste them all into one file and use something like the above example to choose what function to call. IF you follow the above steps and it doesn't work, please post the result. Link to comment Share on other sites More sharing options...
invis2 Posted September 21, 2010 Author Share Posted September 21, 2010 Hi Im sure your right I just wouldnt have a clue how to go about it need a bit more help if you could please. Link to comment Share on other sites More sharing options...
invis2 Posted September 21, 2010 Author Share Posted September 21, 2010 Thanks for your help Tvern really appreciated I will try and get back to you thanks again. Link to comment Share on other sites More sharing options...
invis2 Posted September 21, 2010 Author Share Posted September 21, 2010 Hi Tvern I tried your suggestion but it is to slow for the application the execution time for each exe is quite slow. I guess the scripts need to be joined in someway and operate within one executable. Link to comment Share on other sites More sharing options...
invis2 Posted September 21, 2010 Author Share Posted September 21, 2010 Sorry didnt think to upload scrips here are they are in order. HotKeySet("{delete}", "StartProg") HotKeySet("{ESC}", "EndProg") ; Infinite loop While 1 WEnd Func StartProg() MouseClick ("right") $pos = MouseGetPos() MouseMove($pos[0] + 80, $pos[1] + 55, 5) Sleep (400) MouseMove($pos[0] + 250, $pos[1] + 55, 5) MouseClick ("left") Sleep (400) Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{ENTER}") Send ("{TAB}") Send ("{ENTER}") EndFunc Func EndProg() Exit EndFunc HotKeySet("{delete}", "StartProg") HotKeySet("{ESC}", "EndProg") ; Infinite loop While 1 WEnd Func StartProg() MouseClick ("right") $pos = MouseGetPos() MouseMove($pos[0] + 85, $pos[1] + 85, 5) Sleep (400) MouseMove($pos[0] + 250, $pos[1] + 85, 5) MouseClick ("left") Sleep (400) Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{ENTER}") Send ("{TAB}") Send ("{ENTER}") EndFunc Func EndProg() Exit EndFunc HotKeySet("{delete}", "StartProg") HotKeySet("{ESC}", "EndProg") ; Infinite loop While 1 WEnd Func StartProg() MouseClick ("right") $pos = MouseGetPos() MouseMove($pos[0] + 80, $pos[1] + 80, 5) Sleep (400) MouseMove($pos[0] + 250, $pos[1] + 100, 5) MouseClick ("left") Sleep (400) Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{ENTER}") Send ("{TAB}") Send ("{ENTER}") EndFunc Func EndProg() Exit EndFunc HotKeySet("{delete}", "StartProg") HotKeySet("{ESC}", "EndProg") ; Infinite loop While 1 WEnd Func StartProg() MouseClick ("right") $pos = MouseGetPos() MouseMove($pos[0] + 85, $pos[1] + 85, 5) Sleep (400) MouseMove($pos[0] + 250, $pos[1] + 85, 5) MouseClick ("left") Sleep (400) Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{ENTER}") Send ("{TAB}") Send ("{ENTER}") EndFunc Func EndProg() Exit EndFunc Link to comment Share on other sites More sharing options...
wakillon Posted September 21, 2010 Share Posted September 21, 2010 Is it too slow for a game ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
invis2 Posted September 21, 2010 Author Share Posted September 21, 2010 No its not a game its a stock market program if that helps. The problem is only partially solved with these simple scripts Time and effort is the issue and scripting really helps in this way as im sure you know. these scripts would really help my poor fingers and brain if I could join them together. What made you wonder if it was a game by the way. Regards Link to comment Share on other sites More sharing options...
wakillon Posted September 21, 2010 Share Posted September 21, 2010 ok ! try : expandcollapse popupHotKeySet("{ESC}", "EndProg") HotKeySet("!1","StartProg1") ;Hotkey Alt+1 HotKeySet("!2","StartProg2") ;Hotkey Alt+2 HotKeySet("!3","StartProg3") ;Hotkey Alt+3 HotKeySet("!4","StartProg4") ;Hotkey Alt+4 ; Infinite loop While 1 Sleep ( 20 ) WEnd Func StartProg1() MouseClick ("right") $pos = MouseGetPos() MouseMove($pos[0] + 80, $pos[1] + 55, 5) Sleep (400) MouseMove($pos[0] + 250, $pos[1] + 55, 5) MouseClick ("left") Sleep (400) Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{ENTER}") Send ("{TAB}") Send ("{ENTER}") EndFunc Func StartProg2() MouseClick ("right") $pos = MouseGetPos() MouseMove($pos[0] + 85, $pos[1] + 85, 5) Sleep (400) MouseMove($pos[0] + 250, $pos[1] + 85, 5) MouseClick ("left") Sleep (400) Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{ENTER}") Send ("{TAB}") Send ("{ENTER}") EndFunc Func StartProg3() MouseClick ("right") $pos = MouseGetPos() MouseMove($pos[0] + 80, $pos[1] + 80, 5) Sleep (400) MouseMove($pos[0] + 250, $pos[1] + 100, 5) MouseClick ("left") Sleep (400) Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{ENTER}") Send ("{TAB}") Send ("{ENTER}") EndFunc Func StartProg4() MouseClick ("right") $pos = MouseGetPos() MouseMove($pos[0] + 85, $pos[1] + 85, 5) Sleep (400) MouseMove($pos[0] + 250, $pos[1] + 85, 5) MouseClick ("left") Sleep (400) Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{TAB}") Send ("{ENTER}") Send ("{TAB}") Send ("{ENTER}") EndFunc Func EndProg() Exit EndFunc AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
invis2 Posted September 21, 2010 Author Share Posted September 21, 2010 My dear Wakillon you are a genius that works absolutely perfectly. Thank you so much your a star. By the way Tvern if your reading this your way worked better once i had re-booted my machine but the wakillon way is definitely quicker. In any event thank you both for your time really appreciated. Link to comment Share on other sites More sharing options...
wakillon Posted September 21, 2010 Share Posted September 21, 2010 Glad to help you ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts 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