autohotkey-网上长脚本

本文介绍了使用Ctrl+12345快速复制粘贴的功能,并展示了如何通过小键盘数字键进行多变量顺序粘贴。同时,详细展示了利用AutoHotkey进行窗口自动隐藏、屏幕截图和位置控制的脚本,以及一个自定义的热键管理和窗口自动调整工具。
摘要由CSDN通过智能技术生成

Ctrl + 1 2 3 4 5分别复制, Alt + 1 2 3 4 5分别粘贴

;Feb 12, 2013
;Ctrl + 1 2 3 4 5分别复制 Alt + 1 2 3 4 5分别粘贴

;Mar 3, 2013
;windows + w顺序粘贴五个变量

;May 22, 2013
;支持小键盘(Numclock是否打开均可)
;windows + v粘贴并保存将要覆盖的内容到剪贴板


^1::
send ^c
a = %Clipboard%
Return

^NumpadEnd::
send ^c
a = %Clipboard%
Return

^Numpad1::
send ^c
a = %Clipboard%
Return

^2::
send ^c
b = %Clipboard%
Return

^NumpadDown::
send ^c
b = %Clipboard%
Return

^Numpad2::
send ^c
b = %Clipboard%
Return

^3::
send ^c
c = %Clipboard%
Return

^NumpadPgDn::
send ^c
c = %Clipboard%
Return

^Numpad3::
send ^c
c = %Clipboard%
Return

^4::
send ^c
d = %Clipboard%
Return

^NumpadLeft::
send ^c
d = %Clipboard%
Return

^Numpad4::
send ^c
d = %Clipboard%
Return

^5::
send ^c
e = %Clipboard%
Return

^NumpadClear::
send ^c
e = %Clipboard%
Return

^Numpad5::
send ^c
e = %Clipboard%
Return


!1::
Clipboard = %a%
send ^v
Return

!NumpadEnd::
Clipboard = %a%
send ^v
Return

!Numpad1::
Clipboard = %a%
send ^v
Return


!2::
Clipboard = %b%
send ^v
Return

!NumpadDown::
Clipboard = %b%
send ^v
Return

!Numpad2::
Clipboard = %b%
send ^v
Return


!3::
Clipboard = %c%
send ^v
Return

!NumpadPgDn::
Clipboard = %c%
send ^v
Return

!Numpad3::
Clipboard = %c%
send ^v
Return


!4::
Clipboard = %d%
send ^v
Return

!NumpadLeft::
Clipboard = %d%
send ^v
Return

!Numpad4::
Clipboard = %d%
send ^v
Return


!5::
Clipboard = %e%
send ^v
Return

!NumpadClear::
Clipboard = %e%
send ^v
Return

!Numpad5::
Clipboard = %e%
send ^v
Return


#w::
send !1
send !2
send !3
send !4
send !5
Return

#v::
toPaste = %Clipboard%
send ^c
toCover = %Clipboard%
Clipboard = %toPaste%
send ^v
Clipboard = %toCover%
Return

让窗口贴边隐藏

/*
 * BoD winautohide v1.00.
 *
 * This program and its source are in the public domain.
 * Contact BoD@JRAF.org for more information.
 *
 * Version history:
 * 2008-06-13: v1.00
 */

#SingleInstance ignore

/*
 * Hotkey bindings
 */
Hotkey, #right, toggleWindowRight
Hotkey, #left, toggleWindowLeft
Hotkey, #up, toggleWindowUp
Hotkey, #down, toggleWindowDown

; uncomment the following lines to use ctrl+alt+shift instead if you don't have a "windows" key
;Hotkey, !^+right, toggleWindowRight
;Hotkey, !^+left, toggleWindowLeft
;Hotkey, !^+up, toggleWindowUp
;Hotkey, !^+down, toggleWindowDown



/*
 * Timer initialization.
 */
SetTimer, watchCursor, 300


/*
 * Tray menu initialization.
 */
Menu, tray, NoStandard
Menu, tray, Add, About..., menuAbout
Menu, tray, Add, Un-autohide all windows, menuUnautohideAll
Menu, tray, Add, Exit, menuExit
Menu, tray, Default, About...


return ; end of code that is to be executed on script start-up


/*
 * Tray menu implementation.
 */
