【问题标题】:Autohotkey macro to switch mouse position between multiple screensAutohotkey 宏可在多个屏幕之间切换鼠标位置
【发布时间】:2022-01-01 06:02:25
【问题描述】:

我只想把这个放在这里。 我需要一个将鼠标光标移动到另一台显示器的宏。 但在相同的相对位置上与屏幕分辨率成正比。 并且不会被困在边境。 并且在此过程中不单击任何内容。

Ctrl+MiddleMouseButton 现在将光标移动到下一个屏幕,并且应该适用于任意数量的屏幕和不同的分辨率。 不过,我只能用 2 个屏幕对其进行测试。

【问题讨论】:

    标签: autohotkey multiple-monitors


    【解决方案1】:
    ^MButton::
      SysGet, monitors, MonitorCount
    
      SysGet, MonitorCount, MonitorCount
      SysGet, MonitorPrimary, MonitorPrimary
      
      current := 0
      Loop, %MonitorCount%
      {
        SysGet, Monitor, Monitor, %A_Index%
        CoordMode, Mouse, Screen
        MouseGetPos, MouseX, MouseY
        if (  (MouseX >= MonitorLeft) && (MouseX < MonitorRight) && (MouseY >= MonitorTop) && (MouseY < MonitorBottom) )
        {
          current := A_Index
          currentRX := (MouseX - MonitorLeft) / (MonitorRight - MonitorLeft)
          currentRY := (MouseY - MonitorTop) / (MonitorBottom - MonitorTop)
          break
        }
      }
      next := current + 1
      
      if (next > MonitorCount)
        next := 1
      SysGet, Monitor, Monitor, %next%
      
      newX := MonitorLeft + currentRX*(MonitorRight - MonitorLeft)
      newY := MonitorTop + currentRY*(MonitorBottom - MonitorTop)
      
      DllCall("SetCursorPos", "int", newX, "int", newY)
      DllCall("SetCursorPos", "int", newX, "int", newY)
    return
    

    【讨论】:

      【解决方案2】:

      如果你不关心光标保持它的相对位置而只是跳到下一个屏幕的中间,使用这个(在这个例子中是alt+middlemouse):

      !MButton::
        SysGet, monitors, MonitorCount
      
        SysGet, MonitorCount, MonitorCount
        SysGet, MonitorPrimary, MonitorPrimary
        
        current := 0
        Loop, %MonitorCount%
        {
          SysGet, Monitor, Monitor, %A_Index%
          CoordMode, Mouse, Screen
          MouseGetPos, MouseX, MouseY
          if (  (MouseX >= MonitorLeft) && (MouseX < MonitorRight) && (MouseY >= MonitorTop) && (MouseY < MonitorBottom) )
          {
            current := A_Index
            break
          }
        }
        next := current + 1
        if (next > MonitorCount)
          next := 1
      
        SysGet, Monitor, Monitor, %next%
        newX := MonitorLeft + 0.5*(MonitorRight - MonitorLeft)
        newY := MonitorTop + 0.5*(MonitorBottom - MonitorTop)
        
        DllCall("SetCursorPos", "int", newX, "int", newY)
        DllCall("SetCursorPos", "int", newX, "int", newY)
      return
      

      【讨论】:

        猜你喜欢
        • 2016-04-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-20
        • 1970-01-01
        • 2015-04-15
        • 1970-01-01
        相关资源
        最近更新 更多