Mucho

Script recognizing Minimized Windows inconsistently

1 post in this topic

#1 ·  Posted (edited)

The script works on a charting program. Basically,

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

    else,

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

 

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",1)
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)
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func On_Exit()
    Exit 0
EndFunc

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

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

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