Article View: borland.public.cppbuilder.nativeapi
Article #10956Re: Send key press to another app-window.
From: Graham Reeds
Date: Mon, 08 Mar 2004 14:13
Date: Mon, 08 Mar 2004 14:13
43 lines
2306 bytes
2306 bytes
> I want a function to find another app-window exist(if the app is opened on
> desktop).
To find if a windows is active the easiest is to use FindWindowEx();
The format is pretty simple:
// find the "Connection Parameters" window
hWndMain = ::FindWindowEx(NULL, NULL, NULL , "Connection Parameters");
// now find the "Connect" button widget in the "Connection Parameters"
window.
hWndButton = ::FindWindowEx(hWndMain, NULL, NULL , "Connect");
// and to press the button (simulate mouse click)
::PostMessage(hWndMain, WM_COMMAND, MAKEWPARAM(iCtrlId, BN_CLICKED),
(LPARAM)GetDlgItem(hWndMain, iCtrlId));
> then user click some item in my app-window, will changing focus to another
> app-window, and send a key press string to the app-window.
Well that is something I am stuck on also. I need to send CTRL+R to the
window.
To set the focus you call:
::SetFocus(hWndMain);
I have the hWnd but I can't get the key presses to work. This is my code:
// make the PCView window the focus
::SetFocus(hWndPcView);
// send CTRL+R to start recording
::PostMessage(hWndPcView, WM_KEYDOWN, VK_CONTROL, 0x10FF);
::PostMessage(hWndPcView, WM_KEYDOWN, VkKeyScan('R'), 0);
::PostMessage(hWndPcView, WM_KEYUP, VkKeyScan('R'), 0);
::PostMessage(hWndPcView, WM_KEYUP, VK_CONTROL, 0x10FF);
Any ideas?
--
Graham Reeds,
grahamr@omnieng.co.uk | http://omnieng.co.uk
Technical Details
Message-ID:
<404c7f89$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40448e03@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,bc09f599c90f85b4 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-08 06:40:22 PST From: "Graham Reeds" <grahamr@omnieng.co.uk> Newsgroups: borland.public.cppbuilder.nativeapi References: <40448e03@newsgroups.borland.com> Subject: Re: Send key press to another app-window. Date: Mon, 8 Mar 2004 14:13:49 -0000 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 193.82.59.1 Message-ID: <404c7f89$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1078755209 193.82.59.1 (8 Mar 2004 06:13:29 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail