Bert Posted December 6, 2005 Share Posted December 6, 2005 I wrote a application for Unicenter ServiceDesk that adds shortkuts by using hotsetkeys. It works, but I noticed it is eating up about 40% of my processor time. Is this normal? If not, is there something wrong with my script? expandcollapse popupAutoItSetOption("WinTitleMatchMode", 2);any part of the string can be used in a window's name AutoItSetOption("TrayIconDebug", 1);debug is on Break(1);This fixes the icon in the systemtray. 1 is on, 0 is off ;checks to see if UNPlus.exe is running $g_szVersion = "UNPlus.exe" If WinExists($g_szVersion) Then Exit; It's already running ;Startup splash screen AutoItWinSetTitle($g_szVersion) SplashTextOn("Unicenter UNPlus", "Unicenter Plus Beta .9_6 for ServiceDesk 6.0.", 500, 40, -1, -1, 0, "", 18) Sleep(1500) SplashOff() ;Checks to see if Unicenter is loaded. If not ;it will start Unicenter IF WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") == 0 then run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe", "") WinWaitActive("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") endif IF WinExists ("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe" )== 1 then WinActivate ( "Unicenter ServicePlus Service Desk" , "http://usdp/CAisd/pdmweb.exe" ) endif ;----------------------------------------------- ;These hotsetkeys will always be active. This is due to the nature of the function. HotKeySet("{F6}", "_F6_Func");QuickPaste HotKeySet("^!x", "_key1_Func");exit this script only - clrl + alt + x ;------------------------------------------------ While 1 ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;------------------------------------------------------ ;This section monitors if Unicenter is open or closed. ;It is working through many beta trials, so no changes ;are needed here. DO NOT MAKE ANY CHANGES HERE ;------------------------------------------------------ ;;- $uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") if $uni == 0 then $endunplus = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter?" & @CRLF _ & @CRLF _ & "Click YES to restart Unicenter." & @CRLF _ & "Click NO to close UNPlus."& @CRLF _ & "Click CANCEL to disreguard this message") if $endunplus == 2 then WinWaitActive("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") sleep(5000);IMPORTANT THAT THIS SLEEP STATEMENT STAYS HERE! endif if $endunplus == 7 then exit endif if $endunplus == 6 then run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe","") endif ;end section ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;This section monitors if certain windows are open. ;If they are, the hotkeysets for those windows are active. ;<:::Keys for Request Detail:::> If WinActive("Request Detail - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1A_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotKeySet("{PRINTSCREEN}", "_key2_Func"); Print ticket WinWaitNotActive("Request Detail - Unicenter ServicePlus Service Desk") _key_clean_1() EndIF ;<:::Keys for Incident Detail:::> If WinActive("Incident Detail - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1B_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotKeySet("{PRINTSCREEN}", "_key2_Func"); Print ticket WinWaitNotActive("Incident Detail - Unicenter ServicePlus Service Desk") _key_clean_1() EndIf ;<:::Keys for Problem Detail:::> If WinActive("Problem Detail - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1C_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotKeySet("{PRINTSCREEN}", "_key2_Func"); Print ticket WinWaitNotActive("Problem Detail - Unicenter ServicePlus Service Desk") _key_clean_1() EndIf ;<:::Keys for Update Incident:::> If WinActive("Update Incident - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1D_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste WinWaitNotActive("Update Incident - Unicenter ServicePlus Service Desk") _key_clean_1() EndIf ;<:::Keys for Update Request:::> If WinActive("Update Request - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1E_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste WinWaitNotActive("Update Incident - Unicenter ServicePlus Service Desk") _key_clean_1() EndIf ;<:::Keys for Update Problem:::> If WinActive("Update Problem - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1F_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste WinWaitNotActive("Update Problem - Unicenter ServicePlus Service Desk") _key_clean_1() EndIf ;;<:::Keys for Main Window:::> If WinActive("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") Then;DO NOT CHANGE THIS LINE! HotKeySet("{F1}", "_F1G_Func");turns key on for help HotKeySet("{F2}", "_F2_Func");turns key on for Search Request HotKeySet("{F3}", "_F3B_Func");turns key on for Search Request HotKeySet("{F5}", "_F5B_Func");turns key on Refresh current querry HotKeySet("{F8}", "_F8_Func");turns key on for close Unicenter WinWaitNotActive("Update Problem - Unicenter ServicePlus Service Desk") _key_clean_1() EndIf wend ;Functions------------------------------- ;table of contents ;F1 ; F1A: Help in Request Ticket view ; F1B: Help in Incident Ticket view ; F1C: Help in Problem Ticket view ; F1D: Help in Update Incident view ; F1E: Help in Update Request view ; F1F: Help in Update Problem view ; F1G: Help in Main Window view ;F2 ; F2: Search Request ;F3 ; F3A: Resolution field ; F3B: Search Incident ;F4 ; F4: TreePaste ;F5 ; F5B: Refresh ticket view ; F5B: Refresh Querry ;F6 ; F6: QuickPaste ;F7 ; F7: Close ticket ;F8 ; F8: Log out Unicenter ;F9 ; F9: CTFS ;------------------------------------------- ;F1 section - Help Func _F1A_Func();Help in Request Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else $help_R = GUICreate("Help in Request Ticket view", 445, 130) GUISetBkColor (0xE0FFFF) GUICtrlCreateLabel ("F1= Opens a help file showing the functions." & @CRLF _ & "F5= Refresh: This will refresh the current view." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed." & @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.", 5, 5, 440, 95) $button1 = GUICtrlCreateButton("OK", 185, 102, 60, 20) ; Run the GUI until it is closed GUISetState() While 2 $msg = GUIGetMsg() Select Case $msg = $button1 GuiDelete($help_R) exitloop EndSelect WEnd EndIf EndFunc ;==>_F1A_Func Func _F1B_Func();Help in Incident Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else $help_R = GUICreate("Help in Incident Ticket view", 445, 130) GUISetBkColor (0xE0FFFF) GUICtrlCreateLabel ("F1= Opens a help file showing the functions." & @CRLF _ & "F5= Refresh: This will refresh the current view." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed." & @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.", 5, 5, 440, 95) $button1 = GUICtrlCreateButton("OK", 185, 102, 60, 20) ; Run the GUI until it is closed GUISetState() While 3 $msg = GUIGetMsg() Select Case $msg = $button1 GuiDelete($help_R) exitloop EndSelect WEnd EndIf EndFunc ;==>_F1B_Func Func _F1C_Func();Help in Problem Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else $help_R = GUICreate("Help in Problem Ticket view", 445, 130) GUISetBkColor (0xE0FFFF) GUICtrlCreateLabel ("F1= Opens a help file showing the functions." & @CRLF _ & "F5= Refresh: This will refresh the current view." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed." & @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.", 5, 5, 440, 95) $button1 = GUICtrlCreateButton("OK", 185, 102, 60, 20) ; Run the GUI until it is closed GUISetState() While 4 $msg = GUIGetMsg() Select Case $msg = $button1 GuiDelete($help_R) exitloop EndSelect WEnd EndIf EndFunc ;==>_F1C_Func Func _F1D_Func();Help in Incident Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else $help_R = GUICreate("Help in Update Incident view", 445, 130) GUISetBkColor (0xE0FFFF) GUICtrlCreateLabel ("F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.", 5, 5, 440, 95) $button1 = GUICtrlCreateButton("OK", 185, 102, 60, 20) ; Run the GUI until it is closed GUISetState() While 5 $msg = GUIGetMsg() Select Case $msg = $button1 GuiDelete($help_R) exitloop EndSelect WEnd EndIf EndFunc ;==>_F1D_Func Func _F1E_Func();Help in Request Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else $help_R = GUICreate("Help in Update Request view", 445, 130) GUISetBkColor (0xCCFFCC) GUICtrlCreateLabel ("F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.", 5, 5, 440, 95) $button1 = GUICtrlCreateButton("OK", 185, 102, 60, 20) ; Run the GUI until it is closed GUISetState() While 6 $msg = GUIGetMsg() Select Case $msg = $button1 GuiDelete($help_R) exitloop EndSelect WEnd EndIf EndFunc ;==>_F1E_Func Func _F1F_Func();Help in Update Problem view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else $help_R = GUICreate("Help in Update Problem view", 445, 130) GUISetBkColor (0xCCFFCC) GUICtrlCreateLabel ("F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.", 5, 5, 440, 95) $button1 = GUICtrlCreateButton("OK", 185, 102, 60, 20) ; Run the GUI until it is closed GUISetState() While 7 $msg = GUIGetMsg() Select Case $msg = $button1 GuiDelete($help_R) exitloop EndSelect WEnd EndIf EndFunc ;==>_F1F_Func Func _F1G_Func();Help in main window view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else $help_R = GUICreate("Help in Main Window view", 445, 130) GUISetBkColor (0xFFC1C1) GUICtrlCreateLabel ("F1= Opens a help file showing the functions." & @CRLF _ & "F2= Search Request: This will search for Request tickets in a predefined bucket." & @CRLF _ & "F3= Search Incident: This will search for Incidents tickets in a predefined bucket." & @CRLF _ & "F5= Refresh: This will refresh the current list of tickets that are listed." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "F8= Logout: This will log you out of Unicenter", 5, 5, 440, 95) $button1 = GUICtrlCreateButton("OK", 185, 102, 60, 20) ; Run the GUI until it is closed GUISetState() While 8 $msg = GUIGetMsg() Select Case $msg = $button1 GuiDelete($help_R) exitloop EndSelect WEnd EndIf EndFunc ;==>_F1G_Func ;--------------------------------- ;F2 Section: Search Request Func _F2_Func(); Search Request If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Run("request.exe", "") ; MsgBox(0 + 64, "Request", "Button for search request pushed") ;dummy control for testing BlockInput(0) EndIf EndFunc ;==>_F2_Func ;---------------------------------- ;F3 Section ; F3A: Resolution field ; F3B: Search Incident Func _F3A_Func(); Resolution field If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "Resolution", "Button for Resolution pushed") ;dummy control for testing BlockInput(1) Send("!d") WinWaitActive("Update Request - Unicenter ServicePlus Service Desk", "") Send("!9") BlockInput(0) EndIf EndFunc ;==>_F3A_Func Func _F3B_Func(); Search Incident If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "Incident", "Button for search Incident pushed") ;dummy control for testing BlockInput(1) Run("incident.exe", "") BlockInput(0) EndIf EndFunc ;==>_F3B_Func ;F4 Section Func _F4_Func(); TreePaste If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "TreePaste", "Button for TreePaste pushed") ;dummy control for testing BlockInput(1) Send("^a") Sleep(50) Send("{DEL}") Sleep(50) BlockInput(0) RunWait("treepaste.exe", "") BlockInput(1) Sleep(500) Send("^v") BlockInput(0) EndIf EndFunc ;==>_F4_Func ;F5 Section ; F5A: Refresh TIcket ; F5B: Refresh List Func _F5A_Func(); Refresh Ticket If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "Refresh ticket", "Button for REFRESH TICKET pushed") ;dummy control for testing BlockInput(1) Send("!v") Sleep(20) Send("!e") BlockInput(0) EndIf EndFunc ;==>_F5A_Func Func _F5B_Func(); Refresh Querry If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "Refresh Querry", "Button for Refresh Querry pushed") ;dummy control for testing BlockInput(1) Send("!v") Sleep(20) Send("!f") BlockInput(0) EndIf EndFunc ;==>_F5B_Func ;F6 Section Func _F6_Func(); QuickPaste If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "QuickPaste", "Button for QuickPaste pushed") ;dummy control for testing RunWait("quickpaste2_0.exe", "") EndIf EndFunc ;==>key6 ;F7 Section Func _F7_Func(); Close Ticket If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "Close Ticket", "Button for Close Ticket pushed") ;dummy control for testing If FileExists("ct.flg") Then RunWait("closeticket.exe", "") Else MsgBox(0 + 48, "Change ticket status to close", "This function is currently turned off. You will need to use the F9 key to enable this function") EndIf EndIf EndFunc ;==>_F7_Func ;F8 Section Func _F8_Func(); Close Unicenter If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "Close UNPlus", "Button for Close UNPlus pushed") ;dummy control for testing BlockInput(1) Send("!u") Send("!e") BlockInput(0) Exit EndIf EndFunc ;==>_F8_Func ;F9 Section Func _F9_Func(); CTFS If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "SwitchF7", "Button for SwitchF7 pushed") ;dummy control for testing RunWait("switchF7.exe", "") EndIf EndFunc ;==>_F9_Func Func _key1_Func(); Closes UNPlus If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "Exit", "Button for Exit pushed") ;dummy control for testing ; HotKeySet("^!x") Exit EndIf EndFunc ;==>_key1_Func Func _key2_Func(); Print tickets If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else ; MsgBox(0 + 64, "Print", "Button for printing ticket pushed") ;dummy control for testing BlockInput(1) Run("print.exe", "") BlockInput(0) EndIf EndFunc ;==>_key2_Func Func _key_clean_1();Releases hotsetkeys HotKeySet("{F1}"); turns help off HotKeySet("{F2}"); turns Request off HotKeySet("{F3}"); turns Resolution / incident off HotKeySet("{F4}"); turns TreePaste off HotKeySet("{F5}"); turns refresh off HotKeySet("{F7}"); turns close ticket off HotKeySet("{F9}"); turns CTFS off HotKeySet("{PRINTSCREEN}"); Turns Print ticket off EndFunc ;==>_key_clean_1 The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GaryFrost Posted December 6, 2005 Share Posted December 6, 2005 just put a short sleep below your While 1 example While 1 Sleep ( 50 ) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Bert Posted December 6, 2005 Author Share Posted December 6, 2005 (edited) I did a sleep(50) like you suggested. It dropped to 14. Changed it to sleep(100), and that dropped it to 2-3. I can live with that, but I now have a concern with the user hitting the key too fast, and it not working. Am I right to think this, or when the window becomes actve, the script will pause anyway, and the problem won't occure? edit: I think it won't occure, for the window will be active, and then the script would make the key active. I'm still not completely happy with the processor time, (for the code is only 477 lines in it. I thought using a while statement wasn't supposed to do that) Edited December 7, 2005 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
herewasplato Posted December 7, 2005 Share Posted December 7, 2005 A loop like this in a test script on my system:While 1WEndwill eat up the CPU... adding a sleep of 10 milliseconds makes it show 0% in task manager... (on my system)If just one of your windows is active, the script should halt on the WinWaitNotActive statement.Per the help file for WinWaitNotActive:"The script polls for a window match every 250 milliseconds or so."For all practical purposes, that "250" should not register as CPU usage on most systems.BTW, I use a "Do/Sleep(50)/Until" loop like I suggested in your other post on this script to avoid/control that polling rate.If you bring up task manager's processes tab to the foreground, then your script should be looping thru the If/Endif lines inside that while/sleep(50)/wend loop... is that how you are determining the CPU usage?The only way that I can think of to reduce the CPU usage more (besides increasing the sleep) is to use the layout that I suggested here: http://www.autoitscript.com/forum/index.ph...35entry128935I cannot imagine that the overhead would drop all that much, but the help file does say this:"This version of the If statement is used to execute a single statement without the overhead of an EndIf."later... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Bert Posted December 7, 2005 Author Share Posted December 7, 2005 I'm going to give this a try today. Thanks! The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted December 7, 2005 Author Share Posted December 7, 2005 I rearranged my program using what you suggested, and that did the trick. Thanks! The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now