autoit-scripts – Blame information for rev 7

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