Hi I am not really understanding scripting.. is this possible..

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
itisme
Posts: 8
Joined: 21 Sep 2019, 08:44

Hi I am not really understanding scripting.. is this possible..

21 Sep 2019, 11:14

Hi I am not really understanding scripting.. is this possible..

: What I would like to do :
  • I have a first person game that has a ton of running from point to point but no autorun key.
  • I would like to use autohotkey to set "w" to always be down so I can activate the script and automatically run forward without touching the keyboard or mouse.
  • If possible I would love to be able to turn ON and OFF auto run by just double tapping "w"
  • Otherwise I'd be happy to get set a ket (say v) to toggle autorun off and on
Is this possible, and if so, would anyone be able to help me with the scripting?

Thanks!
ilhom
Posts: 52
Joined: 19 Aug 2019, 17:58

Re: Hi I am not really understanding scripting.. is this possible..

21 Sep 2019, 12:28

Try this. The 200 is the amount of milliseconds to detect if it's been double tapped or not. You can adjust this if you want.
To cancel the auto run, just tap w again.

Code: Select all

$w::
if (A_TimeSincePriorHotkey < 200)
	SendInput {w down}
else
	SendInput w
itisme
Posts: 8
Joined: 21 Sep 2019, 08:44

Re: Hi I am not really understanding scripting.. is this possible..

22 Sep 2019, 05:26

Hey thanks a lot... the problem with this is that it stops you normally using w.... or so it seemed.. I tried editing it to have it switch on and off with either a key or a middle mouse button.. but I couldn't get it to do anything...

TL;DR - How would I modify the code above to remove the double tap stuff, and simple if I press say "h" it will hold down "w" and in game I walk forward? Then press "h" again to stop... or better even better, make it MButton instead of "w"?
ilhom
Posts: 52
Joined: 19 Aug 2019, 17:58

Re: Hi I am not really understanding scripting.. is this possible..

22 Sep 2019, 13:48

itisme wrote:
22 Sep 2019, 05:26
Hey thanks a lot... the problem with this is that it stops you normally using w.... or so it seemed.. I tried editing it to have it switch on and off with either a key or a middle mouse button.. but I couldn't get it to do anything...

TL;DR - How would I modify the code above to remove the double tap stuff, and simple if I press say "h" it will hold down "w" and in game I walk forward? Then press "h" again to stop... or better even better, make it MButton instead of "w"?
It worked normal for me if I just tapped w again. Anyway, here is the other script. You can test in notepad, but you will want to change the Untitled - Notepad to the window title of your game. This will let your h key function normally outside of the game so you don't need to kill/start the script whenever you close/open the game.

If you want to use middle mouse button instead, replace both instances of h with MButton

Code: Select all

$h::
IfWinActive, Untitled - Notepad
{
	if GetKeyState("w")
		SendInput {w up}
	else
		SendInput {w down}
	return
}
else
	SendInput h
itisme
Posts: 8
Joined: 21 Sep 2019, 08:44

Re: Hi I am not really understanding scripting.. is this possible..

24 Sep 2019, 00:42

Thanks so much for eveything.. would you please look at my script for me...

At the top I have listed what I want it to do... but only some of it is working. Maybe you could see what I have done wrong?

Thanks

Code: Select all

#SingleInstance

/*

NOTES: 

t == press and hold e
g == rapid fire press e
b == press and hold Left Mouse Button
Middel Mouse Button == press and hold w, press Middle Mouse Button or w or s or a or d to stop holding down w
F11 == halts any recuring loops, incase you forget what is turned on or get confused. Simply resets eveything.
p == Pause Scrtip


*/


paused := false


; -------------------------------------------------------------------------------------------------------------
; F11 halts any latent executions, in case you forget the state of your toggles!
; plays a little beep sound 
; -------------------------------------------------------------------------------------------------------------

F11::
	settimer, dogather, off
	Click, up, X2
	Click, up
	SoundBeep, 300, 100
	return

; -----------------------------------------------------------------------------------------------------------------------------------------------
; Double press Middel Mouse Button move forward wioth out touching anything, Press again to stop. The number if how fast you need to double click
; -----------------------------------------------------------------------------------------------------------------------------------------------

MButton::
	if (A_TimeSincePriorHotkey < 400)
	SendInput {w down}
else
	SendInput w

; -------------------------------------------------------------------------------------------------------------
; makes the g key toggle a loop which calls the dogather function (below)
; this is useful for gathering leaves. Just press the key once and run around to rapidly autogather. 
; Press again to stop.
; -------------------------------------------------------------------------------------------------------------

$g::
	gather := not gather
	if gather
	{
		settimer, dogather, 40
	}
	else
	{
		settimer, dogather, off
	}
return


; -------------------------------------------------------------------------------------------------------------
; the dogather function simply clicks mouse button 2 a single time, which is my interact key.
; the timer defined above is therefore basically executing rapidfire left clicks (40 milliseconds apart)
; -------------------------------------------------------------------------------------------------------------

dogather:
	Send, e
	return


; -------------------------------------------------------------------------------------------------------------
; This bind causes the t key to toggle holding down the interact key, which again for me is mouse thumb button 2 (X2)
; This means you don't have to hold down your interact button to manually mine from deposits or to mine away rocks
; -------------------------------------------------------------------------------------------------------------

t::
	if (A_TimeSincePriorHotkey < 400)
	SendInput {e down}
else
	SendInput e

; -------------------------------------------------------------------------------------------------------------
; this bind causes the b to to toggle holding down the left mouse button. Useful for manual crafting.
; -------------------------------------------------------------------------------------------------------------

b::
	holdbutton1 := not holdbutton1
	if holdbutton1
	{
        	Click, down
	}
	else
	{
		Click, up
	}
	Return


; -------------------------------------------------------------------------------------------------------------
; this bind toggles suspension of all of the scripts.
; when pressed, if suspending you will hear a high pitch/low pitch "turning off" sound
; press again to resume, reloading the script and playing a reverse sound
; this is useful if you want to alt-tab out and type something without accidentally causing your mouse to do weird stuff!
; -------------------------------------------------------------------------------------------------------------

p::
	Suspend
	Pause, , 1	
	paused := not paused
	if not paused 
	{
		SoundBeep, 600, 100
		SoundBeep, 700, 100
		Reload
	}
	else
	{
		SoundBeep, 700, 100
		SoundBeep, 600, 100
	}

	Return
	
;--------------------------- Unused -----------------------------------------
; -------------------------------------------------------------------------------------------------------------
; XButton1 is mouse thumb button 1. Binding this to escape makes it way way easier to exit dialogs, build mode, etc
; -------------------------------------------------------------------------------------------------------------

;XButton1::ESC	

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Mannaia666, wpulford and 414 guests