/AutoRun/AutoRun.au3 |
@@ -2,11 +2,10 @@ |
#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.11 |
#AutoIt3Wrapper_Res_Fileversion=1.0.0.14 |
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y |
#AutoIt3Wrapper_Res_Fileversion_First_Increment=y |
#AutoIt3Wrapper_Res_ProductName=AutoRun |
@@ -25,7 +24,7 @@ |
#AutoIt3Wrapper_Run_Tidy=y |
#Tidy_Parameters=/sort_funcs /reel |
#AutoIt3Wrapper_Run_Au3Stripper=y |
#Au3Stripper_Parameters=/debug |
#Au3Stripper_Parameters=/debug /sf /sv |
#AutoIt3Wrapper_Versioning=v |
#AutoIt3Wrapper_Versioning_Parameters=/Comments %fileversionnew% |
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** |
@@ -51,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.11" |
Global Const $VERSION = "1.0.0.14" |
#AutoIt3Wrapper_Testing=n |
#pragma compile(AutoItExecuteAllowed, true) |
#AutoIt3Wrapper_ShowProgress=n |
@@ -59,11 +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) |
@@ -77,13 +80,16 @@ |
;; MAIN LOOP ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
; Setup termination handler. |
OnAutoItExitRegister("Terminate") |
; 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("SendCapslockMode", 0) |
Opt("SendKeyDelay", 0) |
|
TrayCreateItem("On", -1, -1, $TRAY_ITEM_RADIO) |
TrayItemSetState(-1, $TRAY_CHECKED) |
@@ -100,35 +106,34 @@ |
TraySetIcon(@ScriptFullPath, -5) |
TraySetState($TRAY_ICONSTATE_SHOW) |
|
Global $capsState = 0, $scriptEnabled = 1 |
#Region Main Event Loop |
; Setup termination handler. |
OnAutoItExitRegister("Terminate") |
|
; Run main event loop. |
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 |
ToggleAutoRun() |
CheckCaps() |
EndIf |
Sleep(100) |
WEnd |
#EndRegion Main Event Loop |
|
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() |
#Region Function Definitions |
Func CheckCaps() |
Switch GetCaps() |
Case "ON" |
If $capsState == 0 Then |
ConsoleWrite("Activating Auto Run" & @CRLF) |
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 |
@@ -137,12 +142,48 @@ |
$capsState = 0 |
EndIf |
EndSwitch |
EndFunc ;==>ToggleAutoRun |
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." & @CRLF & @CRLF & _ |
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 & _ |
"Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1)) |
"Path: " & @ScriptFullPath) |
EndFunc ;==>TrayMenuAbout |
|
Func TrayMenuExit() |
@@ -159,3 +200,4 @@ |
Func TrayMenuOn() |
$scriptEnabled = 1 |
EndFunc ;==>TrayMenuOn |
#EndRegion Function Definitions |