Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

WindowState? If fullscreen do A. If not do B.

If you have a question or need help, this is the place to be.
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

WindowState? If fullscreen do A. If not do B.

Post by zian »

The title says it.

I'd like a script/macro that will look at the window size (full size/maximized or not) for XBMC, MPC, WMC etc. If the window is full screen it fires one macro. If it is not full screen it fires a different macro.

Btw...
Searched much couldn't find any results.

Thanks.
eventghost.net
Be there or be square.
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: WindowState? If fullscreen do A. If not do B.

Post by FCB38 »

Whowww! I'm so surprise that somebody have the same question!!!
I'm trying to do something without script but there is no solution.
I'm so exited, and I'm waiting for the solution.

Thank you for your help.
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: WindowState? If fullscreen do A. If not do B.

Post by FCB38 »

Hello,

I've got the same problem. Is there a solution? I'm really interesting by this.

Regards...
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: WindowState? If fullscreen do A. If not do B.

Post by FCB38 »

Hello,

Is there a problem with the forum? I try to answer to this post but nothing happen.
Can you explain to me?

Thank you.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: WindowState? If fullscreen do A. If not do B.

Post by Pako »

zian wrote:The title says it.
I'd like a script/macro that will look at the window size (full size/maximized or not) for XBMC, MPC, WMC etc. If the window is full screen it fires one macro. If it is not full screen it fires a different macro.
I know, why you got no answer.
On your question nobody knows the answer. There is no universal way.
I personally know only how it is with MPC-HC.
The answer you find, when you look at the code of MPC-HC plugin.

Pako
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Re: WindowState? If fullscreen do A. If not do B.

Post by zian »

On your question nobody knows the answer. There is no universal way.
I'm bummed.
Thanks for the info Pako.
eventghost.net
Be there or be square.
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: WindowState? If fullscreen do A. If not do B.

Post by Livin »

see if this will help...

http://pywinauto.sourceforge.net/

look into python's win32gui methods


also, I was thinking you might be able to get the window's dimensions and check it against the desktop resolutions... if they match, the app window should be full screen, if they don't it would not be :)


if you cannot find a way to do it in Python, you might be able to write a mini app to do it and pass the result back to Python...

http://www.daniweb.com/software-develop ... ads/202569
http://stackoverflow.com/questions/5531 ... ode-behind
http://pinvoke.net/default.aspx/Enums/S ... mmand.html
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: WindowState? If fullscreen do A. If not do B.

Post by Pako »

Right now, I just thought of something.
It is possible to reformulate the task as follows ?
If some window of some program is just full screen and is on top, do A, otherwise do B.
If so, then it would probably be possible to find universal solutions.
Otherwise, it is not possible, because for each program this window (= FullScreen) is called differently and the biggest problem is to find the name and class name of this window.

Pako
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: WindowState? If fullscreen do A. If not do B.

Post by FCB38 »

I'm really interested by this subject but I'm not programmer.
The problem is to big for me.
I hope that you'll find a solution.
Good luck.

Regards...
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: WindowState? If fullscreen do A. If not do B.

Post by Pako »

I found a solution:
FullScreen.png
FullScreen.png (7.97 KiB) Viewed 7375 times
Python Script:

Code: Select all

from win32gui import GetForegroundWindow, GetWindow, GetWindowRect
from win32api import EnumDisplayMonitors
GW_CHILD         = 5
GW_HWNDNEXT      = 2

def GetFullScreen():
    fullscreen = False
    mons = EnumDisplayMonitors()
    hwnd = GetForegroundWindow()
    rect = GetWindowRect(hwnd)
    for mon in mons:
        if rect == mon[2]:
            fullscreen = True
            break
    if not fullscreen: # maybe some child ?
        child = GetWindow(hwnd, GW_CHILD)
        while child > 0:
            childRect = GetWindowRect(child)
            for mon in mons:
                if childRect == mon[2]:
                    fullscreen = True
                    break
            if fullscreen:
                break
            child = GetWindow(child, GW_HWNDNEXT)
    return fullscreen

eg.result = GetFullScreen()
But I do not know if it will be reliable in practice and whether it will work in all cases that you need.
I tried only MPC-HC and WMP.

Pako
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: WindowState? If fullscreen do A. If not do B.

Post by FCB38 »

Hello,

I'm a novice, can you explain to me how to create the script? I create a *.txt file with the lines you give us and I save it to *.py?
This is this?
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: WindowState? If fullscreen do A. If not do B.

Post by Pako »

FCB38 wrote:I'm a novice, can you explain to me how to create the script? I create a *.txt file with the lines you give us and I save it to *.py?
This is this?
No, you need no *. py file.
You simply add to your configuration the action Python Script.
Once you put the action, opens a simple text editor.
There you paste (or write) a script and confirm OK.

Pako
Attachments
AddAction.png
AddAction.png (4.18 KiB) Viewed 7357 times
AddPythonScript.png
AddPythonScript.png (18.48 KiB) Viewed 7357 times
PythonScriptEditor.png
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: WindowState? If fullscreen do A. If not do B.

Post by FCB38 »

Hello,

It seems to work perfectly. Not with a window from the Windows Explorer; like I wanted.

Thank you very much.
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Re: WindowState? If fullscreen do A. If not do B.

Post by zian »

(((((Pako)))))

Works like a charm.
Thanks VERY much.

btw...
I use this so I can either A..."un-fullscreen" a window and then open up my docked magnify.exe
or
B... first close/exit magnify.exe and then do fullscreen (of XBMC - WMC - MPC-HC etc.)

I LOVE IT.
eventghost.net
Be there or be square.
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: WindowState? If fullscreen do A. If not do B.

Post by Livin »

Nice work Pako... that would make a nice plug-in *hint, hint* ;)
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Post Reply