Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sending keystrokes to window
Message
From
11/05/2006 13:26:23
 
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
01120957
Message ID:
01121040
Views:
12
>The code below successfully finds the window I want it to and sets focus to it but the keyboard command does not work. The same code worked with an open Notepad instance though. I was able to sent '{CTRL-O}' to notepad which brought up the open dialog box. any ideas?
>
>
>DECLARE INTEGER FindWindow IN user32;
>        STRING lpClassName, STRING lpWindowName
>
>  hwnd = FindWindow(.NULL.,[Program Error])
>
>
>  DECLARE INTEGER SendMessage IN user32;
>    INTEGER hWnd,;
>    INTEGER Msg,;
>    INTEGER wParam,;
>    INTEGER lParam
>
> DECLARE INTEGER SetForegroundWindow IN user32 INTEGER hwnd
>
>
> if hwnd > 0
>	SetForegroundWindow(hwnd)
>	keyboard '{ALT-C}'	
> endif
>
>
>
replace the KEYBOARD statement with the WScript.Shell object's method of SEANDKEYS.
LOCAL oShell	&& as WScript.Shell
oShell = CREATEOBJECT("WScript.Shell")
oShell.SendKeys("C:\MyPath\MyFile.ext")
check the web site for key stroke used with this method at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/4b032417-ebda-4d30-88a4-2b56c24affdd.asp

This works for all windows modal dialog boxes.
Greg Reichert
Previous
Reply
Map
View

Click here to load this message in the networking platform