What is funny is that I can see the focus on the textbox in the password window (the cursor flashes hundreds of times in it so the setfocus is at least working) by testing the below:
DO WHILE Checkwin('Password')
WAIT WINDOW "Cursor is flashing in textbox of password window" NOWAIT
ENDDO
RETURN
FUNCTION CheckWin
PARAMETER tcTitle
DECLARE INTEGER FindWindow IN Win32API AS FindWindow STRING, STRING
lnwindow = FindWindow(0,tcTitle)
IF lnwindow > 0
#DEFINE WM_KEYDOWN 0x0100
#DEFINE WM_SYSCOMMAND 0x0112
#DEFINE WM_COMMAND 0x00110818
#DEFINE WM_KEYUP 0x0101
#DEFINE WM_SETFOCUS 0x0007
DECLARE SHORT PostMessage IN user32;
INTEGER hWnd,;
INTEGER Msg,;
STRING @wParam,;
INTEGER lParam
hwnd = lnwindow
cmessage = 'password'+CHR(13)+CHR(0)
ReturnValue = PostMessage(hwnd,WM_SETFOCUS,0,0)
ReturnValue = PostMessage(hwnd,WM_KEYDOWN, @cmessage,0)
ReturnValue = PostMessage(hwnd,WM_KEYUP, @cmessage,0)
RETURN .T.
ELSE
RETURN .F.
ENDIF
hello Tracy,
>
>maybe i am way off here but there are two things i am thinking of right now:
>
>1. i you send keystrokes, make sure there is an object on the 'password' window that knows what to do with it. if u whant to fill a text box, make sure the textbox has the focus when the window receives the message. if u need to send some data to some of your code in the window, you need to register a new message with windows, and then catch it manually.
>
>2. if you have a textbox (not an editbox), i don't think you should send a chr(13) after the string, because then you're sending a two-liner, and the text box will show you the 2nd line (which is empty).
>
>hope i am not too far off :-)
>
>
>
>>Well the below should work, but nothing gets put in the password window.
>>
>>
>>DO WHILE CheckWin('Password')
>> *--This will display until I close the password window as it should
>> WAIT WINDOW "Found the password window" NOWAIT
>>ENDDO
>>RETURN
>>
>>FUNCTION CheckWin
>>PARAMETER tcTitle
>>
>>lnwindow = FindWindow(0,tcTitle)
>>IF lnwindow > 0
>> #DEFINE WM_KEYDOWN 0x0100
>> DECLARE SHORT SendMessage IN user32;
>> INTEGER hWnd,;
>> INTEGER Msg,;
>> STRING @ wParam,;
>> INTEGER lParam
>>
>> hwnd = lnwindow
>> cmessage = 'password'+CHR(13)
>> ReturnValue = SendMessage(hwnd, WM_KEYDOWN, @cmessage, 0)
>> RETURN .T.
>>ELSE
>> RETURN .F.
>>ENDIF
>>
>>
>>Yet if I run that loop the wait window displays nonstop (as it should) until I close the password window. Once I do that, it exits the loop because lnwindow returns false. So everything is working EXCEPT sending the keystrokes to taht password window... Sheesh, you'd think it was Friday! :o()
.·*´¨)
.·`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"