Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Send a keystroke to a hwnd window
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00889676
Message ID:
00889798
Views:
23
This message has been marked as the solution to the initial question of the thread.
>I played with keyb_event for a while and everytime I used it, all of my keys started producing unexpected results until I reboot. For instance, after this:
>
>ReturnValue = PostMessage(hwnd, WM_KEYDOWN, wParam, 0)
>ReturnValue = Keybd_Event(97,0,0,0)
>ReturnValue = Keybd_Event(97,0,2,0)
>
>No matter what I sent as the first parameter, whenever I returned after testing it, click and dblclick and pressing ENTER has strange results. If I double-click on any icon, it brings up its properties, etc. Very strange so I am leaving that one alone for awhile.
>
>Anyway, the below is the ONLY thing that works so far and it works well. The only problem is that I am not supposed to use the windows script at all and I need to stick with pure API so I will have to find something else. I will post it though for lurkers since it works so well. Someone else may need it one day.

Tracy,

You don't need PostMessage in the above. I'll play around with it tomorrow.

I've made a modification or two to the code below
*--App has already been launched using CREATEPROCESS and now it is in
*--a loop using GETEXITCODEPROCESS() waiting for it to close but the
*--password box pops up first and a password must be entered without
*--the user's input at all behind the scenes so the app will run.
*--So far this has always worked the first time
IF lnclosepass < 3 .and. PassWin('Password')
   = Sleep (3000)
   lnclosepass = lnclosepass + 1
ENDIF

FUNCTION PassWin
 LPARAMETER tcTitle

DECLARE INTEGER FindWindow IN Win32API AS FindWindow STRING, STRING
lnwindow = FindWindow(0,tcTitle)

IF lnwindow > 0
 DECLARE INTEGER SetActiveWindow IN Win32API;
   INTEGER hWnd
   = SetActiveWindow(lnwindow)
   oShell = Createobject("wscript.shell")
   oShell.Sendkeys("~Pawwword~")
   oShell = NULL
   RELEASE oshell
   RETURN .T.
ELSE
   RETURN .F.
ENDIF
BTW, I assume you meant "Password".< bg >
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform