Sign in to follow this  
Followers 0
supadodger

check how long a window has been open?

10 posts in this topic

#1 ·  Posted (edited)

ive been using wingettitle and then sleeping and checking again.

this isnt the actual code but you guys will get it

is there any better way of doing this?

$open = wingettitle super

if wingettitle = 1 then sleep 5000

else

Goto Waiting

Endif

$open = wingettitle super

if wingettitle = 1 then run c:\blah.exe

else

Endif

Edited by supadodger

Share this post


Link to post
Share on other sites



ive been using wingettitle and then sleeping and checking again.

this isnt the actual code but you guys will get it

is there any better way of doing this?

$open = wingettitle super

if wingettitle = 1 then sleep 5000

else

Goto Waiting

Endif

$open = wingettitle super

if wingettitle = 1 then run c:\blah.exe

else

Endif

That's some pretty hopeless scripting. AutoIt requires parens around the function parameters (see the help file). WinGetTitle() returns a string (see the help file). There is no GOTO in AutoIt (see the help file).

See the help file.

:D


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

That's some pretty hopeless scripting. AutoIt requires parens around the function parameters (see the help file). WinGetTitle() returns a string (see the help file). There is no GOTO in AutoIt (see the help file).

See the help file.

:D

this isnt the actual code this isnt the actual code = Pseudocode <> proper formatting

(and, since we do not have any methods except for functions, there SHOULD be a way to unconditionally branch... as in On Error Goto...)

it would have saved me about 100 lines of code in my most recent project (and made the result a LOT more readable)


Everseeker

Share this post


Link to post
Share on other sites

That's some pretty hopeless scripting. AutoIt requires parens around the function parameters (see the help file). WinGetTitle() returns a string (see the help file). There is no GOTO in AutoIt (see the help file).

See the help file.

:D

ive read the help file a bit and cant find a more efficient way of doing this.

okay then. here is actual code.

Func Wait()
ToolTip("Sleeping Tynieko", 0, 0)
WinWait ("Tyny")
ToolTip("Tyny Dead?", 0, 0)
Sleep (10000)
$open = WinGetTitle ("Tyny", "")
If $open = 1 Then
ToolTip("Sleeping Tyny", 0, 0)
Winclose ("Tyny")
WinClose ("TynyGM")
Sleep(1000)
Else
Endif
ENdFunc

is there a better way of doing this?

better as in more efficient.

Share this post


Link to post
Share on other sites

this isnt the actual code this isnt the actual code = Pseudocode <> proper formatting

My mistake. Correction: That's some pretty hopeless pseudocode...

:D

(and, since we do not have any methods except for functions, there SHOULD be a way to unconditionally branch... as in On Error Goto...)

it would have saved me about 100 lines of code in my most recent project (and made the result a LOT more readable)

No.

:D


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

ive read the help file a bit and cant find a more efficient way of doing this.

okay then. here is actual code.

Func Wait()
ToolTip("Sleeping Tynieko", 0, 0)
WinWait ("Tyny")
ToolTip("Tyny Dead?", 0, 0)
Sleep (10000)
$open = WinGetTitle ("Tyny", "")
If $open = 1 Then
ToolTip("Sleeping Tyny", 0, 0)
Winclose ("Tyny")
WinClose ("TynyGM")
Sleep(1000)
Else
Endif
ENdFunc

is there a better way of doing this?

better as in more efficient.

Are you just using WinGetTitle() to test if the window exists? Check out WinExists() (see the help file).

:D


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

#7 ·  Posted (edited)

Are you just using WinGetTitle() to test if the window exists? Check out WinExists() (see the help file).

:D

it always exists and winexists finds it hidden. its hidden mostly i just need to know if its not hidden.

so actually neither code is working right since both find it hidden.

thats why im here. i wanna see it only if its not hidden.

maybe i can do winacttivate and then winactive and see if its active to tell if its hidden.

Edited by supadodger

Share this post


Link to post
Share on other sites

ive read the help file a bit and cant find a more efficient way of doing this.

okay then. here is actual code.

Func Wait()
ToolTip("Sleeping Tynieko", 0, 0)
WinWait ("Tyny")
ToolTip("Tyny Dead?", 0, 0)
Sleep (10000)
$open = WinGetTitle ("Tyny", "")
If $open = 1 Then
ToolTip("Sleeping Tyny", 0, 0)
Winclose ("Tyny")
WinClose ("TynyGM")
Sleep(1000)
Else
Endif
ENdFunc

is there a better way of doing this?

better as in more efficient.

Maybe something like this

Global $startedtiming = False, $starttime, $endtime
While 1
    If Exitcondition() Then Exit

    If WinExists("some title") Then
        If Not $statedtiming Then
            $starttime = TimerInit()
            $startedtiming = True
        EndIf
    Else
        If $startedtiming Then
            $endtime = TimerDiff($starttime) 
            $startedtiming = False
        EndIf

    EndIf

    Sleep(100)
    
WEnd

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.

Share this post


Link to post
Share on other sites

Maybe something like this

Global $startedtiming = False, $starttime, $endtime
While 1
    If Exitcondition() Then Exit

    If WinExists("some title") Then
        If Not $statedtiming Then
            $starttime = TimerInit()
            $startedtiming = True
        EndIf
    Else
        If $startedtiming Then
            $endtime = TimerDiff($starttime) 
            $startedtiming = False
        EndIf

    EndIf

    Sleep(100)
    
WEnd
If you need to know if it's visible rather than it exists then instead of

if WinExists("some title") Then

use

if BitAND(WinGetState("some title"),2) Then


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.

Share this post


Link to post
Share on other sites

it always exists and winexists finds it hidden. its hidden mostly i just need to know if its not hidden.

so actually neither code is working right since both find it hidden.

thats why im here. i wanna see it only if its not hidden.

maybe i can do winacttivate and then winactive and see if its active to tell if its hidden.

i got it. thanks guys.

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