How to check current active window is Desktop or not?

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Legend
Newbie
Posts: 10
Joined: Fri Apr 04, 2014 12:11 am

How to check current active window is Desktop or not?

Post by Legend » Sat Nov 08, 2014 8:36 am

I'm not sure whether its possible or not but is there a method to detect whether current active window is Desktop or not,

Eg.
1)Monitor active window
2)If active window is currently desktop then launch a program(process)/made the program(process/window) the active window if its currently running.

Thank you.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: How to check current active window is Desktop or not?

Post by Marcus Tettmar » Sat Nov 08, 2014 11:42 am

The Desktop has a window title of "Program Manager". So you can do:

Code: Select all

GetActiveWindow>title,x,y
If>title=Program Manager
  //Desktop is active
Else
  //Something else is active
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Legend
Newbie
Posts: 10
Joined: Fri Apr 04, 2014 12:11 am

Re: How to check current active window is Desktop or not?

Post by Legend » Sat Nov 08, 2014 12:11 pm

Thanks Marcus, the code works provided I click the desktop first. I use it like below

Code: Select all

Wait>5

GetActiveWindow>title,x,y
If>title=Program Manager
  //Desktop is active
  MessageModal>Desktop is Active.
Else
  //Something else is active
  MessageModal>Desktop is not Active.
Endif

I compiled it into exe, then run exe inside a folder, then minimise/close folder, I can see the desktop, but message desktop is not active will be display unless, I minimise/close folder, then click desktop, then I will get message desktop is active. :(

Is there a method, when I see the desktop in plain sight(screen), then launch whatever app or macro I want? :?:

Thank you.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: How to check current active window is Desktop or not?

Post by Marcus Tettmar » Sat Nov 08, 2014 12:14 pm

Err, of course. You said you want code that detects WHETHER the desktop is active or not.

The code doesn't MAKE it active, it tells you IF it is active.

Is that not what you want?

If you want to MAKE it active then use SetFocus.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Legend
Newbie
Posts: 10
Joined: Fri Apr 04, 2014 12:11 am

Re: How to check current active window is Desktop or not?

Post by Legend » Sat Nov 08, 2014 1:04 pm

Sorry, my mistake, I thought making it active is what I want, I'm wrong as usual. :(

Initially, I thought detecting the active desktop window will do but I was wrong, when I saw the desktop on screen, it doesn't mean its active or not, so I'm wrong, sorry. :(

So, actually, what I'm trying to achieve is when, I can see the desktop on screen(in plain sight) irregardless whether its active or not, launch a macro or program I specify.

So the right method below is eg.

1) Saw the destkop on screen(whether its active window or not, doesnt matter).
2) Launch the a program I specify.

Any ideas?

Thanks.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts