Jump to content

Idle Problem


Recommended Posts

I have a script that I'm having a problem with. I made a idle routine, but it is hanging around 18 on the processor. Not sure what is causing it.

CODE
#region ;Section is ok, It shouldn't need editing

AutoItSetOption("WinTitleMatchMode", 2)

AutoItSetOption("TrayIconDebug", 1)

Opt("GUIOnEventMode", 1)

Break(1)

Opt("WinDetectHiddenText", 1)

Opt("TrayAutoPause", 0)

Opt("TrayMenuMode", 1)

Opt("GUIOnEventMode", 1)

#include <Date.au3>

$optiontray = TrayCreateItem("Options")

$abouttray = TrayCreateItem("About")

$helptray = TrayCreateItem("Help")

TrayCreateItem("")

$exittray = TrayCreateItem("Exit UNPlus")

TraySetState()

$current = "12:00:00 AM"

#endregion

while 4

$aaa = "Request Detail - Unicenter ServicePlus Service Desk"

$bbb = "Incident Detail - Unicenter ServicePlus Service Desk"

$ccc = "Problem Detail - Unicenter ServicePlus Service Desk"

$ddd = "Update Incident - Unicenter ServicePlus Service Desk"

$eee = "Update Request - Unicenter ServicePlus Service Desk"

$fff = "Update Problem - Unicenter ServicePlus Service Desk"

$ggg = "New Incident"

$hhh = "New Request"

$iii = "New Problem"

$jjj = "Unicenter ServicePlus Service Desk - Announcements"

$jjj2 = "http://usdp/CAisd/pdmweb.exe"

$kkk = "Unicenter ServicePlus Service Desk - Request List"

$lll = "Unicenter ServicePlus Service Desk - Incident List"

$mmm = "Unicenter ServicePlus Service Desk - Incident Search"

$nnn = "Unicenter ServicePlus Service Desk - Request Search"

$ooo = "Unicenter ServicePlus Service Desk - Change Order Search"

$oooo = "Unicenter ServicePlus Service Desk - Change Order List"

$ppp = "Service Request"

$pp2 = "equest.nsf"

$qqq = "Master Page"

$qq2 = "http://dcam.stsc.suntrust.com/PageSetup/master_page.asp"

$rrr = "Message (HTML)"

$rr2 = "Menu Bar"

$sss = "Inbox - Microsoft Outlook"

$ttt = "Work Order: Ad Hoc"

$uuu = "Depot Ordering System - Order #"

$vvv = "Create New Activity for"

Select

Case not WinActive($aaa) or not WinActive($bbb) _

or not WinActive($ccc) or not WinActive($ddd) _

or not WinActive($eee) or not WinActive($fff) _

or not WinActive($ggg) or not WinActive($hhh) _

or not WinActive($iii) or not WinActive($jjj, $jjj2) _

or not WinActive($kkk, $jjj2) or not WinActive($lll, $jjj2) _

or not WinActive($mmm, $jjj2) or not WinActive($nnn, $jjj2) _

or not WinActive($ooo, $jjj2) or not WinActive($ppp, $pp2) _

or not WinActive($qqq, $qq2) or not WinActive($rrr, $rr2) _

or not WinActive($sss) or not WinActive($ttt) _

or not WinActive($uuu) or not WinActive($vvv) or not WinActive($oooo)

do

$msg = TrayGetMsg()

sleep(10)

_trayicon()

until WinActive($aaa) or WinActive($bbb) or WinActive($ccc) _

or WinActive($ddd) or WinActive($eee) or WinActive($fff) _

or WinActive($ggg) or WinActive($hhh) or WinActive($iii) _

or WinActive($jjj, $jjj2) or WinActive($kkk, $jjj2) _

or WinActive($lll, $jjj2) or WinActive($mmm, $jjj2) _

or WinActive($nnn, $jjj2)or WinActive($ooo, $jjj2) _

or WinActive($ppp, $pp2) or WinActive($qqq, $qq2) _

or WinActive($rrr, $rr2) or WinActive($sss) _

or WinActive($ttt) or WinActive($uuu) or WinActive($vvv) _

or WinActive($oooo)

exitloop

EndSelect

WEnd

Func _trayicon()

Select

Case $msg = $optiontray

Run("UNOption.exe")

Case $msg = $helptray

MsgBox(0, "","help clicked")

Case $msg = $exittray

$ProcessList = ProcessList('IVTool.exe')

For $x = 1 To $ProcessList[0][0]

ProcessClose($ProcessList[$x][1])

Next

ProcessClose("maintoolbar.exe")

Exit

Case $msg = $abouttray

MsgBox(64, "about:", "UNPlus 2.0 For Unicenter ServiceDesk" & @CRLF _

& "" & @CRLF _

& " 2006 Suntrust Bank")

case _NowTime() = $current

ProcessClose("maintoolbar.exe")

Exit

EndSelect

EndFunc

Edited by vollyman
Link to comment
Share on other sites

