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:
00889951
Views:
26
Update, I realize I cannot use "{~}" but "~password" should work as long as the password is all caps. It works when I change the password to all caps but I really don't want to do that and I don't want to lose the ~ character in it....

Ok, this works, HOWEVER, I keep receiving the password is incorrect so what I am sending is not actually being sent like I think it is. I can see the keystrokes being entered but they are masked so I cannot verify it. I need to send a tilda ~ before the text and I've tried:

lcsentence = "{~}"+"password"
lcsentence = "~password"

assuming the clear text of the password is 'password.' Is there a special way to send a tilda?
lnwindow = FindWindow(0,tcTitle)

IF lnwindow > 0
	#DEFINE WM_SETFOCUS 0x0007
	#DEFINE KEYEVENTF_KEYUP      2
	#DEFINE VK_SHIFT          0x10

	DECLARE SHORT PostMessage IN user32;
		INTEGER   HWND,;
		INTEGER   Msg,;
		STRING   wParam,;
		INTEGER   LPARAM
	DECLARE INTEGER SetForegroundWindow IN Win32API;
		INTEGER HWND
	DECLARE INTEGER SetActiveWindow IN Win32API;
		INTEGER HWND
	DECLARE keybd_event IN Win32API;
		INTEGER bVk, INTEGER bScan,;
		INTEGER dwFlags, INTEGER dwExtraInfo

	HWND = lnwindow
	ReturnValue = PostMessage(HWND, WM_SETFOCUS, 0, 0)

	lcsentence = "{~}"+"password"+CHR(13)
	= SetActiveWindow(HWND)
	= SetForegroundWindow(HWND)
	FOR lni = 1 TO LEN(lcsentence)
		lcchar = SUBSTR(lcsentence, lni, 1)
		llshift = ISUPPER(lcchar)
		lnchar = ASC(UPPER(lcchar))
		IF llshift
			= keybd_event(VK_SHIFT, 0, 0, 0)
		ENDIF
		= keybd_event(lnchar, 0, 0, 0)
		= keybd_event(lnchar, 0, KEYEVENTF_KEYUP, 0)
		IF llshift
			= keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0)
		ENDIF
	NEXT
	RETURN .T.
ELSE
	RETURN .F.
ENDIF
.·*´¨)
.·`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"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform