Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修飾キーの入力発行順序をリリース優先に変更 #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions keyhac_keymap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
import os
import sys
import time
import profile
Expand Down Expand Up @@ -82,6 +82,25 @@ def checkModifier( mod1, mod2 ):
return True


# mod1 に mod2 が含まれていることを確認する
def hasModifier( mod1, mod2 ):

_mod1 = mod1 & 0xff
_mod2 = mod2 & 0xff
_mod1_L = (mod1 & 0xff00) >> 8
_mod2_L = (mod2 & 0xff00) >> 8
_mod1_R = (mod1 & 0xff0000) >> 16
_mod2_R = (mod2 & 0xff0000) >> 16

if _mod2 & ( _mod1 | _mod1_L | _mod1_R ):
return True
if _mod2_L & ( _mod1 | _mod1_L ):
return True
if _mod2_R & ( _mod1 | _mod1_R ):
return True
return False


class KeyCondition:

vk_str_table = {}
Expand Down Expand Up @@ -1294,18 +1313,12 @@ def setInput_Modifier( self, mod ):
# Win と Alt の単体押しのキャンセルが必要かチェック
# Win の単体押しは スタートメニューが開き、Alt の単体押しは メニューバーにフォーカスが移動してしまう。
cancel_oneshot_win_alt = False
if ( checkModifier( self.virtual_modifier, MODKEY_ALT ) or checkModifier( self.virtual_modifier, MODKEY_WIN ) ) and mod==0:
cancel_oneshot_win_alt = True
elif self.virtual_modifier==0 and ( checkModifier( mod, MODKEY_ALT ) or checkModifier( mod, MODKEY_WIN ) ):
if any((
checkModifier( self.virtual_modifier, MODKEY_ALT ) and not hasModifier( mod, MODKEY_ALT),
checkModifier( self.virtual_modifier, MODKEY_WIN ) and not hasModifier( mod, MODKEY_WIN ),
)):
cancel_oneshot_win_alt = True

# モディファイア押す
for vk_mod in self.vk_mod_map.items():
if vk_mod[1] & MODKEY_USER_ALL : continue
if not ( vk_mod[1] & self.virtual_modifier ) and ( vk_mod[1] & mod ):
self.input_seq.append( pyauto.KeyDown(vk_mod[0]) )
self.virtual_modifier |= vk_mod[1]

# Win と Alt の単体押しをキャンセル
if cancel_oneshot_win_alt:
self.input_seq.append( pyauto.Key( VK_LCONTROL ) )
Expand All @@ -1317,6 +1330,13 @@ def setInput_Modifier( self, mod ):
self.input_seq.append( pyauto.KeyUp(vk_mod[0]) )
self.virtual_modifier &= ~vk_mod[1]

# モディファイア押す
for vk_mod in self.vk_mod_map.items():
if vk_mod[1] & MODKEY_USER_ALL : continue
if not ( vk_mod[1] & self.virtual_modifier ) and ( vk_mod[1] & mod ):
self.input_seq.append( pyauto.KeyDown(vk_mod[0]) )
self.virtual_modifier |= vk_mod[1]

def setInput_FromString( self, s ):

s = s.upper()
Expand Down