Jump to content

Script recognizing Minimized Windows inconsistently

Recommended Posts

The script works on a charting program. Basically,

if a chart is Detached but Not minimized, maximize and process it;


Process another attached chart which is attached to the main layout.


Opt("TrayIconHide", 0)
Opt("TrayIconDebug", 1)
#include <Date.au3>
#include <File.au3>
#include <Array.au3>
#include <Misc.au3>

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "On_Exit")

Dim $ChartList

If WinExists("Advisor Professional  v","") = False then Exit
$ChartList = WinList ("", "Processing data")

If $Chartlist[1][0] <> "" And BitAND(WinGetState($ChartList[1][1]), 16) then ;IsMinimized($Chartlist[1][0]) Then
    MsgBox($MB_SYSTEMMODAL, "Wait", "A chart is either minimized or not detached. Process Attached Chart", 1)
    _WinWaitActivate("Advisor Professional  v","")
Else ;( Detached Chart )
    MsgBox($MB_SYSTEMMODAL, "Wait", "Process Detached Chart that is not minimized", 1)
    WinSetState ($ChartList[1][0], "", @SW_MAXIMIZE)
    MouseClick("left", 130, 40, 1,0)
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        ToolTip('Script is "Paused"',0,0)

Func On_Exit()
    Exit 0

Func _WinWaitActivate($title,$text,$timeout=0)
    If Not WinActive($title,$text) Then WinActivate($title,$text)

The executions of their respective conditions are being simplified here.

I run the script off the quicklaunch. The problem is that it recognizes the detached chart only once, which is the first time. The first time, it recognizes that there is a detached chart that is minimized and so ignores it and processes the attached chart, which is correct, as in the office computer.

On the second run, it fails to recognize that the detached charts are minimized and goes to the second condition, displaying the message, "

"Process Detached Chart that is not minimized"

but without maximizing it, when my script clearly winsetstates it to maximum.

On the third run, it comes back to recognizing the detached chart, so processes the attached chart correctly.

On the fourth, it fails again, and so on with subsequent runnings, alternating between the two conditions.

And to get the script back to working normally, I have to switch to another program's window like my browser and back to my charting program again. But it works only once, again.


I do not have this strange problem with the same script on my office computer.

I hope I have explained my problem with clarity. If not, please query. I need all help.

Edited by Mucho
Upon further testing, second condition not working
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...