I have a script that I'm having a problem with. I made a idle routine, but it is hanging around 18 on the processor. Not sure what is causing it.

CODE
#region ;Section is ok, It shouldn't need editing

AutoItSetOption("WinTitleMatchMode", 2)

AutoItSetOption("TrayIconDebug", 1)

Opt("GUIOnEventMode", 1)

Break(1)

Opt("WinDetectHiddenText", 1)

Opt("TrayAutoPause", 0)

Opt("TrayMenuMode", 1)

Opt("GUIOnEventMode", 1)

#include <Date.au3>

$optiontray = TrayCreateItem("Options")

$abouttray = TrayCreateItem("About")

$helptray = TrayCreateItem("Help")

TrayCreateItem("")

$exittray = TrayCreateItem("Exit UNPlus")

TraySetState()

$current = "12:00:00 AM"

#endregion

while 4

$aaa = "Request Detail - Unicenter ServicePlus Service Desk"

$bbb = "Incident Detail - Unicenter ServicePlus Service Desk"

$ccc = "Problem Detail - Unicenter ServicePlus Service Desk"

$ddd = "Update Incident - Unicenter ServicePlus Service Desk"

$eee = "Update Request - Unicenter ServicePlus Service Desk"

$fff = "Update Problem - Unicenter ServicePlus Service Desk"

$ggg = "New Incident"

$hhh = "New Request"

$iii = "New Problem"

$jjj = "Unicenter ServicePlus Service Desk - Announcements"

$jjj2 = "http://usdp/CAisd/pdmweb.exe"

$kkk = "Unicenter ServicePlus Service Desk - Request List"

$lll = "Unicenter ServicePlus Service Desk - Incident List"

$mmm = "Unicenter ServicePlus Service Desk - Incident Search"

$nnn = "Unicenter ServicePlus Service Desk - Request Search"

$ooo = "Unicenter ServicePlus Service Desk - Change Order Search"

$oooo = "Unicenter ServicePlus Service Desk - Change Order List"

$ppp = "Service Request"

$pp2 = "equest.nsf"

$qqq = "Master Page"

$qq2 = "http://dcam.stsc.suntrust.com/PageSetup/master_page.asp"

$rrr = "Message (HTML)"

$rr2 = "Menu Bar"

$sss = "Inbox - Microsoft Outlook"

$ttt = "Work Order: Ad Hoc"

$uuu = "Depot Ordering System - Order #"

$vvv = "Create New Activity for"

Select

Case not WinActive($aaa) or not WinActive($bbb) _

or not WinActive($ccc) or not WinActive($ddd) _

or not WinActive($eee) or not WinActive($fff) _

or not WinActive($ggg) or not WinActive($hhh) _

or not WinActive($iii) or not WinActive($jjj, $jjj2) _

or not WinActive($kkk, $jjj2) or not WinActive($lll, $jjj2) _

or not WinActive($mmm, $jjj2) or not WinActive($nnn, $jjj2) _

or not WinActive($ooo, $jjj2) or not WinActive($ppp, $pp2) _

or not WinActive($qqq, $qq2) or not WinActive($rrr, $rr2) _

or not WinActive($sss) or not WinActive($ttt) _

or not WinActive($uuu) or not WinActive($vvv) or not WinActive($oooo)

do

$msg = TrayGetMsg()

sleep(10)

_trayicon()

until WinActive($aaa) or WinActive($bbb) or WinActive($ccc) _

or WinActive($ddd) or WinActive($eee) or WinActive($fff) _

or WinActive($ggg) or WinActive($hhh) or WinActive($iii) _

or WinActive($jjj, $jjj2) or WinActive($kkk, $jjj2) _

or WinActive($lll, $jjj2) or WinActive($mmm, $jjj2) _

or WinActive($nnn, $jjj2)or WinActive($ooo, $jjj2) _

or WinActive($ppp, $pp2) or WinActive($qqq, $qq2) _

or WinActive($rrr, $rr2) or WinActive($sss) _

or WinActive($ttt) or WinActive($uuu) or WinActive($vvv) _

or WinActive($oooo)

exitloop

EndSelect

WEnd

Func _trayicon()

Select

Case $msg = $optiontray

Run("UNOption.exe")

Case $msg = $helptray

MsgBox(0, "","help clicked")

Case $msg = $exittray

$ProcessList = ProcessList('IVTool.exe')

For $x = 1 To $ProcessList[0][0]

ProcessClose($ProcessList[$x][1])

Next

ProcessClose("maintoolbar.exe")

Exit

Case $msg = $abouttray

MsgBox(64, "about:", "UNPlus 2.0 For Unicenter ServiceDesk" & @CRLF _

& "" & @CRLF _

& " 2006 Suntrust Bank")

case _NowTime() = $current

ProcessClose("maintoolbar.exe")

Exit

EndSelect

EndFunc

have you tried increasing your sleep time in the while loop? you have it at 10, try 100, that may fix it right up.
Link to comment
Share on other sites

