Vlane Posted March 16, 2011 Posted March 16, 2011 Hello! I am currently writing a script that does some of my work and I'm at a point where it's basically finished but there is a problem which makes it unusable. It does not fully work on the first try. If I execute it a second time it works just fine but I can't do that, it has to work the first time. The script stops at this statement (line 320): if WinGetState($handle) == 0 Then Everything after that is not executed. I already tried WinWaitClose($handle) but it yields the same result. I attached the script if it helps. The script is simplistic but otherwise works. Any help is appreciated.admin.au3
water Posted March 16, 2011 Posted March 16, 2011 WinGetState returns an integer, but the operator "==" is made for string comparison. Could you replace "==" with "=" and test again? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted March 16, 2011 Posted March 16, 2011 Sadly the result is the same. Then put a debugging statement in front to check the state of the window. ConsoleWrite(WinGetState($handle) & @CRLF) if WinGetState($handle) == 0 Then My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
JohnOne Posted March 16, 2011 Posted March 16, 2011 If you are trying to do something with that non existent window, that would make it fail. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
bogQ Posted March 16, 2011 Posted March 16, 2011 While $i <= 0is neverending loopIf there is not a window @error return 0 (that is what your WinGetState($handle) = 0 means) that holds the handle $handle it will trigger 'If' event, only problem is that 'While $i <= 0' will b all the time equal to zero if there is not that win with that handle, handle of win change from time to time if im not wrong when you close it and open up some new random win and open once more your old win So its probably neverending (script cannot exit that loop)Instead using all the send keyes and because we cant see what your script is doing, do it open you wins close old-ones or something like that, why don`t you try to use control* commands?And one more time read WinGetState for return valyes from help file. 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.
Vlane Posted March 17, 2011 Author Posted March 17, 2011 (edited) I tried it with ConsoleWrite and it's a loop. But why does it work on the second try? This is what I don't understand. For clarification purposes: We are working with images in my company which are sysprep'd. Because of that I have to check if everything is working, activate windows/office and so on. This script does that. Edited March 17, 2011 by Vlane
bogQ Posted March 17, 2011 Posted March 17, 2011 (edited) Instead of $handle = WinGetHandle("Kopieren von ") ; WinGetHandle holt sich die ID des Fensters if WinGetState($handle) == 0 ThenTry to use this Its strange that you chosed WinGetState to compare it to =0 Try not to involve handle of win and use title directly If WinExists("Kopieren von ") Then MsgBox(0, "", "Window exists") Else MsgBox(0, "", "Window DO NOT exists") EndIf Are you shure that your win title is "Kopieren von ",you noticed that you have empty space on the end of the title? So try to remove WinGetState and try to use WinExists instead. Dont forget to put ExitLoop comand to somehow exit loop if something inst correct. Edited March 17, 2011 by bogQ 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.
Vlane Posted March 18, 2011 Author Posted March 18, 2011 If WinExists("Kopieren von ") Then MsgBox(0, "", "Window exists") Else MsgBox(0, "", "Window DO NOT exists") EndIf I can't use "WinExists("Kopieren von ")" because the title of the window is changing when the copying process takes longer (for example, it changes to "20 seconds remaining"). Someone recommended to use a handle for this and that's why I did it.
bogQ Posted March 18, 2011 Posted March 18, 2011 (edited) Opt("WinTitleMatchMode", 2) can solve that problem for stringinstr with title newer the less, handle or no handle in any case you shud b using WinExists instead of WinGetState() You can do combination like this Opt("WinTitleMatchMode", 2);set to substr Do Sleep(10) Until Not WinExists("Kopieren von ") Opt("WinTitleMatchMode", 1);restore defolt settings Send('{DEL}') Sleep(1000) Send('{DEL}') Sleep(500) Send('{ENTER}') Sleep(5000) del() del() ... or to put WinWaitClose (ups now i see that it did not work to you) Vlane do you have two windows with identical name? What do WinList return and what do the WinGetState return when the problem happens? Asuming that you dont see that win on your comp but somehow he still exsist. Edited March 18, 2011 by bogQ 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.
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