Threap Posted March 30, 2009 Share Posted March 30, 2009 Hello Forum Users,Long time lurker here, making my first post. I searched the forums before posting, so forgive me if this question has already been answered!In one of my scripts, I need to display the Windows Task Manager, set it to the "Performance" tab, and put the window into "borderless" mode (removing the window frame/decorations). The latter is what's giving me most trouble. In theory it can be done by simply double-clicking on the CPU load graph or in other places in the window; in practice, this is very unreliable when done from a script!Here's a simplified version of my code. I've highlighted the bit that gives the problems: ;Display task manager. Wait for a window with its CLASSID to appear, then activate it.ShellExecute("Taskmgr.exe")WinWait("[CLASS:#32770]")WinActivate("[CLASS:#32770]");Now switch to Performance tab... send TabRight messages to the SysTab control until the appropriate text is visibleWhile (Not(WinGetText("[CLASS:#32770]","CPU Usage History"))) ControlCommand ("[CLASS:#32770]", "", "[CLASS:SysTabControl32; INSTANCE:1]", "TabRight")WEnd ; yes, I know this loop might never end if something goes wrong. Not my main problem ; now, set Task Manager to "no window border" modeWhile (WinGetText("[CLASS:#32770]","Handles")) ; this is text that is ONLY visible in "frame" mode - disappears in borderless mode! $winpos = WinGetPos("[CLASS:#32770]") MouseClick ("left",$winpos[0]+20,$winpos[1]+90,2,0) ; the (20,90) co-ords relative to window have been chosen to work under XP & Vista Sleep(100)Wend ; the mouse double-click doesn't always work - so we loop, doing it until successThe above code works (pretty reliably) on XP, but fails frequently on Vista and Windows 7 (yes, I know W7 is pre-release at this point but the Task Manager code seems identical to Vista). The failure mode is that it just sits there in the final While() loop, sending mouseclicks that never work.Frankly, clicking on windows and sending control commands doesn't seem like the neatest way of doing this. I've had great success with using COM elsewhere in the script, and I wonder if that's the solution here?Can anyone suggest a way to access TaskMgr.exe via COM and pass commands to it that way? I've googled extensively trying to find COM API documentation for TaskMgr but no luck!Failing that, any suggestions for an alternative way to reliably accomplish this? (I can move this thread to another forum area if COM isn't the solution).Thanks for any help you can offer! Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 30, 2009 Share Posted March 30, 2009 I highly doubt there's any kind of COM interface for task manager. There's really no point in letting it be automated. What exactly do you need the "frameless" mode for? There's probably a better way to get that information. Link to comment Share on other sites More sharing options...
Threap Posted March 30, 2009 Author Share Posted March 30, 2009 I highly doubt there's any kind of COM interface for task manager. There's really no point in letting it be automated.What exactly do you need the "frameless" mode for? There's probably a better way to get that information.Thanks for the reply. I need the Frameless mode so that I can have the simple CPU usage/load graphs visible on the screen. Task Manager is the only solution that can be used for my purposes.I'll move this query to another forum, as COM seems to be a dead end. Link to comment Share on other sites More sharing options...
spudw2k Posted April 3, 2009 Share Posted April 3, 2009 Thanks for the reply. I need the Frameless mode so that I can have the simple CPU usage/load graphs visible on the screen. Task Manager is the only solution that can be used for my purposes. I'll move this query to another forum, as COM seems to be a dead end.Easy, cheap way ControlClick("Windows Task Manager","","#327701","left",2) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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