It doesn't help much, and it causes a responce slowdown, which I rather avoid. I set it to 400, and it went down to 3, but I rather have it at 0, with no responce time lag.

well if you don't like the result of reducing the number of iterations, then your next option is to reduce the operations per iteration. for example, why do you have the assignments of all of those literal strings being done in every iteration? are they ever changed after assignment? if not then move the start of the loop until after those assignments. then you're cutting about half of the work out of every iteration, and i bet that would drop the usage considerable without needing a bigger sleep.
Link to comment
Share on other sites

The problem I have is the script is looking to see if any of those windows are active. If not, I need it to idle until one of them become active. Without the idle function, My script will kick up to 27 on processor until one of the windows are active.

I was thinking, could I do a case else and the end of the wile loop. I tried it, and it helped some, but I still have processor hunger. I set it to 50, and I got it to 9. I hate to go higher than than, for the responce time starts to get affected.

Link to comment
Share on other sites

you have opt on event mode twice... yet you use guigetmessage... a bozo no-no!

.... this is a direction... i cant test it correctly

#include <GUIConstants.au3>
#region;Section is ok, It shouldn't need editing

AutoItSetOption("WinTitleMatchMode", 2)
;AutoItSetOption("TrayIconDebug", 1)
;Opt("GUIOnEventMode", 1)
Break(1)
;Opt("WinDetectHiddenText", 1)
;Opt("TrayAutoPause", 0)
Opt("TrayMenuMode", 1)
;Opt("GUIOnEventMode", 1)
#include <Date.au3>
$optiontray = TrayCreateItem("Options")
$abouttray = TrayCreateItem("About")
$helptray = TrayCreateItem("Help")
TrayCreateItem("")
$exittray = TrayCreateItem("Exit UNPlus")
TraySetState()
$current = "12:00:00 AM"
$passes = ""
#endregion


    
    $Window = StringSplit("Request Detail - Unicenter ServicePlus Service Desk,Incident Detail - Unicenter ServicePlus Service Desk" & _
    "Problem Detail - Unicenter ServicePlus Service Desk,Update Incident - Unicenter ServicePlus Service Desk" & _
    "Update Request - Unicenter ServicePlus Service Desk,Update Problem - Unicenter ServicePlus Service Desk" & _
    "New Incident,New Request,New Problem,Unicenter ServicePlus Service Desk - Announcements,http://usdp/CAisd/pdmweb.exe" & _
    "Unicenter ServicePlus Service Desk - Request List,Unicenter ServicePlus Service Desk - Incident List" & _
    "Unicenter ServicePlus Service Desk - Incident Search,Unicenter ServicePlus Service Desk - Request Search" & _
    "Unicenter ServicePlus Service Desk - Change Order Search,Unicenter ServicePlus Service Desk - Change Order List" & _
    "Service Request,equest.nsf,Master Page,http://dcam.stsc.suntrust.com/PageSetup/master_page.asp,Message (HTML),Menu Bar" & _
    "Inbox - Microsoft Outlook,Work Order: Ad Hoc,Depot Ordering System - Order #,Create New Activity for", ",")
    
While 4
    
    $msg4 = GUIGetMsg()
    
    If $msg4 = $GUI_EVENT_CLOSE Then Exit
    
    For $x = 1 to $Window[0]
        If WinActive($Window[$x]) Then 
            $x = 1
            ContinueLoop
        EndIf
    Next    
    
    _trayicon()
    
    Sleep(10)
WEnd

Func _trayicon()
    While $passes < 100
    
    $msg = GUIGetMsg()
    Select
        Case $msg = $optiontray
            Run("UNOption.exe")
        Case $msg = $helptray
            MsgBox(0, "", "help clicked")
            
        Case $msg = $exittray
            $ProcessList = ProcessList('IVTool.exe')
            For $x = 1 To $ProcessList[0][0]
                ProcessClose($ProcessList[$x][1])
            Next
            ProcessClose("maintoolbar.exe")
            Exit
        Case $msg = $abouttray
            MsgBox(64, "About:", "UNPlus 2.0 For Unicenter ServiceDesk" & @CRLF _
                     & "" & @CRLF _
                     & " 2006 Suntrust Bank")
            
        Case _NowTime() = $current
            ProcessClose("maintoolbar.exe")
            Exit
    EndSelect
WEnd

$passes = ""
EndFunc  ;==>_trayicon

8)

NEWHeader1.png

Link to comment
Share on other sites

just reviewing it visually...

looks like

For $x = 1 to $Window[0]
        If WinActive($Window[$x]) Then
            $x = 1
            ContinueLoop
        EndIf
    Next

should have a very small sleep in it also

8)

NEWHeader1.png

Link to comment
Share on other sites

Well, I put in the fix you gave me, and now sometimes it gets stuck in the idle loop. I hate to post the entire code to the board, it is 1400 lines.

use tooltips or msgbox's, or even consolewrite()'s to find out what you values are at each iteration, to see why your exit condition isn't being met.
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...