【问题标题】:Make second monitor go fullscreen with AHK使用 AHK 使第二台显示器全屏显示
【发布时间】:2014-09-27 20:06:25
【问题描述】:

我有这个 Autohotkeys 脚本,我需要帮助。通过按 win+b,窗口将移动另一个监视器,在本例中为监视器 2。我希望每当它进入监视器 2 时,也可以使用键盘快捷键 f11 将其全屏显示,然后在发送回监视器 1 时将其从全屏中取出,然后将其扔掉。这可能吗?这就是我现在所拥有的。

SysGet, Mon1, Monitor, 1
SysGet, Mon2, Monitor, 2

#b::
winget,windowtomove,id,A    ;move active window
gosub windowmove
return

windowmove:
if not mon2left
return
wingetpos,x1,y1,w1,h1,ahk_id %windowtomove%
winget,winstate,minmax,ahk_id %windowtomove%
m1:=(x1+w1/2>mon1left) and (x1+w1/2<mon1right) and (y1+h1/2>mon1top) and (y1+h1/2<mon1bottom) ? 1:2   ;works out if centre of window is on monitor 1 (m1=1) or monitor 2 (m1=2)
m2:=m1=1 ? 2:1  ;m2 is the monitor the window will be moved to
ratiox:=abs(mon%m1%right-mon%m1%left)-w1<5 ? 0:abs((x1-mon%m1%left)/(abs(mon%m1%right-mon%m1%left)-w1))  ;where the window fits on x axis
ratioy:=abs(mon%m1%bottom-mon%m1%top)-h1<5 ? 0:abs((y1-mon%m1%top)/(abs(mon%m1%bottom-mon%m1%top)-h1))   ;where the window fits on y axis
x2:=mon%m2%left+ratiox*(abs(mon%m2%right-mon%m2%left)-w1)   ;where the window will fit on x axis in normal situation
y2:=mon%m2%top+ratioy*(abs(mon%m2%bottom-mon%m2%top)-h1)
w2:=w1   
h2:=h1   ;width and height will stay the same when moving unless reason not to lower in script

if abs(mon%m1%right-mon%m1%left)-w1<5 or abs(mon%m2%right-mon%m2%left-w1)<5   ;if x axis takes up whole axis OR won't fit on new screen
   {
   x2:=mon%m2%left   
   w2:=abs(mon%m2%right-mon%m2%left)
   }
if abs(mon%m1%bottom-mon%m1%top)-h1<5 or abs(mon%m2%bottom-mon%m2%top)-h1<5
   {
   y2:=mon%m2%top
   h2:=abs(mon%m2%bottom-mon%m2%top)
   }
if winstate   ;move maximized window
   {
   winrestore,ahk_id %windowtomove%
   winmove,ahk_id %windowtomove%,,mon%m2%left,mon%m2%top
   winmaximize,ahk_id %windowtomove%
   }
else
   {
   if (x1<mon%m1%left)
      x2:=mon%m2%left   ;adjustments for windows that are not fully on the initial monitor (m1)
   if (x1+w1>mon%m1%right)
      x2:=mon%m2%right-w2
   if (y1<mon%m1%top)
      y2:=mon%m2%top
   if (y1+h1>mon%m1%bottom)
      y2:=mon%m2%bottom-h2
   winmove,ahk_id %windowtomove%,,x2,y2,w2,h2   ;move non-maximized window
   }
return

感谢您的任何帮助!

【问题讨论】:

    标签: keyboard-shortcuts autohotkey keyboard-events


    【解决方案1】:

    确实有可能,给你:

    sysGet, d2, monitor, 2
    #ifWinActive ahk_class Chrome_WidgetWin_1
    #b::
        winGetPos, cx, cy, a
        winGet, style, style
        if !(style & 0xC00000)
            send {f11}
        send {blind}+#{right}
        if !(((cx >= d2Left && cx <= d2Right) or (cx >= d2Right && cx <= d2Left)) and ((cy >= d2Top && cy <= d2Bottom) or (cy >= d2Bottom && cy <= d2Top)))
            send {f11}
    return
    

    【讨论】:

    • 朋友,你是救生员,感谢你的帮助!
    • 当窗口不在第二个显示屏上时,您不会碰巧知道是否有办法在第二个显示屏上没有触摸输入,对吗?
    • 你是Win7还是8?
    • 我将为其构建的应用程序将用于 Windows 7。
    • 不幸的是,这不起作用,我找到了一种方法来禁用触摸输入,进入控制面板 > 笔和触摸 > 触摸 > 然后启用/禁用“将手指用作输入设备”。是否有可能将这个功能与 autohotkey 一起使用?
    猜你喜欢
    • 1970-01-01
    • 2012-11-12
    • 1970-01-01
    • 1970-01-01
    • 2014-04-30
    • 2012-05-27
    • 2015-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多