Posts: 13
Threads: 3
Joined: Mar 2006
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
;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
Posts: 12,140
Threads: 142
Joined: Dec 2002
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
;/
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
Posts: 13
Threads: 3
Joined: Mar 2006
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
Posts: 1,769
Threads: 410
Joined: Feb 2003
yeah, this works great!
the '0.15' is a good add too.
Posts: 331
Threads: 60
Joined: May 2006
wow i really love this macro 
Posts: 331
Threads: 60
Joined: May 2006
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.
Posts: 331
Threads: 60
Joined: May 2006
Also I was having a problem with GetFirstWindowInMonitor bring up windows that were minimized, here is the fix for that.
Function ( GetFirstWindowInMonitor )
;/;
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
Posts: 12,140
Threads: 142
Joined: Dec 2002
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.
Posts: 331
Threads: 60
Joined: May 2006
|