From ae3654501b1100b8d3b932a05311461ff1a40527 Mon Sep 17 00:00:00 2001 From: Christian Grasser Date: Fri, 15 Jan 2021 21:14:05 +0100 Subject: [PATCH] Fix issue Support for SendKeys module #183 --- PythonLib/full/_sendkeys.py | 96 +++++++++++++++++++++++++++++++ PythonLib/full_dll/_sendkeys.pyd | Bin 34304 -> 0 bytes PythonLib/min/_sendkeys.py | 96 +++++++++++++++++++++++++++++++ 3 files changed, 192 insertions(+) create mode 100644 PythonLib/full/_sendkeys.py delete mode 100644 PythonLib/full_dll/_sendkeys.pyd create mode 100644 PythonLib/min/_sendkeys.py diff --git a/PythonLib/full/_sendkeys.py b/PythonLib/full/_sendkeys.py new file mode 100644 index 00000000..1c170860 --- /dev/null +++ b/PythonLib/full/_sendkeys.py @@ -0,0 +1,96 @@ +''' + +Sendkeys module moved back to ctypes. +For x64 systems, for example. + +(c) 2009 Igor S. Mandrigin, Agnitum Ltd. + +''' + +from ctypes import windll + +# from the internet +KEYEVENTF_KEYUP = 2 +VK_NUMLOCK = 144 +KEYEVENTF_EXTENDEDKEY = 1 +KEYEVENTF_KEYUP = 2 + + +def _key_down( vk ) : + + scan = windll.user32.MapVirtualKeyA( vk, 0 ) + windll.user32.keybd_event( vk, scan, 0, 0 ) + + + +def _key_up( vk ) : + + scan = windll.user32.MapVirtualKeyA( vk, 0 ) + windll.user32.keybd_event( vk, scan, KEYEVENTF_KEYUP, 0 ) + + + + +def toggle_numlock( turn_on ) : + ''' + toggle_numlock(int) -> int + + Turns NUMLOCK on or off and returns whether + it was originally on or off. + ''' + + is_on = 0 + keys = []; + + is_on = windll.user32.GetKeyState( VK_NUMLOCK ) & 1 + + if is_on != turn_on : + windll.user32.keybd_event(VK_NUMLOCK, + 69, + KEYEVENTF_EXTENDEDKEY | 0, + 0); + windll.user32.keybd_event(VK_NUMLOCK, + 69, + KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, + 0); + + + + return is_on + + +def char2keycode( char ) : + ''' + char2keycode(char) -> int + + Converts character to virtual key code + ''' + vk = windll.user32.VkKeyScanA( ord( char ) ) + return vk + + + +def key_down( key ) : + ''' + key_down(int) -> None + + Generates a key pressed event. Takes a + virtual key code. + ''' + vk = key + # XXX exception if >= 256 + _key_down( vk ) + + + +def key_up( key ) : + ''' + key_up(int) -> None + + Generates a key released event. Takes a + virtual key code. + ''' + + vk = key + # XXX exception if >= 256 + _key_up( vk ) diff --git a/PythonLib/full_dll/_sendkeys.pyd b/PythonLib/full_dll/_sendkeys.pyd deleted file mode 100644 index db3672e7f45fb1eaaf51bfaeb9c79f947e725b3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 34304 zcmeIb3w%`7wLgB6Op*a6%m4`n0Ua^gSRT$JugPSRAej&}fq@AL5dy?y!X$(wPR{U9 z9>GayhQm~9wU>KKTQJz-qm{O(XelNH5>T{&RB1&UHR_3j5)~mxs@urTxBb?CC;Jx$~;ZorLq-T41wsTz*(2_lG}DwFmQbbKy6Q2pi6Ed5B4uV>iXZ)c}^Vu!i}= zIWCe5V-Z1@JB}cjSUxk13+J+th(c6u(3OL2jT|={vB&P?I2$GJ;kdmrDhdrfZ5$UL z#c{eaj+-zP`!(O{)z|dZQjqaY_yQ%T@s8Cz{Ga9GMf6cysq;e~Em}LxRZ+&H?vXbk zVJTn|ARiF&WTWb7ayD-J^+?zX7zwBaggn_C*EY@7;3`KPYb)9eCUM+aK**C#_*{;f zI%M1vjf6IU60jZ+@?>+|9U;Mgd;bXz>?2t@sN#+Vp83Mrxk7=;XC1IPm#*eCb33gA zoD_F{DW~xqQZ=`^6~gjzGB}aR0$Z443^V_cO7mJFSwv(tR~=Sub&`NeuOkpK7$^>*A80*? zluL}SEEdB8xIw??tSZP6YUv<`z8?_1r=c~CEYrkOa zM=R$_aYTxp997ZDr>hH%c++d-R?(bf+#J%?gD%rVqy?(ok$ zde>pRRx6#_HJnC_9|OKyRi6GZ_kH3Uqd5+J5^ZejO#{!wb|@_hi)WDF?-iHBk>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XY}3r z9=)hPtMAjF*Z1oO^qfIqP#RPQjUm<$Z~{ zLxsT!U0HA74XX`n4ULfK7Q+_9R>Q-FZHDcJ9fnHV_w#=R2mT+dR|Yl! diff --git a/PythonLib/min/_sendkeys.py b/PythonLib/min/_sendkeys.py new file mode 100644 index 00000000..1c170860 --- /dev/null +++ b/PythonLib/min/_sendkeys.py @@ -0,0 +1,96 @@ +''' + +Sendkeys module moved back to ctypes. +For x64 systems, for example. + +(c) 2009 Igor S. Mandrigin, Agnitum Ltd. + +''' + +from ctypes import windll + +# from the internet +KEYEVENTF_KEYUP = 2 +VK_NUMLOCK = 144 +KEYEVENTF_EXTENDEDKEY = 1 +KEYEVENTF_KEYUP = 2 + + +def _key_down( vk ) : + + scan = windll.user32.MapVirtualKeyA( vk, 0 ) + windll.user32.keybd_event( vk, scan, 0, 0 ) + + + +def _key_up( vk ) : + + scan = windll.user32.MapVirtualKeyA( vk, 0 ) + windll.user32.keybd_event( vk, scan, KEYEVENTF_KEYUP, 0 ) + + + + +def toggle_numlock( turn_on ) : + ''' + toggle_numlock(int) -> int + + Turns NUMLOCK on or off and returns whether + it was originally on or off. + ''' + + is_on = 0 + keys = []; + + is_on = windll.user32.GetKeyState( VK_NUMLOCK ) & 1 + + if is_on != turn_on : + windll.user32.keybd_event(VK_NUMLOCK, + 69, + KEYEVENTF_EXTENDEDKEY | 0, + 0); + windll.user32.keybd_event(VK_NUMLOCK, + 69, + KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, + 0); + + + + return is_on + + +def char2keycode( char ) : + ''' + char2keycode(char) -> int + + Converts character to virtual key code + ''' + vk = windll.user32.VkKeyScanA( ord( char ) ) + return vk + + + +def key_down( key ) : + ''' + key_down(int) -> None + + Generates a key pressed event. Takes a + virtual key code. + ''' + vk = key + # XXX exception if >= 256 + _key_down( vk ) + + + +def key_up( key ) : + ''' + key_up(int) -> None + + Generates a key released event. Takes a + virtual key code. + ''' + + vk = key + # XXX exception if >= 256 + _key_up( vk )