[爆卦]AutoHotkey範例是什麼?優點缺點精華區懶人包

為什麼這篇AutoHotkey範例鄉民發文收入到精華區:因為在AutoHotkey範例這個討論話題中,有許多相關的文章在討論,這篇最有參考價值!作者VElysian (家瑀 致中和)看板EzHotKey標題[AHK-] AutoHotKey 官...



AutoHotkey Script Showcase

http://www.autohotkey.com/docs/scripts/index.htm


Screen Magnifier -- by Holomind

http://www.autohotkey.com/forum/topic11700.html


.開放原始碼
.支援去鋸齒化
.設定重繪間隔時間(Delay)
.選擇放大的倍數
.被放大鏡擋住的部份仍可正常顯示

說明:

正常版:所有按鈕都在上面,用滑鼠點就可以了。
精簡版:
Win + A 去鋸齒
Win + X 關閉放大鏡
Win + P 隱藏/顯示放大鏡

Ctrl + Shift + 滾輪向上 放大倍率上升
Ctrl + Shift + 滾輪向下 放大倍率下降

exe執行檔載點: http://www.holomind.de/ahk/magnifier/magnifier_smooth.exe



正常版:

OnExit handle_exit

Gui, +AlwaysOnTop +Owner +Resize +ToolWindow ; window for the dock
Gui, Show, NoActivate w400 h400 x300 y50 , PrintScreen
Gui, Add, DDL, vzoom , 0.5|1|2||4|8|16
Gui, Add, Checkbox, y12 x150 vantialize, Antialize ?
Gui, Add, Slider, vdelay x220 y0 Range15-200
Gui, Add, Text, x340 y12 w80 vdelay2

WinGet PrintScreenID, id ,PrintScreen ;
WinSet, Transparent , 254, PrintScreen

;retrieve the unique ID number (HWND/handle) of that window
WinGet, PrintSourceID, id

hotkey , #x , toggle_follow
hotkey , +$LButton , click_through

toolbar_def:=35
toolbar := toolbar_def
follow :=0

hdd_frame := DllCall( "GetDC", UInt, PrintSourceID )
hdc_frame := DllCall( "GetDC", UInt, PrintScreenID )

hdc_buffer := DllCall("gdi32.dll\CreateCompatibleDC", UInt, hdc_frame) ;
buffer
hbm_buffer := DllCall("gdi32.dll\CreateCompatibleBitmap", UInt,hdc_frame,
Int,A_ScreenWidth, Int,A_ScreenHeight)

Gosub, Repaint
return

toggle_follow:
follow := 1 - follow

if follow = 1
{
WinSet Region, 0-0 W%ww% H%wh% E , PrintScreen
toolbar := -32 ; height of window title
GuiControl, Hide, zoom
}
else
{
WinSet Region,, PrintScreen
toolbar :=toolbar_def
GuiControl, Show, zoom
}
Return

click_through:
if follow = 1
{
Gui, Hide
Send, {Click}
SetTimer, Repaint , Off
Sleep, 100
Gui, Show
SetTimer, Repaint, %delay%
}
Return

Repaint:

CoordMode, Mouse, Screen
MouseGetPos, start_x, start_y ; position of mouse
Gui, Submit, NoHide ; needed to read the dropdown
and slidervalue
GuiControl,, delay2 , delay %delay% ms
WinGetPos, wx, wy, ww, wh , PrintScreen

wh2 := wh - toolbar

DllCall( "gdi32.dll\SetStretchBltMode", "uint", hdc_frame, "int", 4 *
antialize ) ; Halftone better quality with stretch

DllCall("gdi32.dll\StretchBlt", UInt,hdc_frame, Int,0, Int,toolbar,
Int,ww, Int,wh - toolbar
, UInt,hdd_frame, Int
, start_x-(ww / 2 / zoom)
, Int,start_y -( wh2 / 2/zoom), Int,ww / zoom, Int,wh2 / zoom
,UInt,0xCC0020) ; SRCCOPY

if follow = 1
WinMove, PrintScreen, ,start_x -ww/2 , start_y-wh/2

SetTimer, Repaint , %delay%
Return

GuiClose:
handle_exit:
DllCall("gdi32.dll\DeleteObject", UInt,hbm_buffer)
DllCall("gdi32.dll\DeleteDC", UInt,hdc_frame )
DllCall("gdi32.dll\DeleteDC", UInt,hdd_frame )
DllCall("gdi32.dll\DeleteDC", UInt,hdc_buffer)
ExitApp

精簡版(執行速度較快):


#NoEnv
SetBatchLines -1

CoordMode Mouse, Screen
OnExit GuiClose
zoom = 2 ; initial magnification, 1..32
antialize = 0
Rx = 128 ; half vertical/horizontal side of magnifier window
Ry = 128
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
TrayTip,,% "Frame = " Round(2*Zx) " × " Round(2*Zy) "`nMagnified to = "
A_GuiWidth "×" A_GuiHeight
Return

#a::
antialize := !antialize
DllCall( "gdi32.dll\SetStretchBltMode", "uint", hdc_frame, "int",
4*antialize ) ; Antializing ?
Return

#x::
GuiClose:
DllCall("gdi32.dll\DeleteDC", UInt,hdc_frame )
DllCall("gdi32.dll\DeleteDC", UInt,hdd_frame )
ExitApp

#p::
MButton::
if paused =
{
Gui, 2:Hide
Gui, Hide
SetTimer, Repaint, Off
paused = 1
}
else
{
Gui, 2:Show
Gui, Show
SetTimer, Repaint, 50
paused =
}
Return

^+Up::
^+Down::
^+WheelUp:: ; Ctrl+Shift+WheelUp to zoom in
^+WheelDown:: ; Ctrl+Shift+WheelUp to zoom out
If (zoom < 31 and ( A_ThisHotKey = "^+WheelUp" or A_ThisHotKey = "^+Up" ))
zoom *= 1.189207115 ; sqrt(sqrt(2))
If (zoom > 1 and ( A_ThisHotKey = "^+WheelDown" or A_ThisHotKey =
"^+Down" ))
zoom /= 1.189207115
Zx := Rx/zoom
Zy := Ry/zoom
TrayTip,,% "Zoom = " Round(100*zoom) "%"
Return

In(x,a,b) { ; closest number to x in [a,b]
IfLess x,%a%, Return a
IfLess b,%x%, Return b
Return x
}


--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.62.73.254
※ 編輯: VElysian 來自: 61.62.92.141 (08/04 09:54)

你可能也想看看

搜尋相關網站