Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dual Monitors - window becomes active when mouse is in monit
#1
I have dual monitors and am always getting caught when moving between them with typing because I did not click in the new window on the other monitor first. Now I know I can just click and have windows make that app active, but why not just have QM make the top window active when the mouse shows up in that monitor.

I have tried using

Code:
Copy      Help
;Get mouse pointer position on Screen position
int px(xm)
out px
if px <= 1224
,act ;;win(100 500)
else
,act ;;win(250 1500)

It will work if the right screen is active and I place the mouse in the left screen and then invoke the macro - but cannot figure the logic to make it work the other way or once I did I would then have no idea on how to have the macro loop each time I changed screens so it would still run when I went back to the other screen.

Any of your programming guru's have any thoughts on this?

Thanks

carl
#2
Code:
Copy      Help
int mon pmon
rep
,1
,POINT p; xm p
,mon=MonitorFromPoint(p MONITOR_DEFAULTTONULL)
,if(mon=pmon or !mon) continue
,if(pmon)
,,;mouse moved into another monitor
,,;out mon
,,int h=win
,,if(MonitorFromWindow(h MONITOR_DEFAULTTONULL)!=mon and h!=win(mouse))
,,,;out 1
,,,ifk((1)) continue ;;maybe moving a window
,,,h=GetFirstWindowInMonitor(h mon)
,,,if(h) act h
,pmon=mon
,

Function GetFirstWindowInMonitor
Code:
Copy      Help
;/
function# h mon

;Simplified.

rep
,h=GetWindow(h iif(h GW_HWNDNEXT GW_HWNDFIRST)); if(!h) break
,if(MonitorFromWindow(h MONITOR_DEFAULTTONULL)!=mon) continue
,if(!IsWindowVisible(h) or !IsWindowEnabled(h)) continue
,if(GetWindow(h GW_OWNER) or GetWinStyle(h 1)&WS_EX_TOOLWINDOW) continue
,ret h
#3
G - this works just fabulous, both entered, converted to functions, first one added to my init2, cut the delay to 0.15 and BAM! exactly what the doctor ordered.

Thanks very much for your prompt reply as I NEVER would have figured that out on my own (as witnessed by where I was when I posted).

Carl
#4
yeah, this works great!
the '0.15' is a good add too.
An old blog on QM coding and automation.

The Macro Hook
#5

wow i really love this macro Big Grin
#6

I think this question is along the same lines....

I have icons on my desktop on monitor (2) and when I use them the new window they make will come up on monitor (1), is there a way to have new windows come up on monitor (2) when the mouse is on monitor (2).

If so maybe you could put it together with the above macro.

Thanks.
#7

Also I was having a problem with GetFirstWindowInMonitor bring up windows that were minimized, here is the fix for that.


Function ( GetFirstWindowInMonitor )
Code:
Copy      Help
;/;
function# h mon

;Simplified.

rep
,h=GetWindow(h iif(h GW_HWNDNEXT GW_HWNDFIRST)); if(!h) break
,if(MonitorFromWindow(h MONITOR_DEFAULTTONULL)!=mon) continue
,if(!IsWindowVisible(h) or !IsWindowEnabled(h) or (min(h)=1)) continue ;;or (min(h)=1)
,if(GetWindow(h GW_OWNER) or GetWinStyle(h 1)&WS_EX_TOOLWINDOW) continue
,ret h
#8
Next QM version (2.2.1.4, next week) will have a function to move a window to a monitor. Then you can assign window trigger... It will be function MoveWindowTo of Monitor class.
#9

Thanks, Gintaras.


Forum Jump:


Users browsing this thread: 1 Guest(s)