#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=favicon.ico #AutoIt3Wrapper_Outfile=Release\x86\AutoRun.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_AutoIncrement=y #AutoIt3Wrapper_Res_Fileversion_First_Increment=y #AutoIt3Wrapper_Res_ProductName=AutoRun #AutoIt3Wrapper_Res_ProductVersion=1.0 #AutoIt3Wrapper_Res_CompanyName=Wizardry and Steamworks #AutoIt3Wrapper_Res_LegalCopyright=Copyright © 2018 Wizardry and Steamworks #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Res_Field=Made By|Wizardry and Steamworks #AutoIt3Wrapper_Res_Field=Email|office@grimore.org #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% #AutoIt3Wrapper_Res_Field=Compile Date|%date% %time% #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 #AutoIt3Wrapper_Versioning=v #AutoIt3Wrapper_Versioning_Parameters=/Comments %fileversionnew% #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; Copyright 2018 Wizardry and Steamworks - MIT LICENSE ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the Software), ; to deal in the Software without restriction, including without ; limitation the rights to use, copy, modify, merge, publish, distribute, ; sublicense, and/or sell copies of the Software, and to permit persons to ; whom the Software is furnished to do so, subject to the following ; conditions: ; ; The above copyright notice and this permission notice shall be included ; in all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR ; OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ; 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" #AutoIt3Wrapper_Testing=n #pragma compile(AutoItExecuteAllowed, true) #AutoIt3Wrapper_ShowProgress=n #include #include #include #include #include #include #include #include #include #include #include #include ; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants. #include ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; INTERNALS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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 tray icon menu. Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) Opt("SendKeyDelay", 0) TrayCreateItem("On", -1, -1, $TRAY_ITEM_RADIO) TrayItemSetState(-1, $TRAY_CHECKED) TrayItemSetOnEvent(-1, "TrayMenuOn") TrayCreateItem("Off", -1, -1, $TRAY_ITEM_RADIO) TrayItemSetOnEvent(-1, "TrayMenuOff") TrayCreateItem("") TrayCreateItem("About") TrayItemSetOnEvent(-1, "TrayMenuAbout") TrayCreateItem("Exit", -1, -1) TrayItemSetOnEvent(-1, "TrayMenuExit") ; -5 for EXE TraySetIcon(@ScriptFullPath, -5) TraySetState($TRAY_ICONSTATE_SHOW) #Region Main Event Loop ; Setup termination handler. OnAutoItExitRegister("Terminate") 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)) While 1 If $scriptEnabled == 1 Then CheckCaps() EndIf Sleep(100) WEnd #EndRegion Main Event Loop #Region Function Definitions Func CheckCaps() Switch GetCaps() Case "ON" If $capsState == 0 Or $shiftPressed == 1 Then ConsoleWrite("Activating Auto Run." & @CRLF) Send("{LSHIFT UP}") Send("{LSHIFT DOWN}") $capsState = 1 $shiftPressed = 0 EndIf Case "OFF" If $capsState == 1 Then ConsoleWrite("Deactivating Auto Run." & @CRLF) Send("{LSHIFT UP}") $capsState = 0 EndIf EndSwitch EndFunc ;==>CheckCaps 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 & _ "Version: " & FileGetVersion(@ScriptFullPath) & @CRLF & _ "Path: " & @ScriptFullPath) EndFunc ;==>TrayMenuAbout Func TrayMenuExit() Exit EndFunc ;==>TrayMenuExit Func TrayMenuOff() $scriptEnabled = 0 If $capsState == 1 Then Send("{LSHIFT UP}") EndIf EndFunc ;==>TrayMenuOff Func TrayMenuOn() $scriptEnabled = 1 EndFunc ;==>TrayMenuOn #EndRegion Function Definitions