鼠标手势脚本。
MouseGestureL,AutoHotKey脚本。
补充:
- ; 资源管理器中,按 Ctrl+Shift+C,复制文件名
- ^+c::
- send ^c
- sleep,200
- clipboard = %clipboard% ;%null%
- tooltip,%clipboard%
- sleep, 2000
- tooltip,
- return
计算数学表达式,支持Wscript语法:
- #^z::
- InputBox, express, 表达式计算, `n请输入表达式如数学公式,,400,150,,,,, %Clipboard%
- try {
- Tempfile := A_Temp . "\mgu_temp.vbs"
- s := Format("WScript.echo Eval(""{}"")", express)
- FileDelete, %Tempfile%
- FileAppend % s, % Tempfile
- cmd := "cscript //nologo " Tempfile
- result := Exec(cmd)
- } catch e {
- result := % "错误: " e.Message "`n行: " e.Line
- }
- showMessage("结果", result)
- return
- Exec(command) {
- shell := ComObjCreate("WScript.Shell")
- exec := shell.Exec(command)
- err := exec.StdErr.ReadAll()
- pos := InStr(err, ": ")
- if (pos > 0) {
- err := SubStr(err, pos + 2)
- }
- return exec.StdOut.ReadAll() . err
- }
粘贴为纯文本
- ^+v::
- Clip0 = %ClipBoardAll%
- ClipBoard = %ClipBoard%
- Send ^v
- Sleep 100
- ClipBoard = %Clip0%
- VarSetCapacity(Clip0, 0)
- return
HTML内容粘贴为HTML代码(RAW HTML)
- ; 获取剪贴板中 CF_HTML 格式数据
- ExtractHtmlData() {
- static CF_HTML := DllCall("RegisterClipboardFormat", "Str", "HTML Format")
- DllCall("OpenClipboard", "Uint", 0)
- format := 0
- Loop {
- format := DllCall("EnumClipboardFormats", "Uint", format)
- } until format = CF_HTML || format = 0
- if (format != CF_HTML) {
- DllCall("CloseClipboard")
- return
- }
- hData := DllCall("GetClipboardData", "Uint", CF_HTML, "Ptr")
- pData := DllCall("GlobalLock", "Ptr", hData)
- html := StrGet(pData, "UTF-8")
- DllCall("GlobalUnlock", "Ptr", hData)
- DllCall("CloseClipboard")
-
- pos := InStr(html, "<html")
- if (pos > 1) {
- html := SubStr(html, pos)
- }
- return html
- }
- ; 定义快捷键Ctrl+Alt+V,粘贴 HTML 原始代码
- ^!v::
- ^!v::
- Clip0 = %ClipBoardAll%
- ClipBoard := ExtractHtmlData()
- Send ^v
- Sleep 100
- ClipBoard = %Clip0%
- VarSetCapacity(Clip0, 0)
- Return
给Windows程序添加别名,添加后,按Win键打开菜单,然后输入别名即可运行对应程序
- ^
- Gui, Add, Text, x10 y5 w200 h20, 请输入别名,例如 xyz
- Gui, Add, Edit, x10 y30 w300 h20 vAlias,
- Gui, Add, Text, x10 y55 w200 h20, 请输入可执行文件名和路径
- Gui, Add, Edit, x10 y80 w300 h20 vExe,
- Gui, Add, Button, x10 y110 w60 h30 gOk Default, 确定
- Gui, Add, Button, x80 y110 w60 h30 gCancel, 取消
- Gui, Show, w320 h150, 添加新命令
- return
- Ok:
- Gui, Submit, NoHide
- if Alias =
- {
- MsgBox, 48, 错误, 请输入别名
- Return
- }
- if Exe =
- {
- MsgBox, 48, 错误, 请输入可执行文件名和路径
- Return
- }
- Run cmd /c reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\%Alias%.exe" /ve /d "%Exe%" /f
- Gui, Destroy
- return
- Cancel:
- Gui, Destroy
- return
屏幕取色
- ; 屏幕取色,Win + Alt + C
- #!c::
- ; 显示取色信息,跟随鼠标移动显示
- Tooltip, , % "1"
- ; 获取桌面工作区域矩形
- SysGet, WorkArea, MonitorWorkArea
- ; MsgBox % "工作区域矩形: Left=" . WorkAreaLeft . ", Top=" . WorkAreaTop . ", Right=" . WorkAreaRight . ", Bottom=" . WorkAreaBottom
-
- Loop
- {
- ; 监听鼠标移动
- CoordMode, Mouse, Screen
- CoordMode, Pixel, Screen
- CoordMode, ToolTip, Screen
- MouseGetPos, X, Y
- PixelGetColor, color, %X%, %Y%
- R := (color & 0x000000FF)
- G := (color & 0x0000FF00) >> 8
- B := (color & 0x00FF0000) >> 16
- rgb := Format("#{:x}{:x}{:x}", r, g, b)
- s := Format("({},{})颜色:`nHTML - {}`nR={}, G={}, B={}", X, Y, rgb, R, G, B)
-
- ty := Y + 20
- if (ty > WorkAreaBottom - 60) {
- ty := WorkAreaBottom - 60
- }
- ToolTip, % s, % X + 20, % ty
- Sleep, 10
- if (GetKeyState("Escape", "P"))
- {
- ; ESC键退出
- ToolTip
- Clipboard := rgb
- break
- }
- }
- return
- GetIPs() {
- ; 查询本机所有网络适配器的IP地址
- wbemLocator := ComObjCreate("WbemScripting.SWbemLocator")
- wbemServices := wbemLocator.ConnectServer(".", "root\cimv2")
- networkAdapters := wbemServices.ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True")
- ; 遍历所有网络适配器,输出IP地址
- ip := ""
- for adapter in networkAdapters
- {
- ipAddresses := adapter.IPAddress
- for index, ipAddress in ipAddresses
- {
- ip := ip . "`t" . index . "`n"
- }
- }
- whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- whr.Open("GET", "https://api.ipify.org", false)
- whr.Send()
- ip := "外部地址: `n`t" . whr.ResponseText . "`n" . "内部地址: `n" . ip
- whr := ""
- return ip
- }
- showMessage(title, text) {
- Gui +LastFound +ToolWindow +AlwaysOnTop
- WinSet, Transparent, 200
- Gui, Font, s18
- Gui, Add, Edit, x10 y10 w580 h460, %text%
- Gui, Show, w600 h480, %title%
- }
- #+i:: showMessage("结果(按ESC关闭)", GetIPs())