menuAbout:
	MsgBox, 8256, About, BoD winautohide v1.00.`n`nThis program and its source are in the public domain.`nContact BoD@JRAF.org for more information.
return

menuUnautohideAll:
	Loop, Parse, autohideWindows, `,
	{
		curWinId := A_LoopField
		if (autohide_%curWinId%) {
			Gosub, unautohide
		}
	}
return

menuExit:
	Gosub, menuUnautohideAll
	ExitApp
return



/*
 * Timer implementation.
 */
watchCursor:
	MouseGetPos, , , winId ; get window under mouse pointer
	if (autohide_%winId%) { ; window is on the list of 'autohide' windows
		if (hidden_%winId%) { ; window is in 'hidden' position
			previousActiveWindow := WinExist("A")
			WinActivate, ahk_id %winId% ; activate the window
			WinMove, ahk_id %winId%, , showing_%winId%_x, showing_%winId%_y ; move it to 'showing' position
			hidden_%winId% := false
			needHide := winId ; store it for next iteration
		}
	} else {
		if (needHide) {
			WinMove, ahk_id %needHide%, , hidden_%needHide%_x, hidden_%needHide%_y ; move it to 'hidden' position
			WinActivate, ahk_id %previousActiveWindow% ; activate previously active window
			hidden_%needHide% := true
			needHide := false ; do that only once
		}
	}
return


/*
 * Hotkey implementation.
 */
toggleWindowRight:
	mode := "right"
	Gosub, toggleWindow
return

toggleWindowLeft:
	mode := "left"
	Gosub, toggleWindow
return

toggleWindowUp:
	mode := "up"
	Gosub, toggleWindow
return

toggleWindowDown:
	mode := "down"
	Gosub, toggleWindow
return


toggleWindow:
	WinGet, curWinId, id, A
	autohideWindows = %autohideWindows%,%curWinId%
	if (autohide_%curWinId%) {
		Gosub, unautohide
	} else {
		autohide_%curWinId% := true
		Gosub, workWindow
		WinGetPos, orig_%curWinId%_x, orig_%curWinId%_y, width, height, ahk_id %curWinId% ; get the window size and store original position

		if (mode = "right") {
			showing_%curWinId%_x := A_ScreenWidth - width
			showing_%curWinId%_y := orig_%curWinId%_y

			hidden_%curWinId%_x := A_ScreenWidth - 1
			hidden_%curWinId%_y := orig_%curWinId%_y
		} else if (mode = "left") {
			showing_%curWinId%_x := 0
			showing_%curWinId%_y := orig_%curWinId%_y

			hidden_%curWinId%_x := -width + 1
			hidden_%curWinId%_y := orig_%curWinId%_y
		} else if (mode = "up") {
			showing_%curWinId%_x := orig_%curWinId%_x
			showing_%curWinId%_y := 0

			hidden_%curWinId%_x := orig_%curWinId%_x
			hidden_%curWinId%_y := -height + 1
		} else { ; down
			showing_%curWinId%_x := orig_%curWinId%_x
			showing_%curWinId%_y := A_ScreenHeight - height

			hidden_%curWinId%_x := orig_%curWinId%_x
			hidden_%curWinId%_y := A_ScreenHeight - 1
		}

		WinMove, ahk_id %curWinId%, , hidden_%curWinId%_x, hidden_%curWinId%_y ; hide the window
		hidden_%curWinId% := true
	}
return


unautohide:
	autohide_%curWinId% := false
	needHide := false
	Gosub, unworkWindow
	WinMove, ahk_id %curWinId%, , orig_%curWinId%_x, orig_%curWinId%_y ; go back to original position
	hidden_%curWinId% := false
return

workWindow:
	DetectHiddenWindows, On
	WinSet, AlwaysOnTop, on, ahk_id %curWinId% ; always-on-top
	WinHide, ahk_id %curWinId%
	WinSet, Style, -0xC00000, ahk_id %curWinId% ; no title bar
	WinSet, ExStyle, +0x80, ahk_id %curWinId% ; remove from task bar
	WinShow, ahk_id %curWinId%
return

unworkWindow:
	DetectHiddenWindows, On
	WinSet, AlwaysOnTop, off, ahk_id %curWinId% ; always-on-top
	WinHide, ahk_id %curWinId%
	WinSet, Style, +0xC00000, ahk_id %curWinId% ; title bar
	WinSet, ExStyle, -0x80, ahk_id %curWinId% ; remove from task bar
	WinShow, ahk_id %curWinId%
return

