/AutoRun/AutoRun.au3 |
@@ -2,10 +2,11 @@ |
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** |
#AutoIt3Wrapper_Icon=favicon.ico |
#AutoIt3Wrapper_Outfile=Release\x86\AutoRun.exe |
#AutoIt3Wrapper_Outfile_x64=Release\x64\AutoRun_x64.exe |
#AutoIt3Wrapper_Compression=0 |
#AutoIt3Wrapper_Res_Comment=Hold shift key down in order to simulate autorun for games that do not have an autorun feature. |
#AutoIt3Wrapper_Res_Description=Hold shift key down in order to simulate autorun for games that do not have an autorun feature. |
#AutoIt3Wrapper_Res_Fileversion=1.0.0.15 |
#AutoIt3Wrapper_Res_Fileversion=1.0.0.7 |
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y |
#AutoIt3Wrapper_Res_Fileversion_First_Increment=y |
#AutoIt3Wrapper_Res_ProductName=AutoRun |
@@ -20,11 +21,10 @@ |
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y |
#AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 |
#AutoIt3Wrapper_Run_After=for %I in ("%in%" "directives.au3") do copy %I "C:\Program Files (x86)\autoit3\SciTE\AutoIt3Wrapper" |
#AutoIt3Wrapper_Run_After="C:\Program Files\7-Zip\7z.exe" a -sfx %scriptdir%\Deploy\AutoRunSFX.exe %out% |
#AutoIt3Wrapper_Run_Tidy=y |
#Tidy_Parameters=/sort_funcs /reel |
#AutoIt3Wrapper_Run_Au3Stripper=y |
#Au3Stripper_Parameters=/debug /sf /sv |
#Au3Stripper_Parameters=/debug |
#AutoIt3Wrapper_Versioning=v |
#AutoIt3Wrapper_Versioning_Parameters=/Comments %fileversionnew% |
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** |
@@ -50,7 +50,7 @@ |
; ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
; OTHER DEALINGS IN THE SOFTWARE. |
|
Global Const $VERSION = "1.0.0.15" |
Global Const $VERSION = "1.0.0.7" |
#AutoIt3Wrapper_Testing=n |
#pragma compile(AutoItExecuteAllowed, true) |
#AutoIt3Wrapper_ShowProgress=n |
@@ -58,17 +58,15 @@ |
#include <WinAPISys.au3> |
#include <WinAPIFiles.au3> |
#include <WinAPIvkeysConstants.au3> |
#include <StructureConstants.au3> |
#include <WinAPIConstants.au3> |
#include <WindowsConstants.au3> |
#include <File.au3> |
#include <FileConstants.au3> |
#include <MsgBoxConstants.au3> |
#include <AutoItConstants.au3> |
#include <StringConstants.au3> |
#include <Misc.au3> |
; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants. |
#include <TrayConstants.au3> |
; Base64 encoder / decoder by J2TEAM (https://github.com/J2TEAM) |
#include "Base64.au3" |
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; INTERNALS ;; |
@@ -78,16 +76,13 @@ |
;; MAIN LOOP ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
; Ensure only one instance of the program is running. |
If _Singleton(@ScriptName, 1) = 0 Then |
MsgBox($MB_SYSTEMMODAL, "Error", "An instance of this program is already running.") |
Exit |
EndIf |
; Setup termination handler. |
OnAutoItExitRegister("Terminate") |
|
; Setup tray icon menu. |
Opt("TrayMenuMode", 3) |
Opt("TrayOnEventMode", 1) |
Opt("SendKeyDelay", 0) |
Opt("SendCapslockMode", 0) |
|
TrayCreateItem("On", -1, -1, $TRAY_ITEM_RADIO) |
TrayItemSetState(-1, $TRAY_CHECKED) |
@@ -104,34 +99,35 @@ |
TraySetIcon(@ScriptFullPath, -5) |
TraySetState($TRAY_ICONSTATE_SHOW) |
|
#Region Main Event Loop |
; Setup termination handler. |
OnAutoItExitRegister("Terminate") |
Global $capsState = 0, $scriptEnabled = 1 |
|
Global $capsState = 0, $scriptEnabled = 1, $shiftPressed = 0 |
|
; Capture low-level shift button press. |
Global $g_hStub_KeyProc = DllCallbackRegister("ProcessKey", "long", "int;wparam;lparam") |
Global $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), _WinAPI_GetModuleHandle(0)) |
|
; Run main event loop. |
While 1 |
If $scriptEnabled == 1 Then |
CheckCaps() |
ToggleAutoRun() |
EndIf |
Sleep(100) |
WEnd |
#EndRegion Main Event Loop |
|
#Region Function Definitions |
Func CheckCaps() |
Switch GetCaps() |
Func _GetCaps() |
Local $aOnOff[2] = ['OFF', 'ON'] |
Return $aOnOff[BitAND(_WinAPI_GetKeyState($VK_CAPITAL), 1)] |
EndFunc ;==>_GetCaps |
|
; Function definitions |
|
Func Terminate() |
ConsoleWrite("Terminating..." & @CRLF) |
Send("{LSHIFT UP}") |
EndFunc ;==>Terminate |
|
Func ToggleAutoRun() |
Switch _GetCaps() |
Case "ON" |
If $capsState == 0 Or $shiftPressed == 1 Then |
ConsoleWrite("Activating Auto Run." & @CRLF) |
Send("{LSHIFT UP}") |
If $capsState == 0 Then |
ConsoleWrite("Activating Auto Run" & @CRLF) |
Send("{LSHIFT DOWN}") |
$capsState = 1 |
$shiftPressed = 0 |
EndIf |
Case "OFF" |
If $capsState == 1 Then |
@@ -140,48 +136,12 @@ |
$capsState = 0 |
EndIf |
EndSwitch |
EndFunc ;==>CheckCaps |
EndFunc ;==>ToggleAutoRun |
|
Func GetCaps() |
Local $aOnOff[2] = ['OFF', 'ON'] |
Return $aOnOff[BitAND(_WinAPI_GetKeyState($VK_CAPITAL), 1)] |
EndFunc ;==>GetCaps |
|
Func ProcessKey($nCode, $wParam, $lParam) |
Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) |
If $nCode < 0 Then |
Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) |
EndIf |
If $wParam == $WM_KEYUP Then |
Local $vkCode = DllStructGetData($tKEYHOOKS, "vkCode") |
Switch $vkCode |
Case 160 |
ConsoleWrite("Left shift pressed..." & @CRLF) |
$shiftPressed = 1 |
EndSwitch |
EndIf |
Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) |
EndFunc ;==>ProcessKey |
|
Func ShiftPress() |
ConsoleWrite("shift pressed..." & @CRLF) |
EndFunc ;==>ShiftPress |
|
Func Terminate() |
ConsoleWrite("Terminating..." & @CRLF) |
$scriptEnabled = 0 |
If $capsState == 1 Then |
Send("{LSHIFT UP}") |
EndIf |
_WinAPI_UnhookWindowsHookEx($g_hHook) |
DllCallbackFree($g_hStub_KeyProc) |
EndFunc ;==>Terminate |
|
Func TrayMenuAbout() |
MsgBox($MB_SYSTEMMODAL, "", "AutoRun: Hold down shift button to simulate autorun for games." & @CRLF & _ |
"(c) 2018 Wizardry and Steamworks, MIT License." & @CRLF & @CRLF & _ |
MsgBox($MB_SYSTEMMODAL, "", "AutoRun ~ Hold down shift button." & @CRLF & @CRLF & _ |
"Version: " & FileGetVersion(@ScriptFullPath) & @CRLF & _ |
"Path: " & @ScriptFullPath) |
"Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1)) |
EndFunc ;==>TrayMenuAbout |
|
Func TrayMenuExit() |
@@ -198,4 +158,3 @@ |
Func TrayMenuOn() |
$scriptEnabled = 1 |
EndFunc ;==>TrayMenuOn |
#EndRegion Function Definitions |
/AutoRun/Base64.au3 |
@@ -0,0 +1,40 @@ |
; Base64 encoder / decoder by J2TEAM (https://github.com/J2TEAM) |
|
Func _Base64Decode($Data) |
Local $Opcode = "0xC81000005356578365F800E8500000003EFFFFFF3F3435363738393A3B3C3DFFFFFF00FFFFFF000102030405060708090A0B0C0D0E0F10111213141516171819FFFFFFFFFFFF1A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132338F45F08B7D0C8B5D0831D2E9910000008365FC00837DFC047D548A034384C0750383EA033C3D75094A803B3D75014AB00084C0751A837DFC047D0D8B75FCC64435F400FF45FCEBED6A018F45F8EB1F3C2B72193C7A77150FB6F083EE2B0375F08A068B75FC884435F4FF45FCEBA68D75F4668B06C0E002C0EC0408E08807668B4601C0E004C0EC0208E08847018A4602C0E00624C00A46038847028D7F038D5203837DF8000F8465FFFFFF89D05F5E5BC9C21000" |
|
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") |
DllStructSetData($CodeBuffer, 1, $Opcode) |
|
Local $Ouput = DllStructCreate("byte[" & BinaryLen($Data) & "]") |
Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ |
"str", $Data, _ |
"ptr", DllStructGetPtr($Ouput), _ |
"int", 0, _ |
"int", 0) |
|
Return BinaryMid(DllStructGetData($Ouput, 1), 1, $Ret[0]) |
EndFunc |
|
Func _Base64Encode($Data, $LineBreak = 76) |
Local $Opcode = "0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E5BC9C21000" |
|
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") |
DllStructSetData($CodeBuffer, 1, $Opcode) |
|
$Data = Binary($Data) |
Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") |
DllStructSetData($Input, 1, $Data) |
|
$LineBreak = Floor($LineBreak / 4) * 4 |
Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3) |
$OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4 |
|
Local $Ouput = DllStructCreate("char[" & $OputputSize & "]") |
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ |
"ptr", DllStructGetPtr($Input), _ |
"int", BinaryLen($Data), _ |
"ptr", DllStructGetPtr($Ouput), _ |
"uint", $LineBreak) |
Return DllStructGetData($Ouput, 1) |
EndFunc |