Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending keystrokes to window
Message
De
11/05/2006 13:26:23
 
 
À
11/05/2006 09:08:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
01120957
Message ID:
01121040
Vues:
18
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform