DayZ Autorun

Post gaming related scripts
User avatar
jigga
Posts: 93
Joined: 24 Jan 2014, 00:31

DayZ Autorun

25 May 2014, 18:12

Adjustable dynamic hotkeys for autorun in DayZ.

Code: Select all

#SingleInstance Force
#NoEnv
ListLines, Off
SetBatchLines, -1
x := 1
global runKeyArr := Object()
OnExit, onBeforeExit
RegRead, savedRunKey, HKCU, Software\billygrippo\dayzrun, RunKey
if (ErrorLevel)
{
	RegWrite, REG_SZ, HKCU, Software\billygrippo\dayzrun, RunKey, +w
	savedRunKey := +w
}
RegRead, savedTogKey, HKCU, Software\billygrippo\dayzrun, TogKey
if (ErrorLevel)
{
	RegWrite, REG_SZ, HKCU, Software\billygrippo\dayzrun, TogKey, ^1
	savedTogKey := ^1
}
Hotkey, *%savedTogKey%, doRun, On
Menu, Tray, NoStandard
Menu, FileMenu, Add, &Help, Help
Menu, FileMenu, Add, E&xit, Quit
Menu, MyMenu, Add, &File, :FileMenu
Gui, Menu, MyMenu
Gui, Add, Hotkey, x6 y77 w100 h40 vtog, %savedTogKey%
Gui, Add, Hotkey, x6 yp+62 w100 h40 vsprint, %savedRunKey%
Gui, Font, s14
Gui, Font, Bold
Gui, Add, Text, x116 y77 w100 h60 vtogKeyText, Toggle
Gui, Add, Text, x116 yp+62 w100 h60 vsprintKeyText, Sprint
Gui, Font, s10
Gui, Add, Button, x3 yp+55 w110 h30 gsetHotkey vbtn, Set Keys
Gui, Add, Button, xp+115 w110 h30 grefresh, Refresh Keys
Gui, 	Font, s24
Gui, Add, Text, x6 y7 w210 h40 vrunlab, Off
Gui, Show, w230 h230, Run for DayZ
ControlFocus, Set Keys, Run for DayZ
return

refresh:
GuiControl, , tog, %savedTogKey%
GuiControl, , sprint, %savedRunKey%
return

setHotkey:
Gui, Submit, NoHide
if (RegExMatch(tog, "(Escape|Esc)") || tog = "" || RegExMatch(sprint, "(Escape|Esc)") || sprint = "")
{
	MsgBox Hotkey cannot contain Escape or be blank. You = fail.
	return
}
savedRunKey := sprint
Hotkey, *%savedTogKey%, doRun, Off
savedTogKey := tog
Hotkey, *%savedTogKey%, doRun, On
runKeyArr := Object()
makeArr(sprint)
return

*Escape::
SendInput, {Shift Up}{Ctrl Up}{Alt Up}
GuiControl, text, runlab, Off
x := 1
return

Help:
MsgBox, , Run for DayZ `, by billygrippo, Press Escape to release all keys and toggle off autorun.
return

Quit:
ExitApp
return

doRun:
KeyWait, Shift
KeyWait, Ctrl
KeyWait, Alt
l :=
if (x)
{
	GuiControl, text, runlab, Running
	Loop, % runKeyArr.MaxIndex()
	{
		l .= "{" . runKeyArr[A_Index]  . " Down}"
	}
	SendInput, %l%
	x--
}
else
{
	GuiControl, text, runlab, Off
	Loop, % runKeyArr.MaxIndex()
	{
		l .= "{" . runKeyArr[A_Index] . " Up}"
	}
	SendInput, %l%
	x++
}
return

makeArr(key){
	loop, % StrLen(key)
	{
		if (!RegExMatch(SubStr(key, A_Index, 1), "(\+|\^|!)"))
		{
			if(RegExMatch(SubStr(key, A_Index), "(Enter|Space|Tab|Backspace|BS|Delete|Del|Insert|Ins|Up|Down|Left|Right|Home|End|PgUp|PgDown|CapsLock|ScrollLock|NumLock|Numpad.*|Wheel.*|LButton|RButton|MButton|XButton1|XButton2|F[\d+])", match))
			{
				runKeyArr.Insert(match1)
				return
			}
			runKeyArr.Insert(SubStr(key, A_Index, 1))
			return
		}
		e := SubStr(key, A_Index, 1)
		StringReplace, e, e, +, Shift
		StringReplace, e, e, !, Alt
		StringReplace, e, e, ^, Ctrl
		runKeyArr.Insert(e)
	}
}

onBeforeExit:
RegWrite, REG_SZ, HKCU, Software\billygrippo\dayzrun, TogKey, %savedTogKey%
RegWrite, REG_SZ, HKCU, Software\billygrippo\dayzrun, RunKey, %savedRunKey%
ExitApp
return

GuiClose:
ExitApp

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 19 guests