Jump to content
Sign in to follow this  
bowo

autoit not wait for the active window

Recommended Posts

bowo

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

Share this post


Link to post
Share on other sites
FireFox

Hi,

What do you need this script for?

There may be more reliable ways to automate what you're trying to do.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
TheSaint

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?


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

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  

×