xYuri Posted November 27, 2019 Posted November 27, 2019 (edited) This simple dllcall gives me error 5, access denied, Func _WinAPI_VkKeyScan($__key) _WinAPI_SetLastError(0) $res = DllCall('User32.dll', 'SHORT', 'VkKeyScan', 'CHAR', $__key) _xConsole('res: '&$res) $_LastErr = _WinAPI_GetLastError() If $_LastErr <> 0 Then _xConsole('Err: {' & $_LastErr & '}> ' & _WinAPI_GetLastErrorMessage()) Return $res EndFunc Am i doing something wrong? Also tried VkKeyScanA and W Edit: I want to send `:` via PostMessage() WM_KEYDOWN Edited November 27, 2019 by xYuri Missing Info
KaFu Posted November 27, 2019 Posted November 27, 2019 (edited) Edited November 27, 2019 by KaFu xYuri 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
xYuri Posted November 27, 2019 Author Posted November 27, 2019 @KaFu Thank you very much for your answer, Sorry that i forgot to include this in my question, But it still not doing what i really wanted, in first place i used `VkKeyScan` to get the shift+ code for `;` which makes it `:`, Now even after using ProgAndy's code it still send `;` , which i can get from https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes, Also `GetLastError()` still gives error code 5, which is weird cuz it give a VKCode to a key.
Nine Posted November 27, 2019 Posted November 27, 2019 dllcall returns an array. You should test @error before using winapi* error function. Provide full code not just the func. You must send message to the right control. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
xYuri Posted November 27, 2019 Author Posted November 27, 2019 (edited) @Nine Yes i am aware of that, and i am sending to the right control as it show ;;;; in notepad i think? Anyway here is the code, Func _WinAPI_VkKeyScanW($__key) _WinAPI_SetLastError(0) $res = DllCall('User32.dll', 'SHORT', 'VkKeyScanW', 'USHORT', AscW($__key)) _xConsole('res: ' & $res[0]) $_LastErr = _WinAPI_GetLastError() If @error Then _xConsole('Err: {' & @error & '}> ' & _WinAPI_GetLastErrorMessage()) Return SetExtended(BitShift($res[0], 8), BitAnd($res[0], 0xFF)) EndFunc ;==>_WinAPI_VkKeyScan $h = WinGetHandle('[CLASS:Notepad]') MsgBox(0, '', $h) $C_H = ControlGetHandle($h, '', '[CLASS:Edit; INSTANCE:1]') _WinAPI_PostMessageW($C_H, $WM_KeyDown, _winapi_VkKeyScanW(':'), 2) Result: Edited November 27, 2019 by xYuri
Nine Posted November 27, 2019 Posted November 27, 2019 VkKey are not actual character. They are assign to physical key. So this is why you will always get lowercase value. One way to solve your problem is to use WM_CHAR like this : _SendMessage ($C_H, $WM_CHAR, Asc(":")) xYuri 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
xYuri Posted November 27, 2019 Author Posted November 27, 2019 @Nine Oh well, thanks very much, it worked as expected, I feel really dumb as i tried sending WM_CHAR before, but without passing it thru Asc() . Again THANKS!
Nine Posted November 27, 2019 Posted November 27, 2019 Glad you like it “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now