Sign in to follow this  
Followers 0
jgg

Application Foregound/background

16 posts in this topic

I have an application which i start via a script made in autoit. The application needs a password to start, and i have made a script which send the password+enter, then access the application. Sometimes antivirus software pop-up dialog-windows and the application lost focus, the script can't log in to the application.

Is there any way to get focus fo the application if ex.notepad is on top?

I have tried winsetontop, controlfocus, controlenable but neither one seems to work. Only when i switch to the application the script get focus, writes the password and logs in to the application.

Thanks....

:whistle:

Share this post


Link to post
Share on other sites



See WinActivate.

Also, you may want to look into sending the text directly to controls rather than using Send to the window. See ControlSend for more information. (Sending directly to the control doesn't require the window be on top, either)

Share this post


Link to post
Share on other sites

I have tried with control send,doens't work.

Here is the box for AutoWindowSpy:

>>>>>>>>>>>>( Window Title )<<<<<<<<<<<<<

Ange lösen

( classname=#32770 )

>>>>>>>>>>>( Mouse Position )<<<<<<<<<<<<

On Desktop: x: 1059 y: 271

In Window: x: 892 y: -11

>>>>>>>>>>>>>( Pixel Color Under Mouse)<<<<<<<<<<<<<

Dec: 14653050 Hex: 0xDF967A

>>>>>>>>>>>( Window Position )<<<<<<<<<<<

left: 167 top: 282 width: 221 height: 74

>>>>>>>>( Last Control Under Mouse )<<<<<<<

>>>>>>>>>( Status Bar Text )<<<<<<<<

>>>>>>>>>>>( Visible Window Text )<<<<<<<<<

OK

>>>>>>>>>>( Hidden Window Text )<<<<<<<<<

How do i write the correct autoit-code?

So here looks the code now:

ControlSend ( "Ange lösen", "", "classname#32770", "losen{ENTER}" )

:whistle:

Share this post


Link to post
Share on other sites

No replies means this isn't possible to do with autoit, or??

Share this post


Link to post
Share on other sites

Move the mouse over the part you typr in and look under the section:

>>>>>>>>( Last Control Under Mouse )<<<<<<<

in AutoIt window spy.

You can try:

WinSetOnTop ( "Ange lösen", "", 1)
winactivate("Ange lösen")
; send("pass{enter}")

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Did you use Winactivate("Ange lösen") before your send command ??

No need if you use ControlSend.

I hope your problem does come from a missing = or you forget to set Opt("WinTitleMatchMode",4)

ControlSend ( "Ange lösen", "", "classname=#32770", "losen{ENTER}" )

Edited by jpm

Share this post


Link to post
Share on other sites

That can't be the correct classname for the Control. #32770 is the class name of a dialog box.

Share this post


Link to post
Share on other sites

Under "Last Control Under Mouse" when i stand in the password-box i got:

>>>>>>>>>>>>( Window Title )<<<<<<<<<<<<<

Ange lösen

( classname=#32770 )

>>>>>>>>>>>( Mouse Position )<<<<<<<<<<<<

On Desktop: x: 237 y: 356

In Window: x: 48 y: 45

>>>>>>>>>>>>>( Pixel Color Under Mouse)<<<<<<<<<<<<<

Dec: 16777215 Hex: 0xFFFFFF

>>>>>>>>>>>( Window Position )<<<<<<<<<<<

left: 189 top: 311 width: 221 height: 74

>>>>>>>>( Last Control Under Mouse )<<<<<<<

Class: Edit1 Text:

>>>>>>>>>( Status Bar Text )<<<<<<<<

>>>>>>>>>>>( Visible Window Text )<<<<<<<<<

OK

>>>>>>>>>>( Hidden Window Text )<<<<<<<<<

How will i write the script to function when i found Last Control Under Mouse?

Share this post


Link to post
Share on other sites

It works....

ALMOST -

the script writes in the password, but don't send enter.

I = 1

While $I < 2

Opt("WinTitleMatchMode",4)

ControlSend ( "Ange lösen", "", "Edit1", "losen{ENTER}" )

Sleep ( 6000 )

Wend

Anyone seeing what's wrong?

Share this post


Link to post
Share on other sites

you probably have a button that can be clicked to enter the password ??

Check with AutoIt-Spy the name of that control as well and send the {ENTER} to that name....


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Yes, it:s

>>>>>>>>( Last Control Under Mouse )<<<<<<<

Class: Button1 Text: OK

How does i have to write the script?

Share this post


Link to post
Share on other sites

try it this way:

ControlSend ( "Ange lösen", "", "Edit1", "losen" )
ControlSend ( "Ange lösen", "", "Button1", "{ENTER}" )

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks, but it didn't work.....

Share this post


Link to post
Share on other sites

you can also try this one:

ControlSend ( "Ange lösen", "", "Edit1", "losen" )
ControlClick("Ange lösen", "", "Button1")

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Now it works. GREEAAAT, fantastic. I don't know why it didn't work at first, i compiled the script with enter at the ok-box and then it worked.

Now i know that the script will log in to the application EVEN if antivirus-program with pop-ups is doing that the application lost focus.

Thanks....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0