算不上什么好东西,抓取拖动窗口的一个测试
#SingleInstance FORCE
#NoEnv
CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen
SetTimer winMonitor, 0
global CustomColor:=0xFF0000, bord:=5, move_WinID, GEvents, IsRight, step:=10, showTip:=1
Gui, +hwndmove_WinID +AlwaysOnTop -Resize +LastFound
Gui, Color, % CustomColor
Gui, Add, Text, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth% gmoveWin
WinSet, Transparent, 150
Gui, -Caption
Gui, Show, H240 W320
Return
moveWin:
PostMessage, 0xA1, 2, , , Ahk_Id %move_WinID%
gosub winMonitor
Return
GuiEscape:
GuiClose:
ExitApp
GuiContextMenu(GuiHwnd, CtrlHwnd, EventInfo, IsRightClick, X, Y)
{
if !IsRightClick
return
GEvents := "RButton"
}
winMonitor:
if !(UniqueID := WinActive("Ahk_Id " move_WinID))
{
ToolTip
return
}
infotip:
WinGetPos, X, Y, Width, Height, Ahk_Id %move_WinID%
MouseGetPos, OutputVarX, OutputVarY
GEvents := (A_GuiEvent ? A_GuiEvent : GEvents)
if (OutputVarX>=X && OutputVarX<=(X+Width) && OutputVarY>=Y && OutputVarY<=(Y+Height))
{
if showTip
ToolTip, % "" ;move_WinID "`n" OutputVarX "`t" OutputVarY
. "`n鼠标:`t" GEvents
. "`n调整步长:`t" step
, OutputVarX+16, OutputVarY+16
else
ToolTip
OnWin := 1
}
else
{
OnWin := 0
ToolTip
}
return
~WheelUp::
if !(UniqueID := WinActive("Ahk_Id " move_WinID)) || !OnWin
{
ToolTip
return
}
if GetKeyState("LButton")
{
if step<50
{
if step >=10
step+=5
else
step+=1
}
gosub infotip
}
else if GetKeyState("RButton")
{
gosub infotip
WinMove, A, , , , % Width + step
gosub infotip
}
else
{
gosub infotip
WinMove, A, , , , , % Height + step
gosub infotip
}
return
~MButton::
if !(UniqueID := WinActive("Ahk_Id " move_WinID)) || !OnWin
{
return
}
showTip:=!showTip
return
~WheelDown::
if !(UniqueID := WinActive("Ahk_Id " move_WinID)) || !OnWin
{
ToolTip
return
}
if GetKeyState("LButton")
{
if step>=15
step-=5
else if step>0
step-=1
gosub infotip
}
else if GetKeyState("RButton")
{
gosub infotip
WinMove, A, , , , % Width - step
gosub infotip
}
else
{
gosub infotip
WinMove, A, , , , ,% Height - step
gosub infotip
}
return
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

