Sign in to follow this  
Followers 0
trosevear

WinGetState on Terminal Server

4 posts in this topic

Hi

I have a script/tool that basically sits in the system tray with a bunch of menu options on it for users, that performs various functions. I have a need to kill an annoying error window should it appear using this same tool (if possible). The issue I have is if I deploy this script on a Terminal or remote desktop server the application is constantly processing 1-5% CPU for each user running it. This creates a resource problem when you get a few users running this. I am hoping someone might have a better way to do this, or be able to explain why this is using CPU all the time and suggest a work around.

Basically this code is fixing an issue where an application (Sage ACT!) displays "A generic error occured in GDI+." on a Terminal Server randomly for users. The problem is the vendor has not fixed this in 5 versions on their product. My tool works I am just trying to minimize the resource usage and have not been able to.

This is a section of the code:

AutoItSetOption ( "WinTitleMatchMode", 3 )
While 1
    $nMsg = WinGetState ($ACTWindow)
    Switch $nMsg
        Case 0
            ;do nothing
        Case Else
            WinKill($ACTWindow,"A generic error occurred in GDI+.")
    EndSwitch
   $msg = TrayGetMsg()
   Select
        Case $msg = 0
            ;If $GDI Then
                ;If WinGetState ($ACTWindow,"A generic error occurred in GDI+.") <> 0 Then
            ;   If _IsVisible ( $ACTWindow ) Then

            ;   EndIf
            ;EndIf
            ContinueLoop
        Case $msg = $ITDefaultLoc
            ResetRegKey(RegRead($RegHKLM & "\SOFTWARE\ActToday","Preference Default Location"),"Preference Default Location")
EndSelect

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Thanks for the suggestion Polymath, (smarter and quicker code) however this yielded the same result, I have actually just created a script with the following code:

While 1
If WinExists("Sage ACT!","A generic error occurred in GDI+.") Then
        WinKill("Sage ACT!","A generic error occurred in GDI+.")
    EndIf
WEnd

 

 

The processor on this (even on my laptop) uses 25% CPU constantly. Perhaps I am just approaching this the wrong way?

Edited by trosevear

Share this post


Link to post
Share on other sites

OK, thanks to Polymath I believe I have solved this by adding a sleep.

While 1
    If WinExists("Sage ACT!","A generic error occurred in GDI+.") Then
        WinKill("Sage ACT!","A generic error occurred in GDI+.")
    EndIf
    Sleep(50)
WEnd

Thanks for your help.

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