AutoRun / AutoWalk

Post gaming related scripts
User avatar
megnatar
Posts: 92
Joined: 27 Oct 2014, 20:49
Location: The Netherlands
Contact:

AutoRun / AutoWalk

21 Jun 2016, 05:17

How to use:
In most games W is used to "move" forward. Thus when calling this function
it will simulate a W key down. You can call this function from any hotkey in you're
script. Press the key once to move forward, press it again to
stop moving. Clicking the left mouse button or pushing W down also
will stop you're character from moving.

Place this file in you're authotkey library folder. Which is here:
%Userprofile%\documents\AutoHotkey\lib\

Give it the following name:
AutoWalk.ahk

Simply call this function from a hotkey in you're script. For example:

Mbutton::
AutoWalk()
Return

Code: Select all

/*
	How to use.
	In most games W is used to "move" forward. Thus when calling this function
	it will simulate a W key down. You can call this function from any hotkey
	in you're script. Press the key once to move forward, press it again to 
	stop moving. Clicking the left mouse button or press/release W also
	will stop you're character from moving.
	
	Place this file in you're Authotkey library folder. Which is here:
	%Userprofile%\documents\AutoHotkey\lib\
	
	Give it the following name:
	AutoWalk.ahk
	
	Simply call this function from some hotkey in you're script. For example:
	
	~w::
	AutoWalk()
	Return
	
*/
#InstallKeybdHook
#InstallMouseHook

global AnyKey			;Declaring variable AnyKey as global variable. Variables in functions are local to that function.

AutoWalk()
{
	AnyKey:=A_ThisHotkey					;Placing last pressed hotkey in variable AnyKey.
	AnyKey:=StrReplace(AnyKey, "~")			;Remove the tilde character from variable Anykey, for none blocked hotkeys.
	If(AnyKey = "w")						;Check to see if the hotkey is also the w key.
	{
		KeyWait, w, T0.5			;Waiting half a second for w to be physically released.
		If(errorlevel = 1)			;When w is still down after 500ms errorlevel is set to 1. You're probably walking manually.
		{
			KeyWait, w			;Waiting for w key to be released.
			exit				;W is physically released, so we can exit here since movement is stopped.
		}
	}	
	keywait, %AnyKey%							;Waiting for the hotkey to be released.
	If not W_VirtState:=GetKeyState("w")		;When the virtual status of the w key is not down, when W_VirtState is 0. Do whatever comes below.
	{
		SendInput, {w down}						;Virtually pressing w down. Virtual (logical state) is whatever your O.S. thinks the key status is in. Physical is the actual state on you're keyboard.
		keywait, %AnyKey%
		Loop
		{	;When you're hotkey, Lbutton or w key is physically pressed down, variable KeyState will be set to 1. The body of the "if" statement will then execute.
			If(KeyState:=GetKeyState(AnyKey, "P") || KeyState:=GetKeyState("Lbutton", "P") || KeyState:=GetKeyState("w", "P"))
			{
				keywait, %AnyKey%			;Waiting for you're hotkey to be released.
				SendInput, {w up}			;Virtually sending w up. Stop moving.
				break						;Breaking free from the loop.
			}
			sleep, 100			;Sleeping 1/10th of a second each time the loop is iterated. Prevents the function from using to much CPU cycles.
		}						;You can increase the sleep period, but the function will be less responsive.
	}
}
Return
Last edited by megnatar on 26 Jul 2016, 13:46, edited 12 times in total.
User avatar
megnatar
Posts: 92
Joined: 27 Oct 2014, 20:49
Location: The Netherlands
Contact:

Re: AutoRun / AutoWalk

02 Jul 2016, 14:36

Update:
The w key now also can be used as key to toggle autowalk on or off.
Snuffy

Re: AutoRun / AutoWalk

09 Oct 2016, 15:53

Thank you for this. I'm attempting to use it but I keep getting the "Error: Call to nonexistent function." I have it in the folder you specified and also a local directory to the script. Any ideas on what could be going on?
razgriz97
Posts: 3
Joined: 09 Aug 2019, 18:11

Re: AutoRun / AutoWalk

09 Aug 2019, 20:05

Congratulations, your script is the best I've found by far until now.

But I'm having a minor issue with it.

I'm using XButton2 instead of Mbutton on this

Code: Select all

Mbutton::
AutoWalk()
Return

if I start to use the script (press once the XButton2) and soon after try to manual walk using W my character stops for about a second and then starts to walk again.