使用autohotkey进行屏幕贴图

; http://www.autohotkey.com/forum/viewtopic.php?p=155636#155636
; lexicos & Sean
#SingleInstance off
SetTimer, AlwaysOnTop, 250

applicationname=小众软件屏幕水印 v0.1
applicationfunction=在屏幕上显示任意图片作为水印。
applicationtip=- 玩全屏游戏时请退出,不然窗口会不断置顶导致闪烁。

IfNotExist, Settings.ini
{
  gosub About
  ini=%ini%[Settings]
  ini=%ini%`nX=20`n
  ini=%ini%`nY=20`n
  ini=%ini%`nPicPath=appinn.png`n
  ini=%ini%`nTrayIcon=1`n
  FileAppend, %ini%, Settings.ini
  ini=
}

IniRead, X, Settings.ini, Settings, X
IniRead, Y, Settings.ini, Settings, Y
IniRead, PicPath, Settings.ini, Settings, PicPath
IniRead, TrayIcon, Settings.ini, Settings, TrayIcon
IniRead, FirstRun, Settings.ini, Settings, FirstRun

if 1=
	sFile := PicPath
else
{
	sFile = %1%
	IniWrite, %1%, Settings.ini, Settings, PicPath
}

if TrayIcon=0
	menu,Tray,NoIcon

Menu, Tray, NoStandard
Menu, Tray, NoDefault
Menu, tray, add, About, About
Menu, tray, add, Hide Tray Icon, HideTrayIcon
Menu, tray, add, 
Menu, tray, add, Exit, Exit

mDC_Scr := Gdi_CreateCompatibleDC(0)
pToken := Gdip_Startup()
pBitmap := Gdip_CreateBitmapFromFile(sFile)
nWidth := Gdip_GetImageWidth(pBitmap)
nHeight := Gdip_GetImageHeight(pBitmap)
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
oBitmap := Gdi_SelectObject(mDC_Scr, hBitmap)

Gui, +LastFound -Caption +E0x80000 +ToolWindow +AlwaysOnTop
hGui := WinExist()
DllCall("UpdateLayeredWindow", "Uint", WinExist(), "Uint", 0, "Uint", 0, "int64P", nWidth|nHeight<<32, "Uint", mDC_Scr, "int64P", 0, "Uint", 0, "UintP", 255<<16|1<<24, "Uint", 2)
Gui, Show, x%X% y%Y% W%nWidth% H%nHeight%, 小众软件屏幕水印

OnMessage(0x0201, "WM_LBUTTONDOWN")
OnMessage(0x0003, "WM_MOVE")
OnMessage(0x0204, "WM_RBUTTONDOWN")

Gdi_SelectObject(mDC_Scr, oBitmap)
Gdi_DeleteObject(hBitmap)
Gdi_DeleteDC(mDC_Scr)
Return

AlwaysOnTop:
WinSet, AlwaysOnTop, On ,小众软件屏幕水印
Return

HideTrayIcon:
WinGetPos, WX, WY, Width, Height, 小众软件屏幕水印
IniWrite, %WX%, Settings.ini, Settings, X
IniWrite, %WY%, Settings.ini, Settings, Y
IniWrite, 0, Settings.ini, Settings, TrayIcon
reload
return

Exit:
GuiClose:
GuiEscape:
WinGetPos, WX, WY, Width, Height, 小众软件屏幕水印
IniWrite, %WX%, Settings.ini, Settings, X
IniWrite, %WY%, Settings.ini, Settings, Y
Gui, Destroy
ExitApp

WM_RBUTTONDOWN()
{
WinGetPos, WX, WY, Width, Height, 小众软件屏幕水印
IniWrite, %WX%, Settings.ini, Settings, X
IniWrite, %WY%, Settings.ini, Settings, Y
Gui, Destroy
ExitApp
}

WM_LBUTTONDOWN()
{
 If A_Gui
  PostMessage, 0xA1, 2 ; WM_NCLBUTTONDOWN
}

WM_MOVE(wParam, lParam, nMsg, hWnd)
{
 If A_Gui
 && DllCall("UpdateLayeredWindow", "Uint", hWnd, "Uint", 0, "int64P", (lParam<<48>>48)&0xFFFFFFFF|(lParam&0xFFFF0000)<<32>>16, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0)
 Return 0
}


