My favorites
▼
|
Sign in
beejcode
Random Code From Brent Anderson (Beej)
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
Griffin AirClick AutoHotKey Script
/
airclick-nosleep.ahk
‹r3
r8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
;Must be in auto-execute section if I want to use the constants
#Include %A_ScriptDir%\AHKHID.ahk
; Splash text settings
Spash_Position_Y := A_ScreenHeight - 100
Spash_Colour_Text =FFFFFF
Spash_Colour_Background =000000
Splash_Font_Size =24
Splash_Time =1500 ; milliseconds
;Create GUI to receive messages
Gui, +LastFound
hGui := WinExist()
;Intercept WM_INPUT messages
WM_INPUT := 0xFF
OnMessage(WM_INPUT, "InputMsg")
;Register Remote Control with RIDEV_INPUTSINK (so that data is received even in the background)
r := HID_Register(65440, 1, hGui, RIDEV_INPUTSINK)
;Prefix loop
Loop {
Sleep 1000
If WinActive("ahk_class QWidget") Or WinActive("ahk_class VLC DirectX")
sPrefix := "VLC"
Else If WinActive("ahk_class Winamp v1.x") Or WinActive("ahk_class Winamp Video")
sPrefix := "Winamp"
Else If WinActive("ahk_class MediaPlayerClassicW")
sPrefix := "MPC"
Else If WinActive("ahk_class PowerDVD")
sPrefix :=PowerDVD
Else sPrefix := "Default"
}
Return
InputMsg(wParam, lParam) {
Local devh, iKey, sLabel
Critical
;Get handle of device
devh := HID_GetInputInfo(lParam, II_DEVHANDLE)
;Check for error
If (devh <> -1) ;Check that it is Griffin Airclick
And (HID_GetDevInfo(devh, DI_HID_VENDORID, True) = 1917)
And (HID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = 4118) {
;Get data
iKey := HID_GetInputData(lParam, uData)
;Only get first key
;Check for error
If (iKey <> -1) {
;Get keycode (located at the 6th byte)
iKey := NumGet(uData, 4, "UChar")
If (iKey = 0) {
lastKey := 0
repeatCounter := 0
dontRepeat := 0
Return
}
If (iKey = lastKey)
repeatCounter := repeatCounter + 1
If (dontRepeat = 1)
{
Return
}
;Call the appropriate sub if it exists
if (iKey = 2 or iKey = 4)
sLabel := iKey
else
sLabel := sPrefix "_" iKey
lastKey := iKey
If IsLabel(sLabel)
Gosub, %sLabel%
}
}
}
Default_1: ;Play/Pause
Send {Media_Play_Pause}
Display_Splash_Text("Play/Pause")
dontRepeat := 1
Return
Default_8: ;Next
Send {Media_Next}
Display_Splash_Text("Next")
dontRepeat := 1
Return
Default_16: ;Previous
Send {Media_Prev}
Display_Splash_Text("Previous")
dontRepeat := 1
Return
2: ;Volume Up
Send {Volume_Up 1}
Display_Splash_Text("Volume Up")
Return
4: ;Volume Down
Send {Volume_Down 1}
Display_Splash_Text("Volume Down")
Return
VLC_16: ;Rewind
SendInput !{Left}
Return
VLC_1: ;Pause
SendInput {Space}
dontRepeat := 1
Return
VLC_8: ;Forward
SendInput !{Right}
Return
MPC_16: ;Rewind
SendInput +{Left}
Return
MPC_8: ;FF
SendInput +{Right}
Return
MPC_1: ;Pause
SendInput {Space}
dontRepeat := 1
Return
PowerDVD_16: ;Previous Chapter
SendInput {P}
Return
PowerDVD_8: ;Next Chapter
SendInput {N}
Return
PowerDVD_1: ;Pause
SendInput {Space}
dontRepeat := 1
Return
Display_Splash_Text(Splash_Text)
{
Global
SplashImage,, B Y%Spash_Position_Y% W500 CT%Spash_Colour_Text% CW%Spash_Colour_Background% FM%Splash_Font_Size% WM1000,, %Splash_Text%, Splash, Courier New
SetTimer, Splash_Off, %Splash_Time%
}
Splash_Off:
SplashImage, Off
Return
Show details
Hide details
Change log
r7
by brentand...@next-technologies.com on Mar 10, 2012
Diff
[No log message]
Go to:
/trunk/Doc/Brent Anderson.doc
...tKey Script/airclick-nosleep.ahk
... Script/airclick-screensaver.ahk
Project members,
sign in
to write a code review
Older revisions
r3
by brentand...@next-technologies.com on Jun 25, 2011
Diff
[No log message]
All revisions of this file
File info
Size: 3472 bytes, 166 lines
View raw file
Powered by
Google Project Hosting