root/Apple Wireless Keyboard Helper/trunk/Misuzilla.Applications.AppleWirelessKeyboardHelper/Scripts/Default.py.sample @ 351

Revision 351, 2.9 kB (checked in by tomoyo, 3 years ago)

スクリプトを書き換え忘れていたので修正。

Line 
1import clr
2
3from System import *
4from System.Diagnostics import Process
5from System.Runtime.InteropServices import Marshal
6from System.Windows.Forms import *
7from Misuzilla.Applications.AppleWirelessKeyboardHelper import Program, Util
8
9# Master Volume Control
10clr.AddReferenceByPartialName("MasterVolumeControlLibrary")
11from MasterVolumeControlLibrary import MasterVolumeControl
12volControl = MasterVolumeControl.GetControl()
13
14def OnLoad(sender, e):
15  pass
16
17def OnUnload(sender, e):
18  volControl.Dispose()
19
20Program.Load   += OnLoad
21Program.Unload += OnUnload
22
23"""
24Power Button
25"""
26def OnDown_Power():
27  # Lock desktop
28  Process.Start("rundll32.exe", "user32.dll,LockWorkStation")
29
30"""
31Eject Button
32"""
33def OnDown_Eject():
34  #Util.Eject("E");
35  pass
36
37"""
38Alpha Numeric(eisu) (JIS only)
39"""
40def OnUp_JISAlphaNumeric():
41  Util.SendInput(Keys.HanjaMode) # IME on/off
42
43"""
44Kana Key (JIS only)
45"""
46def OnUp_JISKana():
47  Util.SendInput(Keys.IMEConvert) # IME Convert
48
49"""
50Fn + F1 ... F12 (OnDown_Fn_[KeyName])
51"""
52def OnDown_Fn_F1():
53  MessageBox.Show('Fn+F1') # System.Windows.Forms.MessageBox
54
55def OnDown_Fn_F2():
56  Program.ShowBalloonTip('Fn+F2') # ShowBalloonTip(str) or ShowBalloonTip(str, System.Windows.Forms.ToolTipIcon)
57
58def OnDown_Fn_F3():
59  if Environment.OSVersion.Version.Major >= 6:
60    Process.Start("rundll32.exe", "DwmApi #105") # 3D Filp
61  else:
62    toggleDesktop() # Show Desktops
63
64def OnDown_Fn_F4():
65  Util.SendInput(Keys.PrintScreen) # System.Windows.Forms.Keys
66
67def OnDown_Fn_F5():
68  pass
69
70def OnDown_Fn_F6():
71  pass
72
73def OnDown_Fn_F7():
74  # iTunes / Previous Track
75  execiTunes(lambda it: it.PreviousTrack())
76
77def OnDown_Fn_F8():
78  # iTunes / PlayPause
79  execiTunes(lambda it: it.PlayPause())
80
81def OnDown_Fn_F9():
82  # iTunes / PlayPause
83  execiTunes(lambda it: it.NextTrack())
84
85def OnDown_Fn_F10():
86  volControl.Mute = not volControl.Mute
87
88def OnDown_Fn_F11():
89  volControl.VolumeDown()
90
91def OnDown_Fn_F12():
92  volControl.VolumeUp()
93
94"""
95Fn+BackSpace -> Delete
96"""
97def OnDown_Fn_Back():
98  Util.SendInput(Keys.Delete)
99
100"""
101Fn+Delete -> VolumeUp (for F12 replaced by Delete)
102"""
103def OnDown_Fn_Delete():
104  volControl.VolumeUp()
105
106"""
107Fn+Up/Down -> PageUp/PageDown
108"""
109def OnDown_Fn_Up():
110  Util.SendInput(Keys.PageUp)
111
112def OnDown_Fn_Down():
113  Util.SendInput(Keys.PageDown)
114
115"""
116Fn+Left/Right -> Home/End
117"""
118def OnDown_Fn_Left():
119  Util.SendInput(Keys.Home)
120
121def OnDown_Fn_Right():
122  Util.SendInput(Keys.End)
123
124# ----
125
126# Create COM Object
127def createObject(progID):
128  t = Type.GetTypeFromProgID(progID)
129  return Activator.CreateInstance(t)
130
131# iTunes Helper functions
132def execiTunes(f):
133  it = createObject('iTunes.Application')
134  f(it)
135  Marshal.ReleaseComObject(it)
136
137# Show desktop
138def toggleDesktop():
139  shell = createObject('Shell.Application')
140  shell.ToggleDesktop()
141  Marshal.ReleaseComObject(shell)
Note: See TracBrowser for help on using the browser.