[AHK-] 放大鏡應用上的問題
有時候需要放大鏡這功能所以嚐試了一下,有些問題想請教
我把原本精華區的範例精簡一下成為自已想要如下,如果把
頭尾兩行刪掉變單獨一個ahk檔執行正常,如果把頭尾兩行
加上,變按中鍵也會正常使用,可是如果像開了檔案管理員
的時候若在上面點了一下,滑鼠的定位會跑掉,所以現在變
設成按滑鼠中鍵執行另一個單獨正常的ahk檔。
MButton:: ; (這行如果刪掉可以正常)
#NoEnv
SetBatchLines -1
CoordMode Mouse, Screen
OnExit GuiClose
zoom = 2 ; initial magnification, 1..32
antialize = 0
Rx = 200 ; half vertical/horizontal side of magnifier window
Ry = 100
Zx := Rx/zoom ; frame x/y size
Zy := Ry/zoom
; GUI to show the magnified image
Gui +AlwaysOnTop +Resize +ToolWindow
Gui Show, % "w" 2*Rx " h" 2*Ry " x0 y0", Magnifier
WinGet MagnifierID, id, Magnifier
WinSet Transparent, 255, Magnifier ; makes the window invisible to
magnification
WinGet PrintSourceID, ID
hdd_frame := DllCall("GetDC", UInt, PrintSourceID)
hdc_frame := DllCall("GetDC", UInt, MagnifierID)
SetTimer Repaint, 50 ; flow through
Repaint:
MouseGetPos x, y
xz := In(x-Zx-6,0,A_ScreenWidth-2*Zx) ; keep the frame on screen
yz := In(y-Zy-6,0,A_ScreenHeight-2*Zy)
; WinMove Frame,,%xz%, %yz%, % 2*Zx, % 2*Zy
DllCall("gdi32.dll\StretchBlt", UInt,hdc_frame, Int,0, Int,0, Int,2*Rx,
Int,2*Ry
, UInt,hdd_frame, UInt,xz, UInt,yz, Int,2*Zx, Int,2*Zy, UInt,0xCC0020) ;
SRCCOPY
Return
GuiSize:
Rx := A_GuiWidth/2
Ry := A_GuiHeight/2
Zx := Rx/zoom
Zy := Ry/zoom
Return
GuiClose:
DllCall("gdi32.dll\DeleteDC", UInt,hdc_frame )
DllCall("gdi32.dll\DeleteDC", UInt,hdd_frame )
ExitApp
In(x,a,b) { ; closest number to x in [a,b]
IfLess x,%a%, Return a
IfLess b,%x%, Return b
Return x
}
Return ;(這行如果刪掉正常)
謝謝~~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.105.82.213
EzHotKey 近期熱門文章
PTT數位生活區 即時熱門文章