English 中文(简体)
如何获得积极监测的宽度和高度?
原标题:How to get the width and height of the active monitor?
  • 时间:2023-10-03 19:36:54
  •  标签:
  • autohotkey
#singleinstance, force
#Warn, All, OutputDebug

space::
Gui HUD:New, +AlwaysOnTop +ToolWindow -Caption +HwndMainHwnd, hudWin
Gui HUD:Font,s14,Consolas
Gui, Add, Text,,% Clipboard
GuiControlGet, OutputVar, Pos, Static1
Gui HUD:Show

Return

以上是一份简单的方案,旨在显示我的记牌上目前的文本。 我只是利用它更多地了解全球倡议,这并非重要。 我似乎想看到的是,如何把全球倡议放在积极监测的中心而不是主要监测中心(我有3名监测员)。

根据<代码>A_ScreenWidth和A_ScreenH 8,,用于“初级”监测。 另见:SysGet,其主要内容是“犯罪”监测或监测。 2. 意思并不大。

我愿创建动态的<代码>x,y,width。 用于<代码>的数值 Gui HUD:Show sub charge. 这样,全球调查股将始终在积极窗口或主要重点监测器上进行监视。

另外,我还是由“初级”监测员来承担,任务区和起步县的监测工作是所提到的。

我非常粗略地、令人惊讶地找不到这一点。 我现在谈谈什么?

任何帮助都将受到高度赞赏。

问题回答

我的解决办法是使用<代码>MonitorGetCount和MonitorGet,以检查协调是否适合监测的界限。

(AHK v2) 申报辅助人员的职能:

ScreenUtil_GetMonitorInfoOfActiveWindow(&monitorIndex, &left, &top, &right, &bottom){
    WinGetPos(&mx, &my, &mw, &mh, "A")
    ScreenUtil_GetMonitorInfoAtPoint(mx + mw//2, my + mh//2, &monitorIndex, &left, &top, &right, &bottom)
}

ScreenUtil_GetMonitorInfoAtMousePointer(&monitorIndex, &left, &top, &right, &bottom){
    CoordMode "Mouse", "Screen"
    MouseGetPos(&mx, &my)
    ScreenUtil_GetMonitorInfoAtPoint(mx, my, &monitorIndex, &left, &top, &right, &bottom)
}

ScreenUtil_GetMonitorInfoAtPoint(x, y, &monitorIndex, &left, &top, &right, &bottom){
    loop MonitorGetCount(){
        MonitorGet(A_Index, &_left, &_top, &_right, &_bottom)
        if(_left <= x && x <= _right && _top <= y && y <= _bottom){
            monitorIndex := A_Index
            left := _left
            top := _top
            right := _right
            bottom := _bottom
            return
        }
    }
    throw Error("Cannot find a monitor that encloses the point!")
}

 

然后,视你如何界定“主动监测”:

  1. To get info of the monitor which the active window resides in:
ScreenUtil_GetMonitorInfoOfActiveWindow(&monitorIndex, &left, &top, &right, &bottom)
MsgBox("Width: " right - left "`nHeight: " bottom - top)
  1. To get info of the monitor which the mouse pointer resides in :
ScreenUtil_GetMonitorInfoAtMousePointer(&monitorIndex, &left, &top, &right, &bottom)
MsgBox("Width: " right - left "`nHeight: " bottom - top)

 


(测试综合文字)

#Requires AutoHotkey v2.0

!1::{
    ScreenUtil_GetMonitorInfoOfActiveWindow(&monitorIndex, &left, &top, &right, &bottom)
    MsgBox("Width: " right - left "`nHeight: " bottom - top)
}

!2::{
ScreenUtil_GetMonitorInfoAtMousePointer(&monitorIndex, &left, &top, &right, &bottom)
MsgBox("Width: " right - left "`nHeight: " bottom - top)
}

ScreenUtil_GetMonitorInfoOfActiveWindow(&monitorIndex, &left, &top, &right, &bottom){
    WinGetPos(&mx, &my, &mw, &mh, "A")
    ScreenUtil_GetMonitorInfoAtPoint(mx + mw//2, my + mh//2, &monitorIndex, &left, &top, &right, &bottom)
}

ScreenUtil_GetMonitorInfoAtMousePointer(&monitorIndex, &left, &top, &right, &bottom){
    CoordMode "Mouse", "Screen"
    MouseGetPos(&mx, &my)
    ScreenUtil_GetMonitorInfoAtPoint(mx, my, &monitorIndex, &left, &top, &right, &bottom)
}

ScreenUtil_GetMonitorInfoAtPoint(x, y, &monitorIndex, &left, &top, &right, &bottom){
    loop MonitorGetCount(){
        MonitorGet(A_Index, &_left, &_top, &_right, &_bottom)
        if(_left <= x && x <= _right && _top <= y && y <= _bottom){
            monitorIndex := A_Index
            left := _left
            top := _top
            right := _right
            bottom := _bottom
            return
        }
    }
    throw Error("Cannot find a monitor that encloses the point!")
}




相关问题
How do you control a .NET checkbox from AutoHotKey?

I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is not directly controllable in AutoHotKEy using "Control,...

How can I rename my visual studio taskbar button?

I often work with multiple checkouts of the same solution, but as they all have the same name, all the taskbar buttons appear the same. I would like to rename the taskbar buttons so I can identify ...

Run AutoHotkey script when screen locked?

I ve written a couple of scripts with AutoHotkey, but I notice they only work when a user is logged in and the screen isn t locked. I d like to schedule the script to run. Does anyone know if that ...

AutoHotKey key SEQUENCE, not just single-key hotkey

I m not stupid... really. How do you map a key SEQUENCE (ie: Ctrl + Q , F) in AutoHotKey. I ve got Ctrl + Q down: ^q:: I ve even got F: f:: The examples in the help files even show how to do two ...

Where is the source code for AutoScriptWriter

I am using autohotkey for test now but tired with modifying the "Sleep, 100" generated by autoscriptwriter. So I decided to get the source code and see if I can modify it a little bit to fit my needs ...

Holding down the left mouse button in AutoHotkey

I want a script where pressing F1 makes AutoHotkey hold down the left mouse button. I then want the script to release the mouse once I press the key again. How can I do that?

热门标签