Jump to content
Sign in to follow this  
Bert

Loop Question

Recommended Posts

Bert

I have a script that is causing a processor problem only when the windows it interacts with are not active. I was thinking of making a sub loop that would cause a sleep statement to loop until one of the windows became active again. I have about 17 windows to deal with, and depending on which window is active, I have certain keys become hotset keys.

I think it is possible, but I think it would be very easy to get the script stuck. Has anyone attempted something like this?

Share this post


Link to post
Share on other sites
Valuater

i used this

Func Cycle()
    While 4
        If Not ProcessExists($PID) Then Return; waits for the process to end
        If $rst="go" then; a "exit cycle" hotkey
            $rst=""
            Return
        EndIf
        Sleep(100)
    WEnd
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Bert

I see how it works, looks good. I think I can work with this to fix the problem. My processor time is hanging around 17, but all I'm doing is waiting for a window to active, and if not, keep looping. This snippit when tweaked should do the trick.

Share this post


Link to post
Share on other sites
Bert

I made a piece of code that does the trick nicely, but it produced a different problem. Here is the code:

CODE
while 4

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)

do

sleep(200)

;_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)

exitloop

endselect

wend

Func _trayicon()

Select

Case $msg = $optiontray

Run("UNOption.exe")

Case $msg = $helptray ;need to fix with GUI

MsgBox(0, "Help", "On each window that UNPlus supports, you can " & _

"press the F1 key for a list of supported keys to use." & @CRLF _

& "" & @CRLF _

& "Supported windows are:" & @CRLF _

& " Incident List and Request List." & @CRLF _

& " Incident Detail, Request Detail and Problem Detail." & @CRLF _

& " Incident Update, Request Update and Problem Update." & @CRLF _

& " New Incident, New Request, and New Problem." & @CRLF _

& "" & @CRLF _

& "Extra functions include: " & @CRLF _

& " QuickPaste - A simple predefined clipboard tool to save keystrokes." & @CRLF _

& " Note: QuickPaste is available for use regardless of what window is active." & @CRLF _

& " You will quickly find many uses for QuickPaste in other applications." & @CRLF _

& " TreePaste - To help in the selection of configuration items." & @CRLF _

& " Refresh view on supported windows." & @CRLF _

& " Search Request and Search Incident." & @CRLF _

& " Resolution shortcut." & @CRLF _

& " Time stamper for Unicenter, Service Request and Work Orders." & @CRLF _

& " Logout shortcut." & @CRLF _

& " Print key support is added for any Incident, Request, or Problem." & @CRLF _

& " Extended print key support has been added for Service Request, Depot tickets and Outlook." & @CRLF _

& "" & @CRLF _

& "Many of the options can be configured using the Options interface " & _

"located on the system tray icon menu.")

Case $msg = $exittray

$ProcessList = ProcessList('IVTool.exe')

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

sleep(1)

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

sleep(1)

Next

ProcessClose("maintoolbar.exe") ;("Unicenter Toolbar")

Exit

Case $msg = $abouttray

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

& "" & @CRLF _

& " 2006 Suntrust Bank")

EndSelect

EndFunc

I have a tray icon that has menu items on it, but when the script is in the above loop, the menu items don't work. I tried making a function and adding a reference to it, but it didn't work. I left the function in place, but commented out in the above script so you can get the idea of what I tried. Any way to fix this?

Share this post


Link to post
Share on other sites
SmOke_N

Are you using TrayGetMsg()? If so, you might want to stick that in that loop, otherwise, how can anything be returned?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.