I've tried to mess with the code to see if I could solve this, but haven't achieved any success yet.

The game I've been testing this is on Battlefield 4, IDK if this replicates on other games.

You got any ideia how to fix this?
FlowerBridge
Posts: 14
Joined: 20 Mar 2019, 20:22

Re: AutoRun / AutoWalk

13 Apr 2020, 09:17

Does that work for every game or for specific ones?
User avatar
megnatar
Posts: 92
Joined: 27 Oct 2014, 20:49
Location: The Netherlands
Contact:

Re: AutoRun / AutoWalk

15 Apr 2020, 05:06

vespe1398 wrote:
13 Apr 2020, 09:17
Does that work for every game or for specific ones?
I'm writing A new script atm that does autowalk and is configurable, remebers all games and so on. Although it's already posted in the GameScripts section. Please W8 a bit and it will be finished.

To answer you're question. Yes It should.
User avatar
megnatar
Posts: 92
Joined: 27 Oct 2014, 20:49
Location: The Netherlands
Contact:

Re: AutoRun / AutoWalk

15 Apr 2020, 05:08

razgriz97 wrote:
09 Aug 2019, 20:05
Congratulations, your script is the best I've found by far until now.

But I'm having a minor issue with it.

I'm using XButton2 instead of Mbutton on this

Code: Select all

Mbutton::
AutoWalk()
Return

if I start to use the script (press once the XButton2) and soon after try to manual walk using W my character stops for about a second and then starts to walk again.

I've tried to mess with the code to see if I could solve this, but haven't achieved any success yet.

The game I've been testing this is on Battlefield 4, IDK if this replicates on other games.

You got any ideia how to fix this?
Sorry for the sloooooow replay. I'm not always here. Or always not here is more like it. Read my comment to Vespe1398 .
Nucleorion
Posts: 50
Joined: 11 Dec 2016, 11:33

Re: AutoRun / AutoWalk

23 Apr 2020, 14:14

I have edited the function and duplicated it by calling it AutoRun to be able to choose with different keys if we want to run or walk
He editado la funcion y la he duplicado llamandola AutoRun para poder elegir con diferentes teclas si queremos correr o andar

Code: Select all

/*
	How to use.
	In most games W is used to "move" forward. Thus when calling this function
	it will simulate a W key down. You can call this function from any hotkey
	in you're script. Press the key once to move forward, press it again to 
	stop moving. Clicking the left mouse button or press/release W also
	will stop you're character from moving.
	
	Place this file in you're Authotkey library folder. Which is here:
	%Userprofile%\documents\AutoHotkey\lib\
	
	Give it the following name:
	AutoRun.ahk
	
	Simply call this function from some hotkey in you're script. For example:
	
	~w::
	AutoRun()
	Return
	
*/
#InstallKeybdHook
#InstallMouseHook

global AnyKeyRun			;Declaring variable AnyKeyRun as global variable. Variables in functions are local to that function.

AutoRun()
{
	AnyKeyRun:=A_ThisHotkey					;Placing last pressed hotkey in variable AnyKeyRun.
	AnyKeyRun:=StrReplace(AnyKeyRun, "~")			;Remove the tilde character from variable AnyKeyRun, for none blocked hotkeys.
	If(AnyKeyRun = "w")						;Check to see if the hotkey is also the w key.
	{
		KeyWait, w, T0.5			;Waiting half a second for w to be physically released.
		If(errorlevel = 1)			;When w is still down after 500ms errorlevel is set to 1. You're probably walking manually.
		{
			KeyWait, w			;Waiting for w key to be released.
			exit				;W is physically released, so we can exit here since movement is stopped.
		}
	}	
	keywait, %AnyKeyRun%							;Waiting for the hotkey to be released.
	If not W_VirtState:=GetKeyState("w")		;When the virtual status of the w key is not down, when W_VirtState is 0. Do whatever comes below.
	{
		SendInput, {w down}						;Virtually pressing w down. Virtual (logical state) is whatever your O.S. thinks the key status is in. Physical is the actual state on you're keyboard.
		Sleep, 200
		SendInput, {Shift down}			;Virtually sending Shift up. Stop moving.
		keywait, %AnyKeyRun%
		Loop
		{	;When you're hotkey, Lbutton or w key is physically pressed down, variable KeyState will be set to 1. The body of the "if" statement will then execute.
			If(KeyState:=GetKeyState(AnyKeyRun, "P") || KeyState:=GetKeyState("Lbutton", "P") || KeyState:=GetKeyState("w", "P"))
			{
				keywait, %AnyKeyRun%			;Waiting for you're hotkey to be released.
				SendInput, {w up}			;Virtually sending w up. Stop moving.
				Sleep, 200
				SendInput, {Shift up}			;Virtually sending w up. Stop moving.
				break						;Breaking free from the loop.
			}
			sleep, 100			;Sleeping 1/10th of a second each time the loop is iterated. Prevents the function from using to much CPU cycles.
		}						;You can increase the sleep period, but the function will be less responsive.
	}
}
Return
The use is the same as that of the genil code of razgriz97 Save the code in a file called AutoRun.ahk next to AutoWalk.ahk
El uso es igual que el del genial codigo de razgriz97 Guardar el codgio en un archivo llamado AutoRun.ahk junto al AutoWalk.ahk

