Sign in to follow this  
Followers 0
Vlane

Script not working on first try

10 posts in this topic

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

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Sadly the result is the same.

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

While $i <= 0

is neverending loop

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

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Vlane

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Instead of

$handle = WinGetHandle("Kopieren von ") ; WinGetHandle holt sich die ID des Fensters

if WinGetState($handle) == 0 Then

Try 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 by bogQ

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.

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by bogQ

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.

 

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