prdfy Posted January 25, 2010 Share Posted January 25, 2010 (edited) 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 January 25, 2010 by prdfy Link to comment Share on other sites More sharing options...
James Posted January 25, 2010 Share Posted January 25, 2010 Check the title again, I think you'll find it's, "Untitled - Notepad". Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
KaFu Posted January 25, 2010 Share Posted January 25, 2010 Take a look at the "Window Titles and Text (Advanced)" and "WinTitleMatchMode" sections in the help-file... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
prdfy Posted January 25, 2010 Author Share Posted January 25, 2010 (edited) 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 January 25, 2010 by prdfy Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 25, 2010 Share Posted January 25, 2010 Try this, and see the examples at the bottom of the page. Opt("WinTitleMatchMode", 2) - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 25, 2010 Share Posted January 25, 2010 If you use a negative window match mode, it appears to be a case insensitive match. Link to comment Share on other sites More sharing options...
martin Posted January 25, 2010 Share Posted January 25, 2010 AARRRGGGG! Still won't work.AutoItSetOption("WinTitleMatchMode",2)AutoItSetOption("WinTextMatchMode",2)If WinWaitActive("notepad") Then msgbox(0,"test","test1")EndIfWinTitleMatchMode, 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 More sharing options...
Akshay07 Posted January 25, 2010 Share Posted January 25, 2010 (edited) 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 isWinactivate ( "XYZ" ) Send ( "{ENTER}" )And it is not 100% successful. Edited January 25, 2010 by Akshay07 Link to comment Share on other sites More sharing options...
bogQ Posted January 25, 2010 Share Posted January 25, 2010 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 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
Akshay07 Posted January 25, 2010 Share Posted January 25, 2010 (edited) you cant doAutoItSetOption("WinTitleMatchMode",2)forWinWait("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") orAutoItSetOption("WinTitleMatchMode",-2) like Richard Robertson sugestedSo i think that probably your problem (Akshay07) and prdfy problem are not relatedTo 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 stepsoWinActivateIf WinActive then SendEndIforSendKeepActive 4 y I even tried something likeWinActivateWinWaitActiveWhile WinActive=0 WinActivateWendDid not help. On some computers, the script got stuck. Edited January 25, 2010 by Akshay07 Link to comment Share on other sites More sharing options...
bogQ Posted January 25, 2010 Share Posted January 25, 2010 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 doWinactivate ( "thisIsTheTitleOfTheWindow")WinWaitActive ( "thisIsTheTitleOfTheWindow")sleep(500)insteadWinactivate ( "thisIsTheTitleOfTheWindow")sleep(500)WinWaitActive ( "thisIsTheTitleOfTheWindow")Or to try it withControlFocus ControlGetFocus until your 100% shure you have focus on that control before sending commandor try with ControlSendI 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 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 connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now