Please help me fix my simple script.... and a usage question

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

Please help me fix my simple script.... and a usage question

24 Sep 2019, 19:38

Hi this is my current script I have built.. it mostly works but strange thigns happen like when I auto run it also spams e and stuff... maybe you pros could take a look at it and help me fix.

This is what I want the script to do to help me in a game called Satisfactory
  • t == press and hold e
  • g == rapid fire press e
  • b == press and hold Left Mouse Button
  • v == press and hold w, press v or w or s or a or d to stop holding down w
  • F11 == halts any recurring loops, incase you forget what is turned on or get confused. Simply resets everything.
  • p == Pause Script
This is my current script.

Code: Select all

#SingleInstance

/*

NOTES This is what I would like the sctript to do: 

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


*/


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

; -----------------------------------------------------------------------------------------------------------------------------------------------
; Press v to move forward wioth out touching anything, Press w to stop autorunning.
; -----------------------------------------------------------------------------------------------------------------------------------------------

v::
	If GetKeyState("w")
	Send {w Up}
	Else
	Send {w Down}
Return

; -------------------------------------------------------------------------------------------------------------
; press g to repeatadly press e, press g 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


; -------------------------------------------------------------------------------------------------------------
; press t to hold down e
; -------------------------------------------------------------------------------------------------------------

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

; -------------------------------------------------------------------------------------------------------------
; Press b to hold down left mouse click
; -------------------------------------------------------------------------------------------------------------

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


; -------------------------------------------------------------------------------------------------------------
; press p to pause all scripts.
; -------------------------------------------------------------------------------------------------------------

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 -----------------------------------------
; -------------------------------------------------------------------------------------------------------------
; Remape a mouse button
; -------------------------------------------------------------------------------------------------------------

;XButton1::ESC	
Also, how can I automatically load AHK and the game I want to use it on... and then quit the script when I exit the game. At the moment I made a batch file to load the game and then AHK, I had to do it this way as if I put AHK first the dos window would just sit there and not load the game.

Code: Select all

@echo off
"D:\Applications\Games\Epic\SatisfactoryEarlyAccess\FactoryGame.exe"
"C:\Program Files\AutoHotkey\autohotkey.exe" "E:\Archive\_Cloud\Dropbox\Apps\Satisfactory AutoHotKey.ahk"
Is there a better way to do this? And is there a way to have AHK close when I exit the game. Thanks!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Marco Gatti, WarlordAkamu67 and 126 guests