Jump to content

Going insane, Why WinWait won't work


prdfy
 Share

Recommended Posts

This is driving me crazy. Why won't a simple WinWait or WinWaitActive script work for me? I am trying to wait for a window title to trigger an event, but it will not work.

If WinWait("notepad","",5) Then

msgbox(0,"test","test1")

EndIf

However, if I use the CLASS argument, then it works.

If WinWaitActive("[CLASS:Notepad]") Then

msgbox(0,"test","test1")

EndIf

Why does it work with a class argument but NOT window title?

Edited by prdfy
Link to comment
Share on other sites

AARRRGGGG! Still won't work.

AutoItSetOption("WinTitleMatchMode",2)

AutoItSetOption("WinTextMatchMode",2)

If WinWaitActive("notepad") Then

msgbox(0,"test","test1")

EndIf

WinTitleMatchMode, 2 should match any substring in the window title. In other words, it will trigger the If/Then statement based on a partial match. But still it's not working. changing the wintextmatchmode has no effect either way.

Edited by prdfy
Link to comment
Share on other sites

AARRRGGGG! Still won't work.

AutoItSetOption("WinTitleMatchMode",2)

AutoItSetOption("WinTextMatchMode",2)

If WinWaitActive("notepad") Then

msgbox(0,"test","test1")

EndIf

WinTitleMatchMode, 2 should match any substring in the window title. In other words, it will trigger the If/Then statement based on a partial match. But still it's not working. changing the wintextmatchmode has no effect either way.

Did you read post #2?. Is the title really "notepad" ? (You have to put the title in the first parameter passed to the Win** functions not the exe name.)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I have to say that I also have troubles using the WinWaitActive/WinActivate functions.

If I understand correctly, these functions are supposed to pause the script until the statement is true.

For example:

WinWaitActive ( "thisIsTheTitleOfTheWindow" )

should pause the script execution until the window with Caption = "thisIsTheTitleOfTheWindow" is active according to the help.

Definition from the Help:

"WinWaitActive

Pauses execution of the script until the requested window is active."

I did not change anything to the default settings so it should be a "full match" for the caption text.

However, it is not always working very well.

So I ended up by doing this:

Winactivate ( "thisIsTheTitleOfTheWindow")
WinWaitActive ( "thisIsTheTitleOfTheWindow")

It did improve the results, but it was not yet perfect. I thought that it might be because the graphic card was taking longer time to update the screen compare to Autoit time to execute the statement (I might be totally wrong, but keep in mind I am not at all an expert in programming), so I tried to introduce a Sleep (500) between the two above statements.

It works 99% of the time but there are times where it does not work.

Edit: (correcting a few things and adding the text below)

Typical example:

When done manually, activating the window with caption "XYZ" and then click on the "ENTER" key should trigger something.

My code is

Winactivate ( "XYZ" )
Send ( "{ENTER}" )

And it is not 100% successful.

Edited by Akshay07
Link to comment
Share on other sites

you cant do

AutoItSetOption("WinTitleMatchMode",2)

for

WinWait("notepad") if win name is "Untitled - Notepad" (well you can only thing is that youl not get any results)

You need to put WinWait("Notepad") or

AutoItSetOption("WinTitleMatchMode",-2) like Richard Robertson sugested

So i think that probably your problem (Akshay07) and prdfy problem are not related

To active win you need some time so you cant send comand before win is activate and WinActivate isnt waiting to win become active before next step

so

WinActivate

WinWaitActive

If WinActive then

Send

EndIf

or

SendKeepActive 4 y :D

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

you cant do

AutoItSetOption("WinTitleMatchMode",2)

for

WinWait("notepad") if win name is "Untitled - Notepad" (well you can only thing is that youl not get any results)

You need to put WinWait("Notepad") or

AutoItSetOption("WinTitleMatchMode",-2) like Richard Robertson sugested

So i think that probably your problem (Akshay07) and prdfy problem are not related

To active win you need some time so you cant send comand before win is activate and WinActivate isnt waiting to win become active before next step

so

WinActivate

If WinActive then

Send

EndIf

or

SendKeepActive 4 y :D

I even tried something like

WinActivate

WinWaitActive

While WinActive=0

WinActivate

Wend

Did not help. On some computers, the script got stuck.

Edited by Akshay07
Link to comment
Share on other sites

Well SendKeepActive shud do the work,

only problem is other program side,

so I tried to introduce a Sleep (500) between the two above statements.

If its constructed to sleep while he is minimized then there is your problem so you shud probably do

Winactivate ( "thisIsTheTitleOfTheWindow")

WinWaitActive ( "thisIsTheTitleOfTheWindow")

sleep(500)

instead

Winactivate ( "thisIsTheTitleOfTheWindow")

sleep(500)

WinWaitActive ( "thisIsTheTitleOfTheWindow")

Or to try it with

ControlFocus ControlGetFocus until your 100% shure you have focus on that control before sending command

or try with ControlSend

I had similar problems on one program and the only thing that worked is that i whas waiting for mouse sand clock icon to disappear before sending anything :D

Becose this look like we are hijacking (and becose your problem isnt related) this topic im off from it. cy

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

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