![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Any way to distinguish between Left control key versus right control key In scripts Topic Summary: using DNS and AHK at the same time – deconflicting warring scripts In the two programs Created On: 11/16/2020 06:25 AM Status: Post and Reply |
|
![]() |
![]() |
- afgban | - 11/16/2020 06:25 AM |
![]() |
![]() |
- Edgar | - 11/16/2020 10:42 AM |
![]() |
![]() |
- kkkwj | - 11/16/2020 10:43 AM |
![]() |
![]() |
- monkey8 | - 11/19/2020 09:21 AM |
![]() |
![]() |
- Edgar | - 11/19/2020 11:00 AM |
![]() |
![]() |
- monkey8 | - 11/19/2020 12:15 PM |
![]() |
![]() |
- Edgar | - 11/19/2020 02:06 PM |
![]() |
![]() |
- monkey8 | - 11/20/2020 08:11 AM |
![]() |
![]() |
- Ag | - 11/19/2020 04:14 PM |
![]() |
|
I use DNS scripting in conjunction with autohotkey due to arthritis – I created a DNS command to go to the first tab on Google Chrome – control + 1 – and it did not work and I could not figure out why until I realized that my left control key is dedicated to the mouseclick function (using AHK) – and when I disengaged AHK the DNS command worked like a charm. Obviously when the AHK program is engaged I use the right control key for control + f, control + v, but is there any way I can have DNS script distinguish between the left control key and the right control key? I’d like to use both DNS and AHK at the same time. I’m guessing probably not. Thank you for any input, even if it’s “you can’t do it”
|
|
|
|
![]() |
|
It is possible but requires a bit of heavy coding. VK_LCONTROL (Left Ctrl key) VK_CTRL (either Ctrl key) VK_RCONTROL (Right Ctrl key) off the top my head, I don't know what the exact mathematical values for VK_LCONTROL and VK_RCONTROL are. here is an example: Const VK_LWIN = &h5B Const VK_CTRL = &h11 Const VK_SHIFT = &h10 Const VK_ALT = &h12 Const VK_SPACE = &h20 Command name = "<keyname> Release" ' Script Lindsay Adam 2010 www.pcbyvoice.com Sub Main If ListVar1 = "WINDOWS Key" Then keybd_event(VK_LWIN,0, 2,0) If ListVar1 = "CONTROL Key" Then keybd_event(VK_CTRL,0, 2,0) If ListVar1 = "SHIFT Key" Then keybd_event(VK_SHIFT,0, 2,0) If ListVar1 = "ALT Key" Then keybd_event(VK_ALT,0, 2,0) If ListVar1 = "SPACE Key" Then keybd_event(VK_SPACE,0, 2,0) End Sub Command name = "<keyname> Hold Down" ' Script Lindsay Adam 2010 www.pcbyvoice.com Sub Main If ListVar1 = "WINDOWS Key" Then keybd_event(VK_LWIN,0,0,0) If ListVar1 = "CONTROL Key" Then keybd_event(VK_CTRL,0,0,0) If ListVar1 = "SHIFT Key" Then keybd_event(VK_SHIFT,0,0,0) If ListVar1 = "ALT Key" Then keybd_event(VK_ALT,0,0,0) If ListVar1 = "SPACE Key" Then keybd_event(VK_SPACE,0,0,0) End Sub ------------------------- -Edgar |
|
|
|
![]() |
|
The left and right keys definitely have different keycodes in the operating system. I could be wrong, but I don't think the old DNS Sax Basic could get that low in its scripting code. The good news is that the new WinWrap Basic in DPI version 15.6 can get that low and will be able to use the low-level keycodes when it arrives. KB can already do this, of course.
------------------------- Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.61, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse |
|
|
|
![]() |
|
The old advanced scripting with for example 15.3 (SAX Basic) IS able to carryout this functionality no problem. You will find the different keycodes for the left and right control key in the link below. Left Control &hA2, Right Control &hA3, use them with keybd_event in SAX or WinWrap Basic.
https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes100P
So for example a "Control F" using the left control key would be as follows:
'www.pcbyvoice.com declare keybd_event Declare Function keybd_event Lib "user32.dll" (ByVal vKey As _ Long, bScan As Long, ByVal Flag As Long, ByVal exInfo As Long) As Long 'declare constant for the left control key Const VK_LCTRL = &hA2 Sub Main 'Hold down the left control key keybd_event(VK_LCTRL,0,0,0) Wait 0.1 SendKeys"f" Wait 0.1 'Release the left control key keybd_event(VK_LCTRL,0,2,0) End Sub
------------------------- |
|
|
|
![]() |
|
That site lists the codes in hex (hexadecimal): VK_LBUTTON 0x01 Left mouse button Basic seems to want some other numeric format: Const VK_LBUTTON = 0x01' this fails ------------------------- -Edgar |
|
|
|
![]() |
|
|
|
![]() |
|
' Constants for mouse_event Const MOUSEEVENTF_LEFTDOWN = &H2 Const MOUSEEVENTF_LEFTUP = &H4 Const MOUSEEVENTF_MIDDLEDOWN = &H20 Const MOUSEEVENTF_MIDDLEUP = &H40 Const MOUSEEVENTF_RIGHTDOWN = &H8 Const MOUSEEVENTF_RIGHTUP = &H10 ' declare virtual key constants ' from Microsoft Windows Visual Studio header Winuser.h Const VK_LBUTTON = &h01 ' Left mouse button Const VK_RBUTTON = &h02 ' Right mouse button Const VK_CANCEL = &h03 ' Control-break processing Const VK_MBUTTON = &h04 ' Middle mouse button (three-button mouse) Const VK_XBUTTON1 = &h05 ' X1 mouse button Const VK_XBUTTON2 = &h06 ' X2 mouse button ' &h07 Undefined Const VK_BACK = &h08 ' BACKSPACE key Const VK_TAB = &h09 ' TAB key ' &h0A-0B Reserved Const VK_CLEAR = &h0C ' CLEAR key Const VK_RETURN = &h0D ' ENTER key ' &h0E-0F Undefined Const VK_SHIFT = &h10 ' SHIFT key Const VK_CONTROL = &h11 ' CTRL key Const VK_MENU = &h12 ' ALT key Const VK_PAUSE = &h13 ' PAUSE key Const VK_CAPITAL = &h14 ' CAPS LOCK key Const VK_KANA = &h15 ' IME Kana mode Const VK_HANGUEL = &h15 ' IME Hanguel mode ' (maintained for compatibility; use VK_HANGUL) Const VK_HANGUL = &h15 ' IME Hangul mode Const VK_IME_ON = &h16 ' IME On Const VK_JUNJA = &h17 ' IME Junja mode Const VK_FINAL = &h18 ' IME final mode Const VK_HANJA = &h19 ' IME Hanja mode Const VK_KANJI = &h19 ' IME Kanji mode Const VK_IME_OFF = &h1A ' IME Off Const VK_ESCAPE = &h1B ' ESC key Const VK_CONVERT = &h1C ' IME convert Const VK_NONCONVERT = &h1D ' IME nonconvert Const VK_ACCEPT = &h1E ' IME accept Const VK_MODECHANGE = &h1F ' IME mode change request Const VK_SPACE = &h20 ' SPACEBAR Const VK_PRIOR = &h21 ' PAGE UP key Const VK_NEXT = &h22 ' PAGE DOWN key Const VK_END = &h23 ' END key Const VK_HOME = &h24 ' HOME key Const VK_LEFT = &h25 ' LEFT ARROW key Const VK_UP = &h26 ' UP ARROW key Const VK_RIGHT = &h27 ' RIGHT ARROW key Const VK_DOWN = &h28 ' DOWN ARROW key Const VK_SELECT = &h29 ' SELECT key Const VK_PRINT = &h2A ' PRINT key Const VK_EXECUTE = &h2B ' EXECUTE key Const VK_SNAPSHOT = &h2C ' PRINT SCREEN key Const VK_INSERT = &h2D ' INS key Const VK_DELETE = &h2E ' DEL key Const VK_HELP = &h2F ' HELP key ' no constants defined for the non-numberPad number keys ' &h30 ' 0 key ' &h31 ' 1 key ' &h32 ' 2 key ' &h33 ' 3 key ' &h34 ' 4 key ' &h35 ' 5 key ' &h36 ' 6 key ' &h37 ' 7 key ' &h38 ' 8 key ' &h39 ' 9 key 'efm5 proposed constants: Const VK_0 = &h30 ' 0 key Const VK_1 = &h31 ' 1 key Const VK_2 = &h32 ' 2 key Const VK_3 = &h33 ' 3 key Const VK_4 = &h34 ' 4 key Const VK_5 = &h35 ' 5 key Const VK_6 = &h36 ' 6 key Const VK_7 = &h37 ' 7 key Const VK_8 = &h38 ' 8 key Const VK_9 = &h39 ' 9 key Const VK_LWIN = &h5B ' Left Windows key (Natural keyboard) Const VK_RWIN = &h5C ' Right Windows key (Natural keyboard) Const VK_APPS = &h5D ' Applications key (Natural keyboard) ' &h5E Reserved Const VK_SLEEP = &h5F ' Computer Sleep key Const VK_NUMPAD0 = &h60 ' Numeric keypad 0 key Const VK_NUMPAD1 = &h61 ' Numeric keypad 1 key Const VK_NUMPAD2 = &h62 ' Numeric keypad 2 key Const VK_NUMPAD3 = &h63 ' Numeric keypad 3 key Const VK_NUMPAD4 = &h64 ' Numeric keypad 4 key Const VK_NUMPAD5 = &h65 ' Numeric keypad 5 key Const VK_NUMPAD6 = &h66 ' Numeric keypad 6 key Const VK_NUMPAD7 = &h67 ' Numeric keypad 7 key Const VK_NUMPAD8 = &h68 ' Numeric keypad 8 key Const VK_NUMPAD9 = &h69 ' Numeric keypad 9 key Const VK_MULTIPLY = &h6A ' Multiply key Const VK_ADD = &h6B ' Add key Const VK_SEPARATOR = &h6C ' Separator key Const VK_SUBTRACT = &h6D ' Subtract key Const VK_DECIMAL = &h6E ' Decimal key Const VK_DIVIDE = &h6F ' Divide key Const VK_F1 = &h70 ' F1 key Const VK_F2 = &h71 ' F2 key Const VK_F3 = &h72 ' F3 key Const VK_F4 = &h73 ' F4 key Const VK_F5 = &h74 ' F5 key Const VK_F6 = &h75 ' F6 key Const VK_F7 = &h76 ' F7 key Const VK_F8 = &h77 ' F8 key Const VK_F9 = &h78 ' F9 key Const VK_F10 = &h79 ' F10 key Const VK_F11 = &h7A ' F11 key Const VK_F12 = &h7B ' F12 key Const VK_F13 = &h7C ' F13 key Const VK_F14 = &h7D ' F14 key Const VK_F15 = &h7E ' F15 key Const VK_F16 = &h7F ' F16 key Const VK_F17 = &h80 ' F17 key Const VK_F18 = &h81 ' F18 key Const VK_F19 = &h82 ' F19 key Const VK_F20 = &h83 ' F20 key Const VK_F21 = &h84 ' F21 key Const VK_F22 = &h85 ' F22 key Const VK_F23 = &h86 ' F23 key Const VK_F24 = &h87 ' F24 key ' &h88-8F Unassigned Const VK_NUMLOCK = &h90 ' NUM LOCK key Const VK_SCROLL = &h91 ' SCROLL LOCK key ' &h92-96 OEM specific ' &h97-9F Unassigned Const VK_LSHIFT = &hA0 ' Left SHIFT key Const VK_RSHIFT = &hA1 ' Right SHIFT key Const VK_LCONTROL = &hA2 ' Left CONTROL key Const VK_RCONTROL = &hA3 ' Right CONTROL key Const VK_LMENU = &hA4 ' Left MENU key Const VK_RMENU = &hA5 ' Right MENU key Const VK_BROWSER_BACK = &hA6 ' Browser Back key Const VK_BROWSER_FORWARD = &hA7 ' Browser Forward key Const VK_BROWSER_REFRESH = &hA8 ' Browser Refresh key Const VK_BROWSER_STOP = &hA9 ' Browser Stop key Const VK_BROWSER_SEARCH = &hAA ' Browser Search key Const VK_BROWSER_FAVORITES = &hAB ' Browser Favorites key Const VK_BROWSER_HOME = &hAC ' Browser Start and Home key Const VK_VOLUME_MUTE = &hAD ' Volume Mute key Const VK_VOLUME_DOWN = &hAE ' Volume Down key Const VK_VOLUME_UP = &hAF ' Volume Up key Const VK_MEDIA_NEXT_TRACK = &hB0 ' Next Track key Const VK_MEDIA_PREV_TRACK = &hB1 ' Previous Track key Const VK_MEDIA_STOP = &hB2 ' Stop Media key Const VK_MEDIA_PLAY_PAUSE = &hB3 ' Play/Pause Media key Const VK_LAUNCH_MAIL = &hB4 ' Start Mail key Const VK_LAUNCH_MEDIA_SELECT = &hB5 ' Select Media key Const VK_LAUNCH_APP1 = &hB6 ' Start Application 1 key Const VK_LAUNCH_APP2 = &hB7 ' Start Application 2 key ' &hB8-B9 Reserved Const VK_OEM_1 = &hBA ' Used for miscellaneous characters; it can vary by keyboard. ' For the US standard keyboard, the ';:' key Const VK_OEM_PLUS = &hBB ' For any country/region, the '+' key Const VK_OEM_COMMA = &hBC ' For any country/region, the ',' key Const VK_OEM_MINUS = &hBD ' For any country/region, the '-' key Const VK_OEM_PERIOD = &hBE ' For any country/region, the '.' key Const VK_OEM_2 = &hBF ' Used for miscellaneous characters; it can vary by keyboard. ' For the US standard keyboard, the '/?' key Const VK_OEM_3 = &hC0 ' Used for miscellaneous characters; it can vary by keyboard. ' For the US standard keyboard, the '`~' key ' &hC1-D7 Reserved ' &hD8-DA Unassigned Const VK_OEM_4 = &hDB ' Used for miscellaneous characters; it can vary by keyboard. ' For the US standard keyboard, the '[{' key Const VK_OEM_5 = &hDC ' Used for miscellaneous characters; it can vary by keyboard. ' For the US standard keyboard, the '\|' key Const VK_OEM_6 = &hDD ' Used for miscellaneous characters; it can vary by keyboard. ' For the US standard keyboard, the ']}' key Const VK_OEM_7 = &hDE ' Used for miscellaneous characters; it can vary by keyboard. ' For the US standard keyboard, the 'single-quote/double-quote' key Const VK_OEM_8 = &hDF ' Used for miscellaneous characters; it can vary by keyboard. ' &hE0 Reserved ' &hE1 OEM specific Const VK_OEM_102 = &hE2 ' Either the angle bracket key or the backslash key on the RT 102-key keyboard ' &hE3-E4 OEM specific Const VK_PROCESSKEY = &hE5 ' IME PROCESS key ' &hE6 OEM specific Const VK_PACKET = &hE7 ' Used to pass Unicode characters as if they were keystrokes. ' The VK_PACKET key is the low word of a 32-bit Virtual Key value used ' for non-keyboard input methods. For more information, ' see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP ' &hE8 Unassigned ' &hE9-F5 OEM specific Const VK_ATTN = &hF6 ' Attn key Const VK_CRSEL = &hF7 ' CrSel key Const VK_EXSEL = &hF8 ' ExSel key Const VK_EREOF = &hF9 ' Erase EOF key Const VK_PLAY = &hFA ' Play key Const VK_ZOOM = &hFB ' Zoom key Const VK_NONAME = &hFC ' Reserved Const VK_PA1 = &hFD ' PA1 key Const VK_OEM_CLEAR = &hFE ' OEM clear key ------------------------- -Edgar |
|
|
|
![]() |
|
Very useful Edgar for adding to the extensions file for WinWrap basic scripting. I have a similar thing with C# where I have a static class containing all the Windows API function and constant definitions.
You can get the info for implementing any Windows API function in C# from Pinvoke on Google.
AG, I noticed your comments on the knowbrainer part of the forum regarding using AHK because of the time taken by the KnowBrainer editor to add global commands and edit global commands. We should have an update coming shortly to help with this. Currently just testing. ------------------------- |
|
|
|
![]() |
|
I started off with a number of Dragon/KnowBrainer scripts using keybd_event to get up/down left/right control.
but switching to having my KnowBrainer/Dragon scripts call AHK has given me the full control of AHK, with its more compact syntax plus I get to use commands in multiple places, both via speech and via keyboard and mouse/trackball shortcuts. ------------------------- DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design. |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.