Jump to content

Help with WinActivate


shaunex
 Share

Recommended Posts

Hi

having trouble with this tiny script that for the life of me can not seem to get a solution to. All it does is open an exe, get focus on it and then send the password and hit enter. This is so the I can set this as a scheduled task to auto log this program after a reboot.

CODE
run (@ProgramFilesDir & "\***.exe")

ProcessWait ("***.exe")

WinActivate("[TITLE:Login]", "[CLASS:TDBLogin")

Send ("****")

Send ("{ENTER}")

I have used a ProcessWait as I could not get a Winwait or WinActive to work the script just hung. I used Autoit Windows Info to the windows title. When the log in box is launched the screen it has focus (or appears to) and the cursor is set in the password box but nothing appears to be happening. Thanks for looking.

Link to comment
Share on other sites

Hi

having trouble with this tiny script that for the life of me can not seem to get a solution to. All it does is open an exe, get focus on it and then send the password and hit enter. This is so the I can set this as a scheduled task to auto log this program after a reboot.

CODE
run (@ProgramFilesDir & "\***.exe")

ProcessWait ("***.exe")

WinActivate("[TITLE:Login]", "[CLASS:TDBLogin")

Send ("****")

Send ("{ENTER}")

I have used a ProcessWait as I could not get a Winwait or WinActive to work the script just hung. I used Autoit Windows Info to the windows title. When the log in box is launched the screen it has focus (or appears to) and the cursor is set in the password box but nothing appears to be happening. Thanks for looking.

you're missing a closed square bracket here

"[CLASS:TDBLogin")

Does this help??

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Your conditions for matching the login window must be incorrect.

Can you show us a screen-grab (or just copy the text) of the output of the AutoIt Window Info tool (window tab)

e.g.

>>>> Window <<<<

Title: Untitled - Notepad

Class: Notepad

Position: 115, 93

Size: 1147, 687

Style: 0x14CF0000

ExStyle: 0x00000110

Handle: 0x000F0318

That way we can see exactly what you have to match up.

Edited by andybiochem
- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Your conditions for matching the login window must be incorrect.

Can you show us a screen-grab (or just copy the text) of the output of the AutoIt Window Info tool (window tab)

e.g.

>>>> Window <<<<

Title: Untitled - Notepad

Class: Notepad

Position: 115, 93

Size: 1147, 687

Style: 0x14CF0000

ExStyle: 0x00000110

Handle: 0x000F0318

That way we can see exactly what you have to match up.

Here you go:

Title: Login

Class: TDBLogin

Position: 317,256

Size: 389,255

Style: 0x96C80000

ExStyle: 0x00000101

Handle: 0x00180124

Link to comment
Share on other sites

Hmmm, nothing odd there.

So does this work?

Run(@ProgramFilesDir & "\***.exe")

WinWaitActive("Login")

Send ("****")

Send ("{ENTER}")
- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Hmmm, nothing odd there.

So does this work?

Run(@ProgramFilesDir & "\***.exe")

WinWaitActive("Login")

Send ("****")

Send ("{ENTER}")
That just hangs with the prgram paused nothing even launches on screen. This is the original way I started with but couldn't get this simple one working.
Link to comment
Share on other sites

So the login screen doesn't launch at all?

I assume you're changing ***.exe to whatever the actual file is called??? Run can't accept wildcards.

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

So the login screen doesn't launch at all?

I assume you're changing ***.exe to whatever the actual file is called??? Run can't accept wildcards.

Yes I was just blanking that out when I uploaded it for my sake. Real .exe name is in there and same with password.

Link to comment
Share on other sites

Yes I was just blanking that out when I uploaded it for my sake. Real .exe name is in there and same with password.

Thought so.

Just to be sure the problem is with launching the login exe and not with recognising the window itself, open the exe manually, and then run this script:

WinActivate("Login")
WinWaitActive("Login")

Send ("****")

Send ("{ENTER}")

On a side note - in my experience some non-standard windows can not always be recognised, especially when they exist 'within' another window. E.g. a main program opens up a smaller window. If the smaller window is created in the program's own environment then it may not be automate-able.

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Thought so.

Just to be sure the problem is with launching the login exe and not with recognising the window itself, open the exe manually, and then run this script:

WinActivate("Login")
WinWaitActive("Login")

Send ("****")

Send ("{ENTER}")

On a side note - in my experience some non-standard windows can not always be recognised, especially when they exist 'within' another window. E.g. a main program opens up a smaller window. If the smaller window is created in the program's own environment then it may not be automate-able.

This is my thought as well as within the login box are two tab fields and this maybe causing it fail to lock on to it. I will try this script.
Link to comment
Share on other sites

This is my thought as well as within the login box are two tab fields and this maybe causing it fail to lock on to it. I will try this script.

Ok I have run the script by manually openning the exe and then running it. It hangs until I manually get focus then puts the 1st 3 characters of the password and locks the machine but I suspect that this is because I am using terminal services to connect to it.

I am also now going to try using a mouse position command to place the focus correctly.

Link to comment
Share on other sites

Hmm.

This sounds far more complicated than a simple window-focus > send data script.

Without seeing the whole process in action, or knowing which program it is, I'm not sure I can be of much help.

PM me if you want.

Maybe someone better than me can help???

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Hmm.

This sounds far more complicated than a simple window-focus > send data script.

Without seeing the whole process in action, or knowing which program it is, I'm not sure I can be of much help.

PM me if you want.

Maybe someone better than me can help???

Thanks for the help anyway it has been me a better view to chat to others reagrding this. Where I am now

CODE
MouseMove (500, 455)

run (@ProgramFilesDir & "\****.exe")

MouseClick ( "left" )

Send ("****")

Send ("{ENTER}")

This moves the mouse to the correct location but it is clicking before the program runs. I have tried a sleep after the run command but then it doesn't launch the program until it has finished the pause. I have also tried a winwaitactive but that just pauses the program and the exe doesn't launch.

For such a simple thing it is causing me a real headache.

Link to comment
Share on other sites

Thanks for the help anyway it has been me a better view to chat to others reagrding this. Where I am now

CODE
MouseMove (500, 455)

run (@ProgramFilesDir & "\****.exe")

MouseClick ( "left" )

Send ("****")

Send ("{ENTER}")

This moves the mouse to the correct location but it is clicking before the program runs. I have tried a sleep after the run command but then it doesn't launch the program until it has finished the pause. I have also tried a winwaitactive but that just pauses the program and the exe doesn't launch.

For such a simple thing it is causing me a real headache.

Hmm.. You can throw a sleep in between your run and mouseclick, since your winwait's don't seem to be working?

Link to comment
Share on other sites

Hmm.. You can throw a sleep in between your run and mouseclick, since your winwait's don't seem to be working?

Yes I tried this already and the spalsh screen of the exe doesn't come up until after the sleep has run so that is no good. I have also tried a script that first calls the exe then calls the second script to move the mouse and that has the same effect, the splash screen doesn't launch until the mouse has moved. I have mananged to once get it working by using a scheduled task to launch the exe then another to launch the script to move the mouse but this is not ideal at all.

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