run script in the background

Ask gaming related questions (AHK v1.1 and older)
Elze
Posts: 3
Joined: 09 Feb 2020, 08:50

run script in the background

09 Feb 2020, 09:23

Hey,

pretty new to AHK, i made a simple Script to run some Basic Farming Stuff in my Game while AFK!
Now i had the idea to maybe run it in the Background while doing other stuff(browsing, watching videos) or just playing with another Instance of the Game.
You can have multiple Instances of the Game open without any Problem!
i would like to run the following Script in the Background:

Code: Select all

#IFWinActive The Lord of the Rings Online
#MaxThreadsPerHotkey 2

F11::Suspend

LCtrl & F1::

toggle:= !toggle
While(toggle){
send {5}							;Start15
send {DEL}
sleep 500
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
send {backspace}
send {backspace}
send {backspace}
send {DEL}
send {DEL}
send {DEL}
send {5}
sleep 500
mouseclick, left, 673, 534, 1, 0
mouseclick, left, 673, 534, 1, 0
sleep 500
mouseclick, left, 673, 534, 1, 0
mouseclick, left, 673, 534, 1, 0
sleep 18100
send {DEL}	;1
sleep 500
send {u}
sleep 3000
send {DEL}	;2
sleep 500
send {u}
sleep 3000
send {DEL}	;3
sleep 500
send {u}
sleep 3000
send {DEL}	;4
sleep 500
send {u}
sleep 3000
send {DEL}	;5
sleep 500
send {u}
sleep 3000
send {DEL}	;6
sleep 500
send {u}
sleep 3000
sleep 1000
mouseclick, left, 426, 673, 1, 0				;Tooltip Horn
mouseclick, left, 426, 673, 1, 0
mouseclick, left, 426, 673, 1, 0
mouseclick, left, 426, 673, 1, 0
mouseclick, left, 426, 673, 1, 0
mouseclick, left, 426, 673, 1, 0
send {u}							;Laufen Horn + rufen
sleep 8000
send {F10}							;Target NPC
sleep 1000
send {u}
sleep 1000
mouseclick, left, 1328, 185, 1, 0				;Click Repair Tab
mouseclick, left, 1328, 185, 1, 0
mouseclick, left, 1328, 185, 1, 0
mouseclick, left, 1328, 185, 1, 0
sleep 500
mouseclick, left, 1273, 566, 1, 0				;Click Repair 
mouseclick, left, 1273, 566, 1, 0
mouseclick, left, 1273, 566, 1, 0
mouseclick, left, 1273, 566, 1, 0
sleep 500
mouseclick, left, 208, 673, 1, 0				;Tooltip Farmland
mouseclick, left, 208, 673, 1, 0
mouseclick, left, 208, 673, 1, 0
mouseclick, left, 208, 673, 1, 0
sleep 1000
send {u}
sleep 7000
}
return
send {5}							;Start15
send {DEL}
sleep 500
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
mouseclick, left, 615, 535, 1, 0
send {backspace}
send {backspace}
send {backspace}
send {DEL}
send {DEL}
send {DEL}
send {5}
sleep 500
mouseclick, left, 673, 534, 1, 0
mouseclick, left, 673, 534, 1, 0
sleep 500
mouseclick, left, 673, 534, 1, 0
mouseclick, left, 673, 534, 1, 0
sleep 18100
send {DEL}	;1
sleep 500
send {u}
sleep 3000
send {DEL}	;2
sleep 500
send {u}
sleep 3000
send {DEL}	;3
sleep 500
send {u}
sleep 3000
send {DEL}	;4
sleep 500
send {u}
sleep 3000
send {DEL}	;5
sleep 500
send {u}
sleep 3000
send {DEL}	;6
sleep 500
send {u}
sleep 3000
sleep 1000
mouseclick, left, 426, 673, 1, 0				;Tooltip 1
mouseclick, left, 426, 673, 1, 0
mouseclick, left, 426, 673, 1, 0
mouseclick, left, 426, 673, 1, 0
mouseclick, left, 426, 673, 1, 0
mouseclick, left, 426, 673, 1, 0
send {u}							
sleep 8000
send {F10}							;Target NPC
sleep 1000
send {u}
sleep 1000
mouseclick, left, 1328, 185, 1, 0				;Click 1
mouseclick, left, 1328, 185, 1, 0
mouseclick, left, 1328, 185, 1, 0
mouseclick, left, 1328, 185, 1, 0
sleep 500
mouseclick, left, 1273, 566, 1, 0				;Click 2 
mouseclick, left, 1273, 566, 1, 0
mouseclick, left, 1273, 566, 1, 0
mouseclick, left, 1273, 566, 1, 0
sleep 500
mouseclick, left, 208, 673, 1, 0				;Tooltip 2
mouseclick, left, 208, 673, 1, 0
mouseclick, left, 208, 673, 1, 0
mouseclick, left, 208, 673, 1, 0
sleep 1000
send {u}
sleep 7000
}
return
My Questions now are what would be the best method to run it in the Background?
And when i run the Script in the Background, can i also use other Scripts while playing in another active window? or would they collude with each other?
Would my actions with mouse and keyboard collude in some kind of way while running it in the Background?

Also is there a better option to write Scripts then just using the built in Windows Editor? :HeHe:

Greetings and thanks for the help
User avatar
Yakshongas
Posts: 590
Joined: 21 Jan 2020, 08:41

Re: run script in the background

09 Feb 2020, 09:47

I think there is no way to make it run in the background as you say, mainly because the script can't create some sort of "virtual keyboard/mouse" that only outputs a signal to one window.

Also, a better option for a script editor is Notepad++ whit a user-defined language made for AutoHotKey scripting.
https notepad-plus-plus.org /downloads/ Broken Link for safety
and to set up Notepad++ for scripting read this other post.
https://www.autohotkey.com/boards/viewtopic.php?t=50
Please mark your topics as solved if you don't need any further help. ✅

Need a little more help? Discord : Yakshongas#9893 🕹

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 113 guests