setFocus

In this category you can exchange your programming questions and solutions.
Post Reply
cvirus
Posts: 88
Joined: Tue Jan 12, 2010 8:33 pm

setFocus

Post: # 946Post cvirus
Wed Aug 15, 2012 5:24 pm

Hello admin, is it possible ro getfocus on the window that you bring with the run command?  This because i want to make an auto login with sendkeys in internet explorer but it aint working.

Marco
Site Admin
Posts: 246
Joined: Sat Sep 15, 2018 8:41 pm

setFocus

Post: # 947Post Marco
Wed Aug 29, 2012 3:34 pm

hi i`ve looked everwhere but can not find a good solution for it.
The only thing i can up with is the following code
I hope you can do something with it, best regards

`set focus to third party application

declare getforeground as "GetForegroundWindow" of user32
? result as integer
end declare

declare setforeground as "SetForegroundWindow" of user32
? hwnd as integer
end declare

dim ThirdPartyHWND as integer

`open or shell
open "notepad.exe"
`wait until foreground window is notepad
sleep 1000
`get windows handle of the active window(notepad)
getforeground.execute
ThirdPartyHWND=getforeground.result

`a testform to check all out it`s getting the focus
object testform as form
? object testbutton as button
? ? width=300
? ? caption="setfocus to third party app"
? ? onclick=setfoc
? end object
? showmodal
end object

sub setfoc
? ``set the focus to the earlier saved windows handle
? setforeground.hwnd=ThirdPartyHWND
? setforeground.execute
end sub

cvirus
Posts: 88
Joined: Tue Jan 12, 2010 8:33 pm

setFocus

Post: # 948Post cvirus
Thu Aug 30, 2012 1:54 pm

Thanks Admin, it works but i got to make more tests. :D

Post Reply