Jump to content

Application Foregound/background


jgg
 Share

Recommended Posts

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:

Link to comment
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)

Link to comment
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:

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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
Link to comment
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?

Link to comment
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?

Link to comment
Share on other sites

  • Developers

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....

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

try it this way:

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

you can also try this one:

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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....

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...