Gdi_CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "")
{
 NumPut(VarSetCapacity(bi, 40, 0), bi)
 NumPut(nW, bi, 4)
 NumPut(nH, bi, 8)
 NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")

 Return DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
}

Gdi_CreateCompatibleDC(hDC = 0)
{
 Return DllCall("gdi32\CreateCompatibleDC", "Uint", hDC)
}

Gdi_SelectObject(hDC, hGdiObj)
{
 Return DllCall("gdi32\SelectObject", "Uint", hDC, "Uint", hGdiObj)
}

Gdi_DeleteObject(hGdiObj)
{
 Return DllCall("gdi32\DeleteObject", "Uint", hGdiObj)
}

Gdi_DeleteDC(hDC)
{
 Return DllCall("gdi32\DeleteDC", "Uint", hDC)
}

Gdip_CreateBitmapFromFile(sFile)
{
 VarSetCapacity(wFile, 1023)
 DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sFile, "int", -1, "Uint", &wFile, "int", 512)
 DllCall("gdiplus\GdipCreateBitmapFromFile", "Uint", &wFile, "UintP", pBitmap)
 Return pBitmap
}

Gdip_CreateBitmapFromHICON(hIcon)
{
 DllCall("gdiplus\GdipCreateBitmapFromHICON", "Uint", hIcon, "UintP", pBitmap)
 Return pBitmap
}

Gdip_CreateHBITMAPFromBitmap(pBitmap, ARGB = 0)
{
 DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pBitmap, "UintP", hBitmap, "Uint", ARGB)
 Return hBitmap
}

Gdip_DisposeImage(pImage)
{
 Return DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)
}

Gdip_GetImageWidth(pImage)
{
 DllCall("gdiplus\GdipGetImageWidth", "Uint", pImage, "UintP", nW)
 Return nW
}

Gdip_GetImageHeight(pImage)
{
 DllCall("gdiplus\GdipGetImageHeight", "Uint", pImage, "UintP", nH)
 Return nH
}

Gdip_Startup()
{
 If Not DllCall("GetModuleHandle", "str", "gdiplus")
 DllCall("LoadLibrary"  , "str", "gdiplus")
 VarSetCapacity(si, 16, 0), si := Chr(1)
 DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)
 Return pToken
}

Gdip_Shutdown(pToken)
{
 DllCall("gdiplus\GdiplusShutdown", "Uint", pToken)
 If hModule := DllCall("GetModuleHandle", "str", "gdiplus")
    DllCall("FreeLibrary"  , "Uint", hModule)
 Return 0
}


About:
Gui,99:Destroy
Gui,99:Margin,15,15
Gui,99:Add,Picture,xm, Appinn.com.png
Gui,99:Font,Bold
Gui,99:Add,Text,xm y+20,%A_space%%A_space%%applicationname%
Gui,99:Font
Gui,99:Add,Text,x25 y+10,%applicationfunction%
Gui,99:Add,Text,x25 y+5,%applicationtip%

Gui,99:Font,Bold
Gui,99:Add,Text,xm y+20,%A_space%%A_space%by 小众软件 - sfufoet
Gui,99:Font
Gui,99:Add,Text,x25 y+10,分享免费、小巧、实用、有趣、绿色的软件
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,x25 y+5 gAppinn,www.appinn.com
Gui,99:Font

Gui,99:Font,Bold
Gui,99:Add,Text,xm y+20,%A_space%%A_space%Power by AutoHotkey
Gui,99:Font
Gui,99:Add,Text,x25 y+10,此小工具由 AutoHotKey 创建
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,x25 y+5 gAUTOHOTKEY,www.AutoHotkey.com
Gui,99:Add,Text,x25 y+5 gAppinnAhk,www.appinn.com/category/autohotkey/
Gui,99:Font

Gui,99:Show,,%applicationname% About
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE") 
Return

Appinn:
  Run,http://www.appinn.com,,UseErrorLevel
Return

AUTOHOTKEY:
  Run,http://www.autohotkey.com,,UseErrorLevel
Return

AppinnAhk:
  Run,http://www.appinn.com/category/autohotkey/,,UseErrorLevel
return

99GuiClose:
  Gui,99:Destroy
  OnMessage(0x200,"")
  DllCall("DestroyCursor","Uint",hCur)
Return

WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  MouseGetPos,,,,ctrl
  If ctrl in Static7,Static10,Static11
    DllCall("SetCursor","UInt",hCurs)
  Return
}
Return


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值