Sign in to follow this  
Followers 0
Wollywog

WinWait Question

7 posts in this topic

Hello,

I am using AutoIt with NeoBook. I love it very much, it is wonderful stuff.

WinWait works perfectly for me unless the main frame of the application remains active when a child window is open - the main window and the child window are both active. When this is the case, AutoIt never recognizes that the child window has opened.

My client has to have both windows active, because the user needs to be able to work in multiple windows at the same time.

I don't know much about scripting. If I were to buy and study the AutoIt guide, do you think it would be possible for me to tweak AutoIt to account for that situation, than have it wrapped in a customized version of the NeoBook plugin?

Thanks very much,

Mike

Share this post


Link to post
Share on other sites



Hello,

I am using AutoIt with NeoBook. I love it very much, it is wonderful stuff.

WinWait works perfectly for me unless the main frame of the application remains active when a child window is open - the main window and the child window are both active. When this is the case, AutoIt never recognizes that the child window has opened.

My client has to have both windows active, because the user needs to be able to work in multiple windows at the same time.

I don't know much about scripting. If I were to buy and study the AutoIt guide, do you think it would be possible for me to tweak AutoIt to account for that situation, than have it wrapped in a customized version of the NeoBook plugin?

Thanks very much,

Mike

The Windows API only allows one window to be active at a time.

If WinWait() can't tell the difference between the two windows, your problem is the weakness of your matching technique (which you didn't post for an example). You could use the special matching term "INSTANCE:2", or the handles, for example to tell the two apart.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The Windows API only allows one window to be active at a time.

If WinWait() can't tell the difference between the two windows, your problem is the weakness of your matching technique (which you didn't post for an example). You could use the special matching term "INSTANCE:2", or the handles, for example to tell the two apart.

:)

Hi,

Thanks for the fast reply. I use Acc Explorer, so I can find the window's handle.

Mike

Edited by Wollywog

Share this post


Link to post
Share on other sites

Hi,

Thanks for the fast reply. I use Acc Explorer, so I can find the window's handle.

Mike

Interesting idea, but I don't think it helps (someone will correct me if I'm wrong, please). Getting the handle in a third party app wouldn't help because it will be different at each run time, and couldn't be entered to the script. Even if you passed it to the script as an integer on the command line, I'm not sure you could recreate an HWND variable from that inside the script.

The normal use of handles in AutoIt is to get it at execution time with:

$hWin = WinGetHandle()

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

The Windows API only allows one window to be active at a time.

If WinWait() can't tell the difference between the two windows, your problem is the weakness of your matching technique (which you didn't post for an example). You could use the special matching term "INSTANCE:2", or the handles, for example to tell the two apart.

:)

Might anyone be able to give a code example of using a handle or special matching term for winwait?

Thank you.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Might anyone be able to give a code example of using a handle or special matching term for winwait?

Thank you.

They just might... :)

; Set mode to advanced
Opt("WinTitleMatchMode", 4)

; Run notepad twice
Global $PID1 = Run("notepad.exe")
Global $PID2 = Run("notepad.exe")

; Wait for the second instance to open
WinWait("[TITLE:Untitled - Notepad; INSTANCE:2]")

; Get handles from windows
Global $hWIN1 = WinGetHandle("[TITLE:Untitled - Notepad; INSTANCE:1]")
Global $hWIN2 = WinGetHandle("[TITLE:Untitled - Notepad; INSTANCE:2]")

; Use handles to manipulate windows
WinActivate($hWIN1)
Sleep(1000)
WinSetTitle($hWIN1, "", "This is Notepad One...")
Sleep(1000)
WinSetState($hWIN1, "", @SW_MINIMIZE)
Sleep(1000)
WinActivate($hWIN2)
Sleep(1000)
WinSetTitle($hWIN2, "", "This is Notepad Two...")
Sleep(1000)
WinSetState($hWIN2, "", @SW_MINIMIZE)
Sleep(1000)
WinSetState($hWIN1, "", @SW_RESTORE)
Sleep(1000)
WinClose($hWIN1)
Sleep(1000)
WinSetState($hWIN2, "", @SW_RESTORE)
Sleep(1000)
WinClose($hWIN2)
Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Wow Psalty, thanks so much for that very helpful info!

And thanks to you too, boji for asking for the info.

I've got some good experimenting and challenges ahead of me with this stuff, and that's great, because that's what keeps me form falling asleep at my PC.

You guys are a great help to me, and I appreciate. Don't be surprised if I get into this and come back to you with some stupid questions, ha ha :)

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