Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Send a keystroke to a hwnd window
Message
From
25/03/2004 12:58:22
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Send a keystroke to a hwnd window
Miscellaneous
Thread ID:
00889676
Message ID:
00889676
Views:
68
I have another app running that has a window up whose title is 'Password' so I can find it. However, how can I send a keystroke to it programmatically once I locate the window?

Look at the below code in the larger code section:
   DO WHILE CheckWin('Password')
      *--THIS WORKS BUT I NEED TO SEND KEYSTROKES TO IT SOMEHOW
      WAIT WINDOW "Found the password window" NOWAIT
   ENDDO
I can locate the window but I cannot send keystrokes to it. Is it possible?

TIA!
PROCEDURE  ExeWait (lcApp, lcCmdLine, lcdir)
IF _VFP.AutoYield = .F.
	llsetback = .T.
ELSE
	llsetback = .F.
ENDIF
 _VFP.AutoYield = .T.
#DEFINE INFINITE  0xFFFFFFFF
LOCAL lcStartupInfo, lcProcInfo, hProcess, ;
	lnPrio, lnIBelieve1
lnIBelieve1 = 1   && Don't remember what that was
lnPrio = 32 && Priority of Process=Normal
lcStartupInfo = CHR(68) + REPLI(CHR(0), 67)
lcProcInfo = REPLI(CHR(0), 16)
IF CreateProcess(0, m.lcApp+" "+m.lcCmdLine+CHR(0), 0,0,;
   m.lnIBelieve1, m.lnPrio,;
   0, 0, @lcStartupInfo, @lcProcInfo) <> 0
   * process and thread handles returned in ProcInfo structure
   hProcess = buf2dword(SUBSTR(lcProcInfo, 1,4))
   hThread = buf2dword(SUBSTR(lcProcInfo, 5,4))
   * waiting until the termination of the program
   DOEVENTS
   DO WHILE .T.
	exitcode = 0
	= GetExitCodeProcess(hProcess, @exitcode)
	IF exitcode # 259
	   EXIT	
	ELSE
	   DO WHILE CheckWin('Password')
              *--THIS WORKS BUT I NEED TO SEND KEYSTROKES TO IT SOMEHOW
	      WAIT WINDOW "Found the password window" NOWAIT
	   ENDDO
	ENDIF
	= Sleep (100)
   ENDDO
   = CloseHandle(hThread)
   = CloseHandle(hProcess)
ELSE
   IF llsetback
      _VFP.AutoYield = .F.
   ENDIF
   RETURN .F.
ENDIF
IF llsetback
    _VFP.AutoYield = .F.
ENDIF
RETURN

FUNCTION CheckWin
PARAMETER tcTitle

DECLARE INTEGER FindWindow IN Win32API AS FindWindow STRING, STRING

RETURN IIF(FindWindow(0,tcTitle)>0,.T.,.F.)
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Next
Reply
Map
View

Click here to load this message in the networking platform