-
sending key presses from my program to another program
i'm trying to send to another program keys through windows api. The code is as follows:
#DEFINE KEYEVENTF_KEYUP 2
DECLARE INTEGER FindWindow IN Win32API STRING, STRING
DECLARE INTEGER SetActiveWindow IN USER32 INTEGER hWnd
DECLARE SHORT SetForegroundWindow IN USER32.DLL INTEGER hWnd
DECLARE INTEGER SetFocus IN user32 AS SetFocusAPI INTEGER hWindow
DECLARE keybd_event IN user32;
SHORT bVk,;
SHORT bScan,;
INTEGER dwFlags,;
INTEGER dwExtraInfo
DECLARE SHORT VkKeyScan IN user32 INTEGER ch
hWnd = FindWindow(0,'Any exact window name')
=SetActiveWindow(hWnd)
=SetForegroundWindow(hWnd)
SetFocusAPI(HWnd)
= keybd_event(VkKeyScan(ASC('A')), 0, 0, 0)
= keybd_event(VkKeyScan(ASC('A')), 0, KEYEVENTF_KEYUP, 0)
which works ok, but when i try to send keys like left or right arrow it doesn't work at all.
the only diference in code is the follow:
#DEFINE VK_RARROW 0x27
= keybd_event(VK_RIGHT , 0, 0, 0)
= keybd_event(VK_RIGHT , 0, KEYEVENTF_KEYUP, 0)
please help!
Thanks in advance
Regards
Xenofon
Similar Threads
-
By craver06 in forum VB Classic
Replies: 10
Last Post: 02-06-2008, 12:12 PM
-
By mannuvashishta in forum .NET
Replies: 1
Last Post: 04-06-2007, 12:47 PM
-
By Matty in forum Open Source
Replies: 0
Last Post: 12-16-2001, 11:17 AM
-
Replies: 0
Last Post: 12-15-2000, 10:07 PM
-
By Naveen in forum VB Classic
Replies: 6
Last Post: 07-03-2000, 04:45 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks