Re: [請問] 取得滑鼠座標位置的方式

作者: zxcwei (wei9133)   2016-07-21 21:42:38
※ 引述《name2name2 (yang~hi)》之銘言:
: 想請問大家有什麼快速的方式可以取得滑鼠座標嗎?
: 我是有想嘗試寫一個win環境跑的小工具做這件事,
: 不過想問有什麼現有的軟體已經能做到了嗎?
: (我是有試過最原始的方式就是一直試誤修正...)
: 還有這種工具大家會需要嗎?
AHK的原始碼檔案,論壇抓來的,把字改成繁體而已,有需要的可以自己壓成執行檔
(.exe)
Gui, Add, GroupBox, x2 y2 w200 h60 , 窗口信息
Gui, Add, Text, x5 y19 w32 h14 , 標題:
Gui, Add, Edit, x38 y17 w159 h18 ved1 HwndH1,
Gui, Add, Text, x5 y39 w32 h14 , 類:
Gui, Add, Edit, x38 y37 w159 h18 ved2 HwndH2,
Gui, Add, GroupBox, x2 y62 w200 h78 , 鼠標指針下信息
Gui, Add, Text, x7 y80 w45 h14 , 類別名:
Gui, Add, Edit, x51 y78 w146 h17 ved3 HwndH3,
Gui, Add, Text, x6 y98 w45 h14 , 文本:
Gui, Add, Edit, x51 y97 w146 h17 ved4 HwndH4,
Gui, Add, Text, x6 y117 w44 h15 , 顏色:
Gui, Add, Edit, x51 y116 w146 h17 ved5 HwndH5,
Gui, Add, GroupBox, x2 y140 w200 h57 , 鼠標坐標( X Y)
Gui, Add, Text, x9 y158 w55 h15 , 整個屏幕:
Gui, Add, Edit, x74 y156 w123 h18 ved6 HwndH6,
Gui, Add, Text, x9 y177 w67 h15 , 激活窗口中:
Gui, Add, Edit, x74 y176 w123 h18 ved7 HwndH7,
Gui, Add, GroupBox, x2 y197 w200 h57 , 位置[左邊x,頂邊y,寬度w,高度h]
Gui, Add, Text, x7 y214 w78 h15 , 激活窗口:
Gui, Add, Edit, x85 y212 w113 h18 ved8 HwndH8,
Gui, Add, Text, x7 y233 w78 h15 , 鼠標下控件:
Gui, Add, Edit, x85 y231 w113 h18 ved9 HwndH9,
Gui, Add, GroupBox, x2 y254 w200 h110 , 窗口文本[包含隱藏文本]
Gui, Add, Edit, x4 y267 w195 h93 ved10 HwndH10,
Gui, Add, Text, x7 y367 w198 h25 c0339E5 gUkl,熱鍵:Ctrl+Win 或 鼠標中鍵 `n
by 星雨朝霞
OnMessage(0x202,"WM_LBUTTONUP")
; Generated using SmartGUI Creator 4.0
;Gui,+AlwaysOnTop
Gui, Show, x0 y28 h393 w205, AHK 視窗訊息 1.1
WinSet, Transparent, 200,ahk_class AutoHotkeyGUI ; 讓窗口稍微有點透明效果
WinSet,TopMost,,ahk_class AutoHotkeyGUI ; 讓窗口置頂
Return
ukl:
run,tencent://message/?uin=458926486&Site=knmb.cn&Menu=yes
Return
~MButton::
Goto winpos
Return
~^LWin::
Goto winpos
Return
~#ctrl::
Goto winpos
Return
~^rWin::
Goto winpos
Return
winpos:
CoordMode,mouse,Screen ;設置坐標模式為全屏
DetectHiddenText, On ;探測隱藏的文本
MouseGetPos,sx,sy,win,class ;取鼠標下信息
;取標題
WinGetTitle,title,ahk_id %win%
GuiControl,,ed1,%title%
;窗口類
WinGetClass,winclass,ahk_id %win%
GuiControl,,ed2,ahk_class %winclass%
if class <>
{
;控件類別名
GuiControl,,ed3,%class%
;控件文本
ControlGetText,text,%class%,ahk_id %win%
GuiControl,,ed4,%text%
;控件大小
ControlGetPos,ctrlx,ctrly,ctrlw,ctrlh,%class%,ahk_id %win%
GuiControl,,ed9,%ctrlx%,%ctrly%,%ctrlw%,%ctrlh%
}
Else
{
;置空
GuiControl,,ed3,
GuiControl,,ed4,
GuiControl,,ed9,
}
;顏色
PixelGetColor,mousecolor,%sx%,%sy%,RGB
GuiControl,,ed5,%mousecolor%
;全屏坐標
GuiControl,,ed6,%sx%,%sy%
;當前激活窗口內的鼠標坐標
CoordMode,mouse,relative ;置坐標模式為當前窗口
MouseGetPos,wx,wy
GuiControl,,ed7,x%wx% y%wy%
;當前窗口大小
WinGetPos,winx,winy,winw,winh,A
GuiControl,,ed8,%winx%,%winy%,%winw%,%winh%
;窗口文本,
WinGetText,wintext,ahk_id %win%
GuiControl,,ed10,%wintext%
Return
GuiClose:
ExitApp
WM_LBUTTONUP(wParam,lParam,uMsg,hWnd)
{
if A_GuiControl in ed1,ed2,ed3,ed4,ed5,ed6,ed7,ed8,ed9
{
GuiControlGet,EditText,,%A_GuiControl%
if (EditText!=""){
Clipboard=%EditText%
ToolTip,已複製: %EditText%
SetTimer,RemoveToolTip,1000
}
}
}
RemoveToolTip:
{
SetTimer, RemoveToolTip, off
ToolTip
return
}
作者: zxcwei (wei9133)   2016-07-21 21:44:00
http://imgur.com/1vjHbsz實際使用的的圖片
作者: paulshain04 (paulshain04)   2016-08-18 12:24:00
可以用按鍵精靈

Links booklink

Contact Us: admin [ a t ] ucptt.com