; <COMPILER: v1.1.37.01>
#NoEnv
#Persistent
#SingleInstance Force
version = 3.5.6
IniRead, ERABversion, ERAB.ini, config, Version
IniWrite, %version%, ERAB.ini, config, Updater
FileRead, Update, UPDATER
name := Dec("RVJBQi5leGU=")
if (Update = "RESTART") {
Run, %name%
}
else if (Update = "BETA") {
if WinExist("ahk_class AutoHotkeyGUI") {
WinClose
}
Sleep, 1000
if (FileExist("ERAB_BETA.zip")) {
FileMove, %name%, ERAB.old, 1
FileMove, ERAB_BETA.zip, %name%, 1
}
Sleep, 200
Run, %name%
}
else if (Update = "UPDATER") {
FileDelete, UPDATER
}
else if (Update = "RESTORE") {
if WinExist("ahk_class AutoHotkeyGUI") {
WinClose
}
Sleep, 1000
FileMove, ERAB.old, %name%, 1
Sleep, 200
Run, %name%
}
else if (Update = "Update.ERAB") {
FileMove, %name%, ERAB.old, 1
FileDelete, README.txt
url := Dec("aHR0cDovL2FzdXJhc3RyaWtlLmRlL0VSQUIvUkVBRE1FLnR4dA==")
version_url := (url)
URLDownloadToFile, %version_url%, README.txt
Sleep, 1000
url := Dec("aHR0cDovL2FzdXJhc3RyaWtlLmRlL0VSQUIvRVJBQi56aXA=")
version_url := (url)
URLDownloadToFile, %version_url%, %name%
Sleep, 1000
FileGetSize, check, %name%, k
while (check < 1000) {
if (timeout > 10) {
MsgBox 0x40040, EZAB Info, Download timed out!`nPlease check your firewall settings and allow www.asurastrike.de.
FileDelete, UPDATER
ExitApp
}
Sleep, 500
timeout += 1
}
FileDelete, UPDATER
Sleep, 500
Run, %name%
}
else if FileExist("MACRO") {
SetTimer, CheckXInput, 100
XInput_Init()
Loop
{
Loop, 4
{
State := XInput_GetState(A_Index-1)
if State
{
BT := State.wButtons
BLT := State.bLeftTrigger
BRT := State.bRightTrigger
StickLX := State.sThumbLX
StickLY := State.sThumbLY
StickRX := State.sThumbRX
StickRY := State.sThumbRY
}
if (BLT > 1) || (BRT > 1) || (BT > 1) || (StickLY > 5000) || (StickLY < -5000) || (StickLX > 5000) || (StickLX < -5000) {
if (FileExist("MACRO")) {
IniWrite, 1, MACRO, status, macro
}
else {
ExitApp
}
}
}
Sleep, 100
}
}
else {
if (FileExist("UPDATER")) {
FileDelete, UPDATER
}
if (ERABversion != "ERROR") {
MsgBox 0x40040, EZAB Info, Updater version:`t%Version%`nEZAB version:`t%ERABversion%
}
else {
MsgBox 0x40040, EZAB Info, Updater version: %Version%
}
}
ExitApp
CheckXInput() {
if !(FileExist("MACRO")) {
SetTimer, CheckXInput, Off
}
return
}
XInput_Init(dll:="")
{
global
if _XInput_hm
return
XINPUT_DEVTYPE_GAMEPAD := 0x01
XINPUT_DEVSUBTYPE_GAMEPAD := 0x01
XINPUT_CAPS_VOICE_SUPPORTED := 0x0004
XINPUT_GAMEPAD_DPAD_UP := 0x1
XINPUT_GAMEPAD_DPAD_DOWN := 0x2
XINPUT_GAMEPAD_DPAD_LEFT := 0x4
XINPUT_GAMEPAD_DPAD_RIGHT := 0x8
XINPUT_GAMEPAD_MENU := 0x10
XINPUT_GAMEPAD_VIEW := 0x20
XINPUT_GAMEPAD_LEFT_STICK := 0x40
XINPUT_GAMEPAD_RIGHT_STICK := 0x80
XINPUT_GAMEPAD_LEFT_BUMPER := 0x100
XINPUT_GAMEPAD_RIGHT_BUMPER := 0x200
XINPUT_GAMEPAD_XBOX := 0x400
XINPUT_GAMEPAD_A := 0x1000
XINPUT_GAMEPAD_B := 0x2000
XINPUT_GAMEPAD_X := 0x4000
XINPUT_GAMEPAD_Y := 0x8000
XINPUT_GAMEPAD_LEFT_STICK_DEADZONE := 7849
XINPUT_GAMEPAD_RIGHT_STICK_DEADZONE := 8689
XINPUT_GAMEPAD_TRIGGER_THRESHOLD := 30
XINPUT_FLAG_GAMEPAD := 0x00000001
if (dll = "")
Loop %A_WinDir%\System32\XInput1_*.dll
dll := A_LoopFileName
if (dll = "")
dll := "XInput1_3.dll"
_XInput_hm := DllCall("LoadLibrary" ,"str",dll ,"ptr")
if !_XInput_hm
throw Exception("Failed to initialize XInput: " dll " not found.")
(_XInput_GetState := DllCall("GetProcAddress" ,"ptr",_XInput_hm ,"ptr",100 ,"ptr"))
|| (_XInput_GetState := DllCall("GetProcAddress" ,"ptr",_XInput_hm ,"astr","XInputGetState" ,"ptr"))
_XInput_SetState := DllCall("GetProcAddress" ,"ptr",_XInput_hm ,"astr","XInputSetState" ,"ptr")
_XInput_GetCapabilities := DllCall("GetProcAddress" ,"ptr",_XInput_hm ,"astr","XInputGetCapabilities" ,"ptr")
if !(_XInput_GetState && _XInput_SetState && _XInput_GetCapabilities)
{
XInput_Term()
throw Exception("Failed to initialize XInput: function not found.")
}
}
XInput_GetState(UserIndex)
{
global _XInput_GetState
VarSetCapacity(xiState,16)
if ErrorLevel := DllCall(_XInput_GetState ,"uint",UserIndex ,"uint",&xiState)
return 0
return {
(Join,
dwPacketNumber: NumGet(xiState, 0, "UInt")
wButtons: NumGet(xiState, 4, "UShort")
bLeftTrigger: NumGet(xiState, 6, "UChar")
bRightTrigger: NumGet(xiState, 7, "UChar")
sThumbLX: NumGet(xiState, 8, "Short")
sThumbLY: NumGet(xiState, 10, "Short")
sThumbRX: NumGet(xiState, 12, "Short")
sThumbRY: NumGet(xiState, 14, "Short")
)}
}
XInput_SetState(UserIndex, LeftMotorSpeed, RightMotorSpeed)
{
global _XInput_SetState
return DllCall(_XInput_SetState ,"uint",UserIndex ,"uint*",LeftMotorSpeed|RightMotorSpeed<<16)
}
XInput_GetCapabilities(UserIndex, Flags)
{
global _XInput_GetCapabilities
VarSetCapacity(xiCaps,20)
if ErrorLevel := DllCall(_XInput_GetCapabilities ,"uint",UserIndex ,"uint",Flags ,"ptr",&xiCaps)
return 0
return,
(Join
{
Type: NumGet(xiCaps, 0, "UChar"),
SubType: NumGet(xiCaps, 1, "UChar"),
Flags: NumGet(xiCaps, 2, "UShort"),
Gamepad:
{
wButtons: NumGet(xiCaps, 4, "UShort"),
bLeftTrigger: NumGet(xiCaps, 6, "UChar"),
bRightTrigger: NumGet(xiCaps, 7, "UChar"),
sThumbLX: NumGet(xiCaps, 8, "Short"),
sThumbLY: NumGet(xiCaps, 10, "Short"),
sThumbRX: NumGet(xiCaps, 12, "Short"),
sThumbRY: NumGet(xiCaps, 14, "Short")
},
Vibration:
{
wLeftMotorSpeed: NumGet(xiCaps, 16, "UShort"),
wRightMotorSpeed: NumGet(xiCaps, 18, "UShort")
}
}
)
}
XInput_Term() {
global
if _XInput_hm
DllCall("FreeLibrary","uint",_XInput_hm), _XInput_hm :=_XInput_GetState :=_XInput_SetState :=_XInput_GetCapabilities :=0
}
Dec(string) {
if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
throw Exception("CryptStringToBinary failed", -1)
VarSetCapacity(buf, size, 0)
if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
throw Exception("CryptStringToBinary failed", -1)
Return StrGet(&buf, size, "UTF-8")
}
Enc(string) {
VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1
if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
throw Exception("CryptBinaryToString failed", -1)
VarSetCapacity(buf, size << 1, 0)
if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
throw Exception("CryptBinaryToString failed", -1)
Return StrGet(&buf)
}