; -------------------------- Run as Administrator --------------------------
full_command_line := DllCall("GetCommandLine", "str")
If not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
Try
{
If A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
Else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
; ------------------------------------------------------------------------------
/*
使用说明:
1、F1获取当前鼠标所指信息
2、上下左右光标移动鼠标,并获取当前鼠标所指信息
3、全部信息存到剪贴板,方便ctrl+v粘贴
4、LIB中需有GDIP_ALL.ahk、BTT.ahk(https://github.com/marius-sucan/AHK-GDIp-Library-Compilation)
5、LIB中需有BTT.ahk(https://github.com/telppa)
*/
; ------------------------------------------------------------------------------
Msgbox,
(`
使用说明:
1、F1获取当前鼠标所指信息
2、上下左右光标移动鼠标,并获取当前鼠标所指信息
3、全部信息存到剪贴板,方便ctrl+v粘贴
4、LIB中需有GDIP_ALL.ahk、BTT.ahk(https://github.com/marius-sucan/AHK-GDIp-Library-Compilation)
5、LIB中需有BTT.ahk(https://github.com/telppa)
)
#NoEnv
SetWorkingDir %A_ScriptDir%
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
DetectHiddenWindows, On
#WinActivateForce
SetControlDelay -1
SetWinDelay -1
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
#UseHook
#Persistent
Process , Priority, , High
F1::
MouseCoorMode:="Screen"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Screenx, Screeny, ID
WinActivate, ahk_id %ID%
MouseGetPos, Screenx, Screeny, ID
MouseCoorMode:="Window"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Windowx, Windowy, ID
MouseCoorMode:="Client"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Clientx, Clienty, ID
WinGet, PID, pid, ahk_id %ID%
WinGetTitle, Title, ahk_id %ID%
WinGetText, Text, ahk_id %ID%
WinGetClass, ClassName, ahk_id %ID%
WinGetPos, WinX, WinY, WinW, WinH, ahk_id %ID%
SysGet, Mon1, Monitor , 1
SysGet, Mon2, Monitor , 2
CoordMode, Pixel, Screen
PixelGetColor, ColorRGB, Screenx, Screeny, RGB
;===========================================================================================
showtext=
(`
坐标: %Screenx% , %Screeny% (Screen)
坐标: %Windowx% , %Windowy% (Window)
坐标: %Clientx% , %Clienty% (Client)
颜色: %ColorRGB% (RGB)
ID: %ID%
PID: %PID%
Title: %Title%
Text: %Text%
Class:%ClassName%
WinXY:%WinX% , %WinY% , %WinW% , %WinH%
Mon1:%Mon1Left% , %Mon1Top% , %Mon1Right% , %Mon1Bottom%
Mon2:%Mon2Left% , %Mon2Top% , %Mon2Right% , %Mon2Bottom%
)
;===========================================================================================
Clipboard:= showtext
BTT(showtext,Screenx+20,Screeny+20,,,{CoordMode:"Screen"})
Draw()
Return
Up::
MouseCoorMode:="Screen"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Screenx, Screeny, ID
WinActivate, ahk_id %ID%
MouseGetPos, Screenx, Screeny, ID
Screeny:=Screeny-1
MouseMove, Screenx, Screeny, 0
MouseCoorMode:="Window"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Windowx, Windowy, ID
MouseCoorMode:="Client"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Clientx, Clienty, ID
WinGet, PID, pid, ahk_id %ID%
WinGetTitle, Title, ahk_id %ID%
WinGetText, Text, ahk_id %ID%
WinGetClass, ClassName, ahk_id %ID%
WinGetPos, WinX, WinY, WinW, WinH, ahk_id %ID%
SysGet, Mon1, Monitor , 1
SysGet, Mon2, Monitor , 2
CoordMode, Pixel, Screen
PixelGetColor, ColorRGB, Screenx, Screeny, RGB
;===========================================================================================
showtext=
(`
坐标: %Screenx% , %Screeny% (Screen)
坐标: %Windowx% , %Windowy% (Window)
坐标: %Clientx% , %Clienty% (Client)
颜色: %ColorRGB% (RGB)
ID: %ID%
PID: %PID%
Title: %Title%
Text: %Text%
Class:%ClassName%
WinXY:%WinX% , %WinY% , %WinW% , %WinH%
Mon1:%Mon1Left% , %Mon1Top% , %Mon1Right% , %Mon1Bottom%
Mon2:%Mon2Left% , %Mon2Top% , %Mon2Right% , %Mon2Bottom%
)
;===========================================================================================
Clipboard:= showtext
BTT(showtext,Screenx+20,Screeny+20,,,{CoordMode:"Screen"})
Draw()
Return
Down::
MouseCoorMode:="Screen"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Screenx, Screeny, ID
WinActivate, ahk_id %ID%
MouseGetPos, Screenx, Screeny, ID
Screeny:=Screeny+1
MouseMove, Screenx, Screeny, 0
MouseCoorMode:="Window"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Windowx, Windowy, ID
MouseCoorMode:="Client"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Clientx, Clienty, ID
WinGet, PID, pid, ahk_id %ID%
WinGetTitle, Title, ahk_id %ID%
WinGetText, Text, ahk_id %ID%
WinGetClass, ClassName, ahk_id %ID%
WinGetPos, WinX, WinY, WinW, WinH, ahk_id %ID%
SysGet, Mon1, Monitor , 1
SysGet, Mon2, Monitor , 2
CoordMode, Pixel, Screen
PixelGetColor, ColorRGB, Screenx, Screeny, RGB
;===========================================================================================
showtext=
(`
坐标: %Screenx% , %Screeny% (Screen)
坐标: %Windowx% , %Windowy% (Window)
坐标: %Clientx% , %Clienty% (Client)
颜色: %ColorRGB% (RGB)
ID: %ID%
PID: %PID%
Title: %Title%
Text: %Text%
Class:%ClassName%
WinXY:%WinX% , %WinY% , %WinW% , %WinH%
Mon1:%Mon1Left% , %Mon1Top% , %Mon1Right% , %Mon1Bottom%
Mon2:%Mon2Left% , %Mon2Top% , %Mon2Right% , %Mon2Bottom%
)
;===========================================================================================
Clipboard:= showtext
BTT(showtext,Screenx+20,Screeny+20,,,{CoordMode:"Screen"})
Draw()
Return
Left::
MouseCoorMode:="Screen"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Screenx, Screeny, ID
WinActivate, ahk_id %ID%
MouseGetPos, Screenx, Screeny, ID
Screenx:=Screenx-1
MouseMove, Screenx, Screeny, 0
MouseCoorMode:="Window"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Windowx, Windowy, ID
MouseCoorMode:="Client"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Clientx, Clienty, ID
WinGet, PID, pid, ahk_id %ID%
WinGetTitle, Title, ahk_id %ID%
WinGetText, Text, ahk_id %ID%
WinGetClass, ClassName, ahk_id %ID%
WinGetPos, WinX, WinY, WinW, WinH, ahk_id %ID%
SysGet, Mon1, Monitor , 1
SysGet, Mon2, Monitor , 2
CoordMode, Pixel, Screen
PixelGetColor, ColorRGB, Screenx, Screeny, RGB
;===========================================================================================
showtext=
(`
坐标: %Screenx% , %Screeny% (Screen)
坐标: %Windowx% , %Windowy% (Window)
坐标: %Clientx% , %Clienty% (Client)
颜色: %ColorRGB% (RGB)
ID: %ID%
PID: %PID%
Title: %Title%
Text: %Text%
Class:%ClassName%
WinXY:%WinX% , %WinY% , %WinW% , %WinH%
Mon1:%Mon1Left% , %Mon1Top% , %Mon1Right% , %Mon1Bottom%
Mon2:%Mon2Left% , %Mon2Top% , %Mon2Right% , %Mon2Bottom%
)
;===========================================================================================
Clipboard:= showtext
BTT(showtext,Screenx+20,Screeny+20,,,{CoordMode:"Screen"})
Draw()
Return
Right::
MouseCoorMode:="Screen"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Screenx, Screeny, ID
WinActivate, ahk_id %ID%
MouseGetPos, Screenx, Screeny, ID
Screenx:=Screenx+1
MouseMove, Screenx, Screeny, 0
MouseCoorMode:="Window"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Windowx, Windowy, ID
MouseCoorMode:="Client"
CoordMode, Mouse, %MouseCoorMode%
MouseGetPos, Clientx, Clienty, ID
WinGet, PID, pid, ahk_id %ID%
WinGetTitle, Title, ahk_id %ID%
WinGetText, Text, ahk_id %ID%
WinGetClass, ClassName, ahk_id %ID%
WinGetPos, WinX, WinY, WinW, WinH, ahk_id %ID%
SysGet, Mon1, Monitor , 1
SysGet, Mon2, Monitor , 2
CoordMode, Pixel, Screen
PixelGetColor, ColorRGB, Screenx, Screeny, RGB
;===========================================================================================
showtext=
(`
坐标: %Screenx% , %Screeny% (Screen)
坐标: %Windowx% , %Windowy% (Window)
坐标: %Clientx% , %Clienty% (Client)
颜色: %ColorRGB% (RGB)
ID: %ID%
PID: %PID%
Title: %Title%
Text: %Text%
Class:%ClassName%
WinXY:%WinX% , %WinY% , %WinW% , %WinH%
Mon1:%Mon1Left% , %Mon1Top% , %Mon1Right% , %Mon1Bottom%
Mon2:%Mon2Left% , %Mon2Top% , %Mon2Right% , %Mon2Bottom%
)
;===========================================================================================
Clipboard:= showtext
BTT(showtext,Screenx+20,Screeny+20,,,{CoordMode:"Screen"})
Draw()
Return
F8::
Clipboard:=text
ExitApp
return
Draw()
{
global Screenx
global Screeny
global ColorRGB
StringRight, ColorRGBAfter, ColorRGB, 6
StringLeft, ColorRGBBefor, ColorRGB, 2
ColorRGB:= ColorRGBBefor "ff" ColorRGBAfter
;msgbox,%ColorRGB%
SysGet, Mon1, Monitor, 1
pToken := Gdip_Startup()
CoordMode, mouse, Screen
MouseGetPos, x0, y0
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 1: Show, NA
hwnd1 := WinExist()
Width := Mon1Right, Height := Mon1Bottom
hdc := CreateCompatibleDC()
hbm := CreateDIBSection(Width, Height)
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
pBrush := Gdip_BrushCreateSolid(ColorRGB)
Gdip_SetSmoothingMode(G, 4)
pPen := Gdip_CreatePen(ColorRGB, 1)
MouseGetPos, x1, y1
w:= Abs(x1-x0)
h:= Abs(y1-y0)
;ToolTip, 基于screen坐标: %x1% , %y1%
; 整个函数的参数分别是 Gdip_FillRectangle(画布, 刷子, x, y, 矩形宽, 矩形高)
Gdip_FillRectangle(G, pBrush, Screenx+40, Screeny+20, 20, 20)
;Gdip_DeletePen(pPen)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
;Gdip_GraphicsClear(G)
w:= Abs(x1-x0)
h:= Abs(y1-y0)
Return [x0,y0,w,h]
}
建议把说明放在代码外侧