Jump to content

autoit not wait for the active window


bowo
 Share

Recommended Posts

Can someone fix my script?

script does not wait for the active window

#Include <WinAPI.au3>
Func First ()

TrayTip ( "Example", "F1 to out", 20000, 1)
HotKeySet("{F1}", "dead")
AutoitSetoption ( "MouseClickDelay", 50 )

if ProcessExists ("example.exe") Then
   WinWaitActive ( "Example Program", "", "" )
   $4 = 0xFFCC00
   $count = 0
   $movx = 1
   $movy = 1
   WinMove ( "Example Program", "", $movx, $movy )
                  $a = PixelSearch ( 124, 119, 129, 122, $4 )
                    if isArray ( $a ) = True Then
                           $Count += 1
                        Else
                        EndIf
                        
                   $b = PixelSearch ( 250, 119, 257, 122, $4 )
                     if isArray ( $b ) = True Then
                           $Count += 1
                        Else
                        EndIf
                        
                  $c = PixelSearch ( 383, 119, 385, 122, $4 )
                     if isArray ( $c ) = True Then
                           $Count += 1
                        Else
                        EndIf
                  
                  $d = PixelSearch ( 516, 119, 513, 122, $4 )
                     if isArray ( $d ) = True Then
                           $Count += 1
                        Else
                        EndIf
                  
               if $Count == 4 Then
                  call ("ready")
               Else
                  call ("First")
               EndIf
               
Else
   Msgbox (0, "Failure", "Program Closed")
   sleep ( 2000 )
EndIf
EndFunc

Func Dead() ; variable exit hotkey
   Exit 0
EndFunc

Func ready()
   blah blah blah
   call ("First")
EndFunc
Edited by bowo
Link to comment
Share on other sites

I gather you've tried the Window Info Tool?

That you've used MsgBox and return values to determine where any issue might lie?

That you've tried Sleep in various places to determine if any delay is needed?

Timing issues?

It may just be, that a Window needs to be fully drawn, before it can be moved?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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