Skip to content

Commit e091634

Browse files
committed
hotkeys
1 parent b544293 commit e091634

File tree

4 files changed

+51
-30
lines changed

4 files changed

+51
-30
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
| `Win+Num4(Left)` | `Win+Num5(Middle)` | `Win+Num6(Right)` |
2525
| `Win+Num1(BottomLeft)` | `Win+Num2(Bottom)` | `Win+Num3(BottomRight)` |
2626

27+
| `Laptop keyboard` | | |
28+
|:------------------------------:|:--------------------------:|:-------------------------------:|
29+
| `alt+ctrl+shift+7(TopLeft)` | `alt+ctrl+shift+8(Top)` | `alt+ctrl+shift+9(TopRight)` |
30+
| `alt+ctrl+shift+U(Left)` | `alt+ctrl+shift+I(Middle)` | `alt+ctrl+shift+O(Right)` |
31+
| `alt+ctrl+shift+J(BottomLeft)` | `alt+ctrl+shift+K(Bottom)` | `alt+ctrl+shift+L(BottomRight)` |
32+
2733
* Each hotkey is switched differently depending on the aspect ratio of the screen.
2834
* To control windows such as Task Manager, you must run in administrator mode.
2935

makeinstaller.iss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
[Setup]
44
AppName="PyWinLayout"
5-
AppVerName="PyWinLayout 0.1.1"
5+
AppVerName="PyWinLayout 0.1.2"
66
DefaultDirName="{pf}\PyWinLayout"
77
DefaultGroupName="PyWinLayout"
8-
AppVersion="0.1.1"
8+
AppVersion="0.1.2"
99
AppCopyright="Taehong Kim"
1010
AppPublisher="Taehong Kim"
1111
UninstallDisplayIcon="{app}\PyWinLayout.exe"
1212
Compression=lzma2/max
1313
SolidCompression=yes
1414
OutputDir="dist"
15-
OutputBaseFilename="PyWinLayout-0.1.1-Setup"
16-
; VersionInfoVersion="0.1.1"
17-
VersionInfoProductVersion="0.1.1"
15+
OutputBaseFilename="PyWinLayout-0.1.2-Setup"
16+
; VersionInfoVersion="0.1.2"
17+
VersionInfoProductVersion="0.1.2"
1818
VersionInfoCompany="Taehong Kim"
1919
VersionInfoCopyright="Taehong Kim"
2020
ArchitecturesInstallIn64BitMode="x64"

source/main.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
__appname__ = 'PyWinLayout'
5-
__version__ = '0.1.1'
5+
__version__ = '0.1.2'
66
__author__ = 'Taehong Kim'
77
__email__ = '[email protected]'
88
__license__ = ''
@@ -183,25 +183,27 @@ def __init__(self, parent=None):
183183

184184
def bind_hotkey(self):
185185
for preset in LAYOUT_PRESETS:
186-
self.RegisterHotKey(preset['event_id'], *preset['codes'])
187-
self.Bind(wx.EVT_HOTKEY, self.handle_hotkey, id=preset['event_id'])
186+
for i in range(len(preset['codes'])):
187+
self.RegisterHotKey(preset['event_ids'][i], *preset['codes'][i])
188+
self.Bind(wx.EVT_HOTKEY, self.handle_hotkey, id=preset['event_ids'][i])
188189

189190
def unbind_hotkey(self):
190191
for preset in LAYOUT_PRESETS:
191-
self.Unbind(wx.EVT_HOTKEY, id=preset['event_id'])
192-
self.UnregisterHotKey(preset['event_id'])
192+
for i in range(len(preset['codes'])):
193+
self.Unbind(wx.EVT_HOTKEY, id=preset['event_ids'][i])
194+
self.UnregisterHotKey(preset['event_ids'][i])
193195

194196
def handle_hotkey(self, event):
195197
for preset in LAYOUT_PRESETS:
196-
if preset['event_id'] == event.GetId():
197-
self.window_layout_manager.resize_foreground_window(preset)
198+
for i in range(len(preset['codes'])):
199+
if preset['event_ids'][i] == event.GetId():
200+
self.window_layout_manager.resize_foreground_window(preset)
198201

199202
def OnClose(self, event=None):
200203
self.unbind_hotkey()
201204
# self.other_instance_watcher.Stop()
202205
wx.CallAfter(self.taskbar.Destroy)
203206
wx.CallAfter(self.Destroy)
204-
# print('OnClose')
205207

206208

207209
class HotKeyApp(wx.App):

