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.

Force app to open, or move, to 2nd display?

If you have a question or need help, this is the place to be.
Post Reply
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Force app to open, or move, to 2nd display?

Post by Livin »

I'd like to have specific apps open directly on my 2nd display... or, when it detects the display becomes active, move the app to it.

Anyone have python code to do this? It would make for a nice plugin ;)

closest thing I found has been...

Code: Select all

# Copyright 2010, Trent Nelson ([email protected]).
# $Id: fix-window-placements.py 6 2010-08-10 09:58:58Z Trent $
from win32gui import (
SetFocus,
MoveWindow,
EnumWindows,
GetClassName,
GetWindowRect,
GetWindowText,
IsWindowEnabled,
IsWindowVisible,
GetDesktopWindow,
GetWindowPlacement,
)
from ctypes import (
windll,
c-int,
c-long,
c-ulong,
c-double,
POINTER,
Structure,
WINFUNCTYPE,
)
class RECT(Structure):
-fields- = [
('left', c-long),
('top', c-long),
('right', c-long),
('bottom', c-long)
]
def dump(self):
return map(int, (self.left, self.top, self.right, self.bottom))
MonitorEnumProc = WINFUNCTYPE(c-int, c-ulong, c-ulong, POINTER(RECT),
c-double)
def enum-display-monitors():
results = []
def -callback(monitor, dc, rect, data):
results.append(rect.contents.dump())
return 1
callback = MonitorEnumProc(-callback)
temp = windll.user32.EnumDisplayMonitors(0, 0, callback, 0)
return results
def get-desktop-area():
left = top = right = bottom = 0
for r in enum-display-monitors():
if r[0] < left:
left = r[0]
if r[1] < top:
top = r[0]
if r[2] right = r[2]
if r[3] bottom = r[3]
return (left, top, right, bottom)
def inside-desktop(hwnd):
desktop = get-desktop-area()
rect = GetWindowPlacement(hwnd)[4]
return (
rect[0] rect[1] rect[2] 
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: Force app to open, or move, to 2nd display?

Post by Pako »

Once I answered a similar theme, but the author of the original request did not bother to respond somehow.
I think it's strange, even if my solution is not good.
Pako
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: Force app to open, or move, to 2nd display?

Post by Livin »

no disrespect meant... I honestly did not even see it. I've been crazy traveling for work, and taking care of my 1 yr old when I'm home - forgot I even posted that!

I will check it out now and let you know how it works for me... many thanks!
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