Sign in to follow this  
Followers 0
invis2

4 tiny scripts need combining

12 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome to the forum !

Define a hotkey for launch each script like a function ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Thanks for your help Tvern really appreciated I will try and get back to you thanks again.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Is it too slow for a game ?


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

ok !

try :

HotKeySet("{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.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Glad to help you !


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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