source/presets.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,47 @@
1515
LAYOUT_PRESETS = [
1616
{
1717
'hotkey': 'win+num5',
18+
'hotkeys': ['win+num5', 'alt+ctrl+shift+I'],
1819
'landscape': [((1 - v) / 2, 0.00, v, 1.00) for v in (1.00, 0.50, 0.34,)],
1920
'portrait': [(0.00, (1 - v) / 2, 1.00, v) for v in (1.00, 0.50,)]
2021
}, {
2122
'hotkey': 'win+num2',
23+
'hotkeys': ['win+num2', 'alt+ctrl+shift+K'],
2224
'landscape': [((1 - v) / 2, 0.50, v, 0.50) for v in (1.00, 0.50, 0.34,)],
2325
'portrait': [(0.00, 1 - v, 1.00, v) for v in (0.75, 0.50, 0.25,)]
2426
}, {
2527
'hotkey': 'win+num8',
28+
'hotkeys': ['win+num8', 'alt+ctrl+shift+8'],
2629
'landscape': [((1 - v) / 2, 0.00, v, 0.50) for v in (1.00, 0.50, 0.34,)],
2730
'portrait': [(0.00, 0.00, 1.00, v) for v in (0.75, 0.50, 0.25,)]
2831
}, {
2932
'hotkey': 'win+num4',
33+
'hotkeys': ['win+num4', 'alt+ctrl+shift+U'],
3034
'landscape': [(0.00, 0.00, v, 1.00) for v in (0.67, 0.50, 0.33,)],
3135
'portrait': [(0.00, (1 - v) / 2, 0.50, v) for v in (1.00, 0.50,)]
3236
}, {
3337
'hotkey': 'win+num6',
38+
'hotkeys': ['win+num6', 'alt+ctrl+shift+O'],
3439
'landscape': [(1 - v, 0.00, v, 1.00) for v in (0.67, 0.50, 0.33,)],
3540
'portrait': [(0.50, (1 - v) / 2, 0.50, v) for v in (1.00, 0.50,)]
3641
}, {
3742
'hotkey': 'win+num1',
43+
'hotkeys': ['win+num1', 'alt+ctrl+shift+J'],
3844
'landscape': [(0.00, 0.50, v, 0.50) for v in (0.67, 0.50, 0.33,)],
3945
'portrait': [(0.00, 1 - v, 0.50, v) for v in (0.75, 0.50, 0.25,)]
4046
}, {
4147
'hotkey': 'win+num3',
48+
'hotkeys': ['win+num3', 'alt+ctrl+shift+L'],
4249
'landscape': [(1 - v, 0.50, v, 0.50) for v in (0.67, 0.50, 0.33,)],
4350
'portrait': [(0.50, 1 - v, 0.50, v) for v in (0.75, 0.50, 0.25,)]
4451
}, {
4552
'hotkey': 'win+num7',
53+
'hotkeys': ['win+num7', 'alt+ctrl+shift+7'],
4654
'landscape': [(0.00, 0.00, v, 0.50) for v in (0.67, 0.50, 0.33,)],
4755
'portrait': [(0.00, 0.00, 0.50, v) for v in (0.75, 0.50, 0.25,)]
4856
}, {
4957
'hotkey': 'win+num9',
58+
'hotkeys': ['win+num9', 'alt+ctrl+shift+9'],
5059
'landscape': [(1 - v, 0.00, v, 0.50) for v in (0.67, 0.50, 0.33,)],
5160
'portrait': [(0.50, 0.00, 0.50, v) for v in (0.75, 0.50, 0.25,)]
5261
},
@@ -63,23 +72,27 @@ def operate_or(values):
6372
def organize_presets(presets):
6473
modifiers = sorted(['alt', 'ctrl', 'shift', 'windows'])
6574
for i in range(len(presets) - 1, -1, -1):
66-
keys = presets[i]['hotkey'].split('+')
67-
mods = [v for v in modifiers if v in keys]
68-
base = [v for v in keys if v and v not in modifiers]
69-
presets[i]['hotkey'] = '+'.join(mods + base)
70-
71-
keys = presets[i]['hotkey'].split('+')
72-
codes = [KEYMAP.get(key) for key in keys]
73-
if None in codes:
74-
presets.pop(i)
75-
continue
76-
77-
codes = [v for v in codes if v is not None]
78-
79-
presets[i]['codes'] = (operate_or(codes[:-1]), codes[-1],)
80-
m = hashlib.new('md5')
81-
m.update(''.join([str(v) for v in presets[i]['codes']]).encode('utf-8'))
82-
presets[i]['event_id'] = int(m.hexdigest()[:5], 16)
75+
presets[i]['codes'] = []
76+
presets[i]['event_ids'] = []
77+
for ii in range(len(presets[i]['hotkeys'])):
78+
79+
keys = presets[i]['hotkeys'][ii].split('+')
80+
mods = [v for v in modifiers if v in keys]
81+
base = [v for v in keys if v and v not in modifiers]
82+
presets[i]['hotkeys'][ii] = '+'.join(mods + base)
83+
84+
keys = presets[i]['hotkeys'][ii].split('+')
85+
codes = [KEYMAP.get(key) for key in keys]
86+
if None in codes:
87+
presets.pop(i)
88+
continue
89+
90+
codes = [v for v in codes if v is not None]
91+
92+
presets[i]['codes'] += [(operate_or(codes[:-1]), codes[-1],)]
93+
m = hashlib.new('md5')
94+
m.update(''.join([str(v) for v in presets[i]['codes'][ii]]).encode('utf-8'))
95+
presets[i]['event_ids'] += [int(m.hexdigest()[:5], 16)]
8396

8497
return presets
8598

0 commit comments

Comments
 (0)