Jump to content

Windows Task Manager into "Frameless" mode?


Threap
 Share

Recommended Posts

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 visible

While (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 :D

; now, set Task Manager to "no window border" mode

While (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 success

The 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

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

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)
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...