It is currently Sun Nov 19, 2017 7:05 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Typing special chars with keybd_event
PostPosted: Thu Sep 21, 2017 9:24 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1023
Hi dudes! :)

The following code is meant to type a copyright symbol by holding down the Alt key and typing 0169 on the numeric keypad.

But for some reason, it's not working. If I set UseAlt to 0, the 0169 definitely works and gets typed, so Alt is clearly the issue.

Any ideas on why it would be failing? Note: I don't want to use SendInput because I'm more interested in why this fails.

[Edit] Seems I'm not the only one with this problem: http://www.delphigroups.info/2/47/498662.html

Code:
Sleep_(2000)

UseAlt=1

If UseAlt=1
  keybd_event_(#VK_MENU,0,0,0)
EndIf

keybd_event_(#VK_NUMPAD0,0,0,0) : keybd_event_(#VK_NUMPAD0,0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_NUMPAD1,0,0,0) : keybd_event_(#VK_NUMPAD1,0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_NUMPAD6,0,0,0) : keybd_event_(#VK_NUMPAD6,0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_NUMPAD9,0,0,0) : keybd_event_(#VK_NUMPAD9,0,#KEYEVENTF_KEYUP,0)

If UseAlt=1
  keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0)
EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: Typing special chars with keybd_event
PostPosted: Thu Sep 21, 2017 5:43 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2842
What are you doing Dude?

Code:
RunProgram("notepad.exe") ; Start Notepad...
Repeat
  hwnd = FindWindow_(0,"Untitled - Notepad")
Until hwnd

SetForegroundWindow_(hWnd)
keybd_event_(#VK_MENU, MapVirtualKey_(#VK_MENU, 0), 0, 0);
keybd_event_(#VK_NUMPAD0, MapVirtualKey_(#VK_NUMPAD0, 0), 0, 0):keybd_event_(#VK_NUMPAD0, MapVirtualKey_(#VK_NUMPAD0, 0), #KEYEVENTF_KEYUP, 0)
keybd_event_(#VK_NUMPAD1, MapVirtualKey_(#VK_NUMPAD1, 0), 0, 0):keybd_event_(#VK_NUMPAD1, MapVirtualKey_(#VK_NUMPAD1, 0), #KEYEVENTF_KEYUP, 0);
keybd_event_(#VK_NUMPAD6, MapVirtualKey_(#VK_NUMPAD6, 0), 0, 0):keybd_event_(#VK_NUMPAD6, MapVirtualKey_(#VK_NUMPAD6, 0), #KEYEVENTF_KEYUP, 0);
keybd_event_(#VK_NUMPAD9, MapVirtualKey_(#VK_NUMPAD9, 0), 0, 0):keybd_event_(#VK_NUMPAD9, MapVirtualKey_(#VK_NUMPAD9, 0), #KEYEVENTF_KEYUP, 0);
keybd_event_(#VK_MENU, MapVirtualKey_(#VK_MENU, 0), #KEYEVENTF_KEYUP, 0)

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Typing special chars with keybd_event
PostPosted: Thu Sep 21, 2017 10:27 pm 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1023
Thanks Rashad, I didn't know MapVirtualKey_() would be needed, because without Alt the other keys are typed without problem. Appreciate your helping me. :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye