HockeyFan Posted December 15, 2008 Share Posted December 15, 2008 (edited) I created this script to help monitor when the "Start Menu" is activated so that it can be closed automatically. When I test the script, I notice that the CPU is right at 50% utilization...and 8% when not run. Can someone explain to me what part of the script is causing this? Thanks! $FullName = GetFullName(@UserName) AdlibEnable("StartMenu",500) While 1 WEnd Exit Func GetFullName($sUserName) $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Name = '" & $sUserName & "'", "WQL", 0x10 + 0x20) If IsObj($colItems) then For $objItem In $colItems Return $objItem.FullName Next Else Return SetError(1,0,"") Endif EndFunc Func StartMenu() $StartMenu = WinExists("Start Menu", $FullName) If $StartMenu = 1 Then Send("{LWIN}") Else Return EndIf EndFunc Edited December 15, 2008 by HockeyFan Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 15, 2008 Share Posted December 15, 2008 You don't have any sleep. By your processor being at 50%, I can also tell you have a dual core or two processors. Link to comment Share on other sites More sharing options...
jaberwacky Posted December 15, 2008 Share Posted December 15, 2008 I just placed a SLeep( 100 ) within the While 1 statement. That seems to have done it for me. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 15, 2008 Share Posted December 15, 2008 That's all it needed. Link to comment Share on other sites More sharing options...
jaberwacky Posted December 15, 2008 Share Posted December 15, 2008 Now, as for why it continuously makes my start menu come and go, who knows? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
HockeyFan Posted December 15, 2008 Author Share Posted December 15, 2008 You don't have any sleep. By your processor being at 50%, I can also tell you have a dual core or two processors.WOW! That was simple...thanks! What was asleep was me!! Thanks for your help. Link to comment Share on other sites More sharing options...
HockeyFan Posted December 15, 2008 Author Share Posted December 15, 2008 I just placed a SLeep( 100 ) within the While 1 statement. That seems to have done it for me. Thanks!! Link to comment Share on other sites More sharing options...
jaberwacky Posted December 15, 2008 Share Posted December 15, 2008 (edited) OK, changed a couple of things after doing some forum searching and tinkering. HotKeySet( "{ESC}" , "terminate" ) While 1 Sleep( 500 ) If WinExists("Start Menu") = 1 Then WinClose("Start Menu") EndIf WEnd Exit Func terminate() EXIT EndFunc I guess that you could always make a bot in AutoIt that will select a certain program to open from the startmenu before your program has a chance to close the menu. EDIT: No that still doesn't work. Supposedly "If WinExists("Start Menu") = 1 Then" always reports a '1' for some reason and so the window is being closed all of the time no matter what. Edited December 15, 2008 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 15, 2008 Share Posted December 15, 2008 Many programs will just hide windows instead of destroy them. It's much more resource efficient. 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