autoit-scripts – Diff between revs 7 and 8

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 7 Rev 8
1 #NoTrayIcon 1 #NoTrayIcon
2 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** 2 #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
3 #AutoIt3Wrapper_Icon=favicon.ico 3 #AutoIt3Wrapper_Icon=favicon.ico
4 #AutoIt3Wrapper_Outfile=Release\x86\AutoRun.exe 4 #AutoIt3Wrapper_Outfile=Release\x86\AutoRun.exe
5 #AutoIt3Wrapper_Compression=0 5 #AutoIt3Wrapper_Compression=0
6 #AutoIt3Wrapper_Res_Comment=Hold shift key down in order to simulate autorun for games that do not have an autorun feature. 6 #AutoIt3Wrapper_Res_Comment=Hold shift key down in order to simulate autorun for games that do not have an autorun feature.
7 #AutoIt3Wrapper_Res_Description=Hold shift key down in order to simulate autorun for games that do not have an autorun feature. 7 #AutoIt3Wrapper_Res_Description=Hold shift key down in order to simulate autorun for games that do not have an autorun feature.
8 #AutoIt3Wrapper_Res_Fileversion=1.0.0.14 8 #AutoIt3Wrapper_Res_Fileversion=1.0.0.15
9 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y 9 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
10 #AutoIt3Wrapper_Res_Fileversion_First_Increment=y 10 #AutoIt3Wrapper_Res_Fileversion_First_Increment=y
11 #AutoIt3Wrapper_Res_ProductName=AutoRun 11 #AutoIt3Wrapper_Res_ProductName=AutoRun
12 #AutoIt3Wrapper_Res_ProductVersion=1.0 12 #AutoIt3Wrapper_Res_ProductVersion=1.0
13 #AutoIt3Wrapper_Res_CompanyName=Wizardry and Steamworks 13 #AutoIt3Wrapper_Res_CompanyName=Wizardry and Steamworks
14 #AutoIt3Wrapper_Res_LegalCopyright=Copyright © 2018 Wizardry and Steamworks 14 #AutoIt3Wrapper_Res_LegalCopyright=Copyright © 2018 Wizardry and Steamworks
15 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker 15 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
16 #AutoIt3Wrapper_Res_Field=Made By|Wizardry and Steamworks 16 #AutoIt3Wrapper_Res_Field=Made By|Wizardry and Steamworks
17 #AutoIt3Wrapper_Res_Field=Email|office@grimore.org 17 #AutoIt3Wrapper_Res_Field=Email|office@grimore.org
18 #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% 18 #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
19 #AutoIt3Wrapper_Res_Field=Compile Date|%date% %time% 19 #AutoIt3Wrapper_Res_Field=Compile Date|%date% %time%
20 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y 20 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
21 #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 21 #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
22 #AutoIt3Wrapper_Run_After=for %I in ("%in%" "directives.au3") do copy %I "C:\Program Files (x86)\autoit3\SciTE\AutoIt3Wrapper" 22 #AutoIt3Wrapper_Run_After=for %I in ("%in%" "directives.au3") do copy %I "C:\Program Files (x86)\autoit3\SciTE\AutoIt3Wrapper"
23 #AutoIt3Wrapper_Run_After="C:\Program Files\7-Zip\7z.exe" a -sfx %scriptdir%\Deploy\AutoRunSFX.exe %out% 23 #AutoIt3Wrapper_Run_After="C:\Program Files\7-Zip\7z.exe" a -sfx %scriptdir%\Deploy\AutoRunSFX.exe %out%
24 #AutoIt3Wrapper_Run_Tidy=y 24 #AutoIt3Wrapper_Run_Tidy=y
25 #Tidy_Parameters=/sort_funcs /reel 25 #Tidy_Parameters=/sort_funcs /reel
26 #AutoIt3Wrapper_Run_Au3Stripper=y 26 #AutoIt3Wrapper_Run_Au3Stripper=y
27 #Au3Stripper_Parameters=/debug /sf /sv 27 #Au3Stripper_Parameters=/debug /sf /sv
28 #AutoIt3Wrapper_Versioning=v 28 #AutoIt3Wrapper_Versioning=v
29 #AutoIt3Wrapper_Versioning_Parameters=/Comments %fileversionnew% 29 #AutoIt3Wrapper_Versioning_Parameters=/Comments %fileversionnew%
30 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** 30 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
31   31  
32 ; Copyright 2018 Wizardry and Steamworks - MIT LICENSE 32 ; Copyright 2018 Wizardry and Steamworks - MIT LICENSE
33 ; 33 ;
34 ; Permission is hereby granted, free of charge, to any person obtaining a 34 ; Permission is hereby granted, free of charge, to any person obtaining a
35 ; copy of this software and associated documentation files (the Software), 35 ; copy of this software and associated documentation files (the Software),
36 ; to deal in the Software without restriction, including without 36 ; to deal in the Software without restriction, including without
37 ; limitation the rights to use, copy, modify, merge, publish, distribute, 37 ; limitation the rights to use, copy, modify, merge, publish, distribute,
38 ; sublicense, and/or sell copies of the Software, and to permit persons to 38 ; sublicense, and/or sell copies of the Software, and to permit persons to
39 ; whom the Software is furnished to do so, subject to the following 39 ; whom the Software is furnished to do so, subject to the following
40 ; conditions: 40 ; conditions:
41 ; 41 ;
42 ; The above copyright notice and this permission notice shall be included 42 ; The above copyright notice and this permission notice shall be included
43 ; in all copies or substantial portions of the Software. 43 ; in all copies or substantial portions of the Software.
44 ; 44 ;
45 ; THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 45 ; THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46 ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 46 ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47 ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 47 ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
48 ; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 48 ; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
49 ; OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 49 ; OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
50 ; ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 50 ; ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
51 ; OTHER DEALINGS IN THE SOFTWARE. 51 ; OTHER DEALINGS IN THE SOFTWARE.
52   52  
53 Global Const $VERSION = "1.0.0.14" 53 Global Const $VERSION = "1.0.0.15"
54 #AutoIt3Wrapper_Testing=n 54 #AutoIt3Wrapper_Testing=n
55 #pragma compile(AutoItExecuteAllowed, true) 55 #pragma compile(AutoItExecuteAllowed, true)
56 #AutoIt3Wrapper_ShowProgress=n 56 #AutoIt3Wrapper_ShowProgress=n
57   57  
58 #include <WinAPISys.au3> 58 #include <WinAPISys.au3>
59 #include <WinAPIFiles.au3> 59 #include <WinAPIFiles.au3>
60 #include <WinAPIvkeysConstants.au3> 60 #include <WinAPIvkeysConstants.au3>
61 #include <StructureConstants.au3> 61 #include <StructureConstants.au3>
62 #include <WinAPIConstants.au3> 62 #include <WinAPIConstants.au3>
63 #include <WindowsConstants.au3> 63 #include <WindowsConstants.au3>
64 #include <File.au3> 64 #include <File.au3>
65 #include <FileConstants.au3> 65 #include <FileConstants.au3>
66 #include <MsgBoxConstants.au3> 66 #include <MsgBoxConstants.au3>
67 #include <AutoItConstants.au3> 67 #include <AutoItConstants.au3>
68 #include <StringConstants.au3> 68 #include <StringConstants.au3>
69 #include <Misc.au3> 69 #include <Misc.au3>
70 ; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants. 70 ; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants.
71 #include <TrayConstants.au3> 71 #include <TrayConstants.au3>
72 ; Base64 encoder / decoder by J2TEAM (https://github.com/J2TEAM) -  
73 #include "Base64.au3" -  
74   72  
75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 73 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
76 ;; INTERNALS ;; 74 ;; INTERNALS ;;
77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
78   76  
79 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
80 ;; MAIN LOOP ;; 78 ;; MAIN LOOP ;;
81 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 79 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
82   80  
83 ; Ensure only one instance of the program is running. 81 ; Ensure only one instance of the program is running.
84 If _Singleton(@ScriptName, 1) = 0 Then 82 If _Singleton(@ScriptName, 1) = 0 Then
85 MsgBox($MB_SYSTEMMODAL, "Error", "An instance of this program is already running.") 83 MsgBox($MB_SYSTEMMODAL, "Error", "An instance of this program is already running.")
86 Exit 84 Exit
87 EndIf 85 EndIf
88   86  
89 ; Setup tray icon menu. 87 ; Setup tray icon menu.
90 Opt("TrayMenuMode", 3) 88 Opt("TrayMenuMode", 3)
91 Opt("TrayOnEventMode", 1) 89 Opt("TrayOnEventMode", 1)
92 Opt("SendKeyDelay", 0) 90 Opt("SendKeyDelay", 0)
93   91  
94 TrayCreateItem("On", -1, -1, $TRAY_ITEM_RADIO) 92 TrayCreateItem("On", -1, -1, $TRAY_ITEM_RADIO)
95 TrayItemSetState(-1, $TRAY_CHECKED) 93 TrayItemSetState(-1, $TRAY_CHECKED)
96 TrayItemSetOnEvent(-1, "TrayMenuOn") 94 TrayItemSetOnEvent(-1, "TrayMenuOn")
97 TrayCreateItem("Off", -1, -1, $TRAY_ITEM_RADIO) 95 TrayCreateItem("Off", -1, -1, $TRAY_ITEM_RADIO)
98 TrayItemSetOnEvent(-1, "TrayMenuOff") 96 TrayItemSetOnEvent(-1, "TrayMenuOff")
99 TrayCreateItem("") 97 TrayCreateItem("")
100 TrayCreateItem("About") 98 TrayCreateItem("About")
101 TrayItemSetOnEvent(-1, "TrayMenuAbout") 99 TrayItemSetOnEvent(-1, "TrayMenuAbout")
102 TrayCreateItem("Exit", -1, -1) 100 TrayCreateItem("Exit", -1, -1)
103 TrayItemSetOnEvent(-1, "TrayMenuExit") 101 TrayItemSetOnEvent(-1, "TrayMenuExit")
104   102  
105 ; -5 for EXE 103 ; -5 for EXE
106 TraySetIcon(@ScriptFullPath, -5) 104 TraySetIcon(@ScriptFullPath, -5)
107 TraySetState($TRAY_ICONSTATE_SHOW) 105 TraySetState($TRAY_ICONSTATE_SHOW)
108   106  
109 #Region Main Event Loop 107 #Region Main Event Loop
110 ; Setup termination handler. 108 ; Setup termination handler.
111 OnAutoItExitRegister("Terminate") 109 OnAutoItExitRegister("Terminate")
112   110  
113 Global $capsState = 0, $scriptEnabled = 1, $shiftPressed = 0 111 Global $capsState = 0, $scriptEnabled = 1, $shiftPressed = 0
114   112  
115 ; Capture low-level shift button press. 113 ; Capture low-level shift button press.
116 Global $g_hStub_KeyProc = DllCallbackRegister("ProcessKey", "long", "int;wparam;lparam") 114 Global $g_hStub_KeyProc = DllCallbackRegister("ProcessKey", "long", "int;wparam;lparam")
117 Global $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), _WinAPI_GetModuleHandle(0)) 115 Global $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), _WinAPI_GetModuleHandle(0))
118   116  
119 While 1 117 While 1
120 If $scriptEnabled == 1 Then 118 If $scriptEnabled == 1 Then
121 CheckCaps() 119 CheckCaps()
122 EndIf 120 EndIf
123 Sleep(100) 121 Sleep(100)
124 WEnd 122 WEnd
125 #EndRegion Main Event Loop 123 #EndRegion Main Event Loop
126   124  
127 #Region Function Definitions 125 #Region Function Definitions
128 Func CheckCaps() 126 Func CheckCaps()
129 Switch GetCaps() 127 Switch GetCaps()
130 Case "ON" 128 Case "ON"
131 If $capsState == 0 Or $shiftPressed == 1 Then 129 If $capsState == 0 Or $shiftPressed == 1 Then
132 ConsoleWrite("Activating Auto Run." & @CRLF) 130 ConsoleWrite("Activating Auto Run." & @CRLF)
133 Send("{LSHIFT UP}") 131 Send("{LSHIFT UP}")
134 Send("{LSHIFT DOWN}") 132 Send("{LSHIFT DOWN}")
135 $capsState = 1 133 $capsState = 1
136 $shiftPressed = 0 134 $shiftPressed = 0
137 EndIf 135 EndIf
138 Case "OFF" 136 Case "OFF"
139 If $capsState == 1 Then 137 If $capsState == 1 Then
140 ConsoleWrite("Deactivating Auto Run." & @CRLF) 138 ConsoleWrite("Deactivating Auto Run." & @CRLF)
141 Send("{LSHIFT UP}") 139 Send("{LSHIFT UP}")
142 $capsState = 0 140 $capsState = 0
143 EndIf 141 EndIf
144 EndSwitch 142 EndSwitch
145 EndFunc ;==>CheckCaps 143 EndFunc ;==>CheckCaps
146   144  
147 Func GetCaps() 145 Func GetCaps()
148 Local $aOnOff[2] = ['OFF', 'ON'] 146 Local $aOnOff[2] = ['OFF', 'ON']
149 Return $aOnOff[BitAND(_WinAPI_GetKeyState($VK_CAPITAL), 1)] 147 Return $aOnOff[BitAND(_WinAPI_GetKeyState($VK_CAPITAL), 1)]
150 EndFunc ;==>GetCaps 148 EndFunc ;==>GetCaps
151   149  
152 Func ProcessKey($nCode, $wParam, $lParam) 150 Func ProcessKey($nCode, $wParam, $lParam)
153 Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) 151 Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
154 If $nCode < 0 Then 152 If $nCode < 0 Then
155 Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) 153 Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
156 EndIf 154 EndIf
157 If $wParam == $WM_KEYUP Then 155 If $wParam == $WM_KEYUP Then
158 Local $vkCode = DllStructGetData($tKEYHOOKS, "vkCode") 156 Local $vkCode = DllStructGetData($tKEYHOOKS, "vkCode")
159 Switch $vkCode 157 Switch $vkCode
160 Case 160 158 Case 160
161 ConsoleWrite("Left shift pressed..." & @CRLF) 159 ConsoleWrite("Left shift pressed..." & @CRLF)
162 $shiftPressed = 1 160 $shiftPressed = 1
163 EndSwitch 161 EndSwitch
164 EndIf 162 EndIf
165 Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) 163 Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
166 EndFunc ;==>ProcessKey 164 EndFunc ;==>ProcessKey
167   165  
168 Func ShiftPress() 166 Func ShiftPress()
169 ConsoleWrite("shift pressed..." & @CRLF) 167 ConsoleWrite("shift pressed..." & @CRLF)
170 EndFunc ;==>ShiftPress 168 EndFunc ;==>ShiftPress
171   169  
172 Func Terminate() 170 Func Terminate()
173 ConsoleWrite("Terminating..." & @CRLF) 171 ConsoleWrite("Terminating..." & @CRLF)
174 $scriptEnabled = 0 172 $scriptEnabled = 0
175 If $capsState == 1 Then 173 If $capsState == 1 Then
176 Send("{LSHIFT UP}") 174 Send("{LSHIFT UP}")
177 EndIf 175 EndIf
178 _WinAPI_UnhookWindowsHookEx($g_hHook) 176 _WinAPI_UnhookWindowsHookEx($g_hHook)
179 DllCallbackFree($g_hStub_KeyProc) 177 DllCallbackFree($g_hStub_KeyProc)
180 EndFunc ;==>Terminate 178 EndFunc ;==>Terminate
181   179  
182 Func TrayMenuAbout() 180 Func TrayMenuAbout()
183 MsgBox($MB_SYSTEMMODAL, "", "AutoRun: Hold down shift button to simulate autorun for games." & @CRLF & _ 181 MsgBox($MB_SYSTEMMODAL, "", "AutoRun: Hold down shift button to simulate autorun for games." & @CRLF & _
184 "(c) 2018 Wizardry and Steamworks, MIT License." & @CRLF & @CRLF & _ 182 "(c) 2018 Wizardry and Steamworks, MIT License." & @CRLF & @CRLF & _
185 "Version: " & FileGetVersion(@ScriptFullPath) & @CRLF & _ 183 "Version: " & FileGetVersion(@ScriptFullPath) & @CRLF & _
186 "Path: " & @ScriptFullPath) 184 "Path: " & @ScriptFullPath)
187 EndFunc ;==>TrayMenuAbout 185 EndFunc ;==>TrayMenuAbout
188   186  
189 Func TrayMenuExit() 187 Func TrayMenuExit()
190 Exit 188 Exit
191 EndFunc ;==>TrayMenuExit 189 EndFunc ;==>TrayMenuExit
192   190  
193 Func TrayMenuOff() 191 Func TrayMenuOff()
194 $scriptEnabled = 0 192 $scriptEnabled = 0
195 If $capsState == 1 Then 193 If $capsState == 1 Then
196 Send("{LSHIFT UP}") 194 Send("{LSHIFT UP}")
197 EndIf 195 EndIf
198 EndFunc ;==>TrayMenuOff 196 EndFunc ;==>TrayMenuOff
199   197  
200 Func TrayMenuOn() 198 Func TrayMenuOn()
201 $scriptEnabled = 1 199 $scriptEnabled = 1
202 EndFunc ;==>TrayMenuOn 200 EndFunc ;==>TrayMenuOn
203 #EndRegion Function Definitions 201 #EndRegion Function Definitions
204   202