Code: Select all

j::
AutoWalk()
Return

h::
AutoRun()
Return
belicn
Posts: 1
Joined: 13 May 2020, 14:52

Re: AutoRun / AutoWalk

13 May 2020, 14:59

can you make this work with roblox please?
go1
Posts: 13
Joined: 17 Sep 2018, 17:14

Re: AutoRun / AutoWalk

09 Jun 2020, 13:31

Regarding AutoWalk only:

In case the author's code does not work,here is simpler version that you can edit yourself if you have enough experience.
This version does not have any gui's so the activation key is the key below right shift and to the left of right control called "AppsKey".

In Detail Explaination Below:

And the only visual indicator that says that script is active is in tooltip in upper left corner,here is small piece of info regarding what is the tooltip in the upper left corner up on activation of the script with AppsKey: 1 = key is pressed P = windows detects the press key.

Code: Select all

#InstallKeyBdHook
#InstallMouseHook
#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Window
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetBatchLines -1
#MaxHotkeysPerInterval 99999
#maxThreadsPerHotkey, 999999
setKeyDelay, 19, 19
setMouseDelay, 19
warp:=0
;--------------------------- above are autoexecutables that somehow make things work
AppsKey:: ;to the left of right control key
	warp:=!warp
	while (warp=1)
	{
Send {w down}
sleep 10
GetKeyState, state, w
tooltip,%warp%<>%state%,100,100,1 ;this script does not use gui so this is only visual indicator that it is online
;0 = key is not pressed U = windows detects key as not pressed (if different state than those are active then it means opposite of what is described)
	}

if(warp = 0){
Send {w up}
}
return

/::ExitApp ;shuts script down
\::Reload ;resets script from zero
mikerudie
Posts: 1
Joined: 10 Jun 2020, 12:44

Re: AutoRun / AutoWalk

10 Jun 2020, 17:34

Fantastic script! Thanks so much.

I was curious though, if there's a way to get this to work with inactive windows??

I've tried to modify the code to work with inactive game windows, but I'm not having any luck whatsoever.

Anyone?
User avatar
owopeachy
Posts: 11
Joined: 28 Jan 2020, 04:04

Re: AutoRun / AutoWalk

04 Sep 2021, 07:04

Nucleorion wrote:
23 Apr 2020, 14:14
I have edited the function and duplicated it by calling it AutoRun to be able to choose with different keys if we want to run or walk
He editado la funcion y la he duplicado llamandola AutoRun para poder elegir con diferentes teclas si queremos correr o andar

Code: Select all

/*
	How to use.
	In most games W is used to "move" forward. Thus when calling this function
	it will simulate a W key down. You can call this function from any hotkey
	in you're script. Press the key once to move forward, press it again to 
	stop moving. Clicking the left mouse button or press/release W also
	will stop you're character from moving.
	
	Place this file in you're Authotkey library folder. Which is here:
	%Userprofile%\documents\AutoHotkey\lib\
	
	Give it the following name:
	AutoRun.ahk
	
	Simply call this function from some hotkey in you're script. For example:
	
	~w::
	AutoRun()
	Return
	
*/
#InstallKeybdHook
#InstallMouseHook

global AnyKeyRun			;Declaring variable AnyKeyRun as global variable. Variables in functions are local to that function.

AutoRun()
{
	AnyKeyRun:=A_ThisHotkey					;Placing last pressed hotkey in variable AnyKeyRun.
	AnyKeyRun:=StrReplace(AnyKeyRun, "~")			;Remove the tilde character from variable AnyKeyRun, for none blocked hotkeys.
	If(AnyKeyRun = "w")						;Check to see if the hotkey is also the w key.
	{
		KeyWait, w, T0.5			;Waiting half a second for w to be physically released.
		If(errorlevel = 1)			;When w is still down after 500ms errorlevel is set to 1. You're probably walking manually.
		{
			KeyWait, w			;Waiting for w key to be released.
			exit				;W is physically released, so we can exit here since movement is stopped.
		}
	}	
	keywait, %AnyKeyRun%							;Waiting for the hotkey to be released.
	If not W_VirtState:=GetKeyState("w")		;When the virtual status of the w key is not down, when W_VirtState is 0. Do whatever comes below.
	{
		SendInput, {w down}						;Virtually pressing w down. Virtual (logical state) is whatever your O.S. thinks the key status is in. Physical is the actual state on you're keyboard.
		Sleep, 200
		SendInput, {Shift down}			;Virtually sending Shift up. Stop moving.
		keywait, %AnyKeyRun%
		Loop
		{	;When you're hotkey, Lbutton or w key is physically pressed down, variable KeyState will be set to 1. The body of the "if" statement will then execute.
			If(KeyState:=GetKeyState(AnyKeyRun, "P") || KeyState:=GetKeyState("Lbutton", "P") || KeyState:=GetKeyState("w", "P"))
			{
				keywait, %AnyKeyRun%			;Waiting for you're hotkey to be released.
				SendInput, {w up}			;Virtually sending w up. Stop moving.
				Sleep, 200
				SendInput, {Shift up}			;Virtually sending w up. Stop moving.
				break						;Breaking free from the loop.
			}
			sleep, 100			;Sleeping 1/10th of a second each time the loop is iterated. Prevents the function from using to much CPU cycles.
		}						;You can increase the sleep period, but the function will be less responsive.
	}
}
Return
The use is the same as that of the genil code of razgriz97 Save the code in a file called AutoRun.ahk next to AutoWalk.ahk
El uso es igual que el del genial codigo de razgriz97 Guardar el codgio en un archivo llamado AutoRun.ahk junto al AutoWalk.ahk

Code: Select all

j::
AutoWalk()
Return

h::
AutoRun()
Return
this is great, i love it, the only thing i still need is for it to still activate when i press the hotkey while already holding w, for e.g to press w, walk manually, then press the hotkey, release w and continue walking automatically, i just have no idea how to put this in the code :'(
Nucleorion
Posts: 50
Joined: 11 Dec 2016, 11:33

Re: AutoRun / AutoWalk

29 Mar 2022, 03:36

Yes, I also have to release w and then hit the assigned key for the autowalk. I don't know how to open that change the code to do that
Nucleorion
Posts: 50
Joined: 11 Dec 2016, 11:33

Re: AutoRun / AutoWalk

29 Mar 2022, 03:39

go1 wrote:
09 Jun 2020, 13:31
Regarding AutoWalk only:

In case the author's code does not work,here is simpler version that you can edit yourself if you have enough experience.
This version does not have any gui's so the activation key is the key below right shift and to the left of right control called "AppsKey".

In Detail Explaination Below:

And the only visual indicator that says that script is active is in tooltip in upper left corner,here is small piece of info regarding what is the tooltip in the upper left corner up on activation of the script with AppsKey: 1 = key is pressed P = windows detects the press key.

Code: Select all

#InstallKeyBdHook
#InstallMouseHook
#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Window
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetBatchLines -1
#MaxHotkeysPerInterval 99999
#maxThreadsPerHotkey, 999999
setKeyDelay, 19, 19
setMouseDelay, 19
warp:=0
;--------------------------- above are autoexecutables that somehow make things work
AppsKey:: ;to the left of right control key
	warp:=!warp
	while (warp=1)
	{
Send {w down}
sleep 10
GetKeyState, state, w
tooltip,%warp%<>%state%,100,100,1 ;this script does not use gui so this is only visual indicator that it is online
;0 = key is not pressed U = windows detects key as not pressed (if different state than those are active then it means opposite of what is described)
	}

if(warp = 0){
Send {w up}
}
return

/::ExitApp ;shuts script down
\::Reload ;resets script from zero
I don't understand with which key the autowalk is activated with that code
go1
Posts: 13
Joined: 17 Sep 2018, 17:14

Re: AutoRun / AutoWalk

06 Dec 2022, 19:23

Near your right control and your right alt on keyboard there should be windows key and apps key.

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 57 guests