/*鼠标复制与粘贴 脚本: zxhSpace 功能: 1、在鼠标为工字光标或激活QQ聊天窗口时,鼠标左键双击后发送Ctrl+c 2、在鼠标为工字光标或激活QQ聊天窗口时,鼠标按下并移动且松开后发送Ctrl+c 3、按下Shift+LButton时发送Ctrl+c 4、按下鼠标右键不松开再按鼠标左键,发送Ctrl+v。鼠标右键松开时自动去掉弹出菜单 */ #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #Persistent ;让脚本持久运行(关闭或ExitApp) #SingleInstance Force ;跳过对话框并自动替换旧实例 #if (A_Cursor = "IBeam") || (WinActive("ahk_class TXGuiFoundation")) ~LButton:: MouseGetPos, begin_x, begin_y while GetKeyState("LButton") { MouseGetPos, x, y xy:=Abs(begin_x-x) yx:=Abs(begin_y-y) if xy>1 || yx>1 global copyyn:=1 else copyyn:=0 Sleep, 10 } if pressesCount > 0 ; >0说明SetTimer 已经启动了,按键次数递增 { pressesCount += 1 return } pressesCount = 1 ;否则,这是新一系列按键的首次按键。将计数设重置为 1 ,并启动定时器: SetTimer, WaitKeygg, 300 ;在 400 毫秒内等待更多的按键。 return WaitKeygg: SetTimer, WaitKeygg, off if pressesCount = 1 ;该键已按过一次。 { } else if pressesCount = 2 ;该键已按过两次。 { Sleep 200 SendInput ^c } pressesCount = 0 ;不论上面哪个动作被触发,将计数复位以备下一系列的按键 return ~LButton Up:: if copyyn=1 { Sleep 500 SendInput ^c } return ~+LButton:: Sleep 200 SendInput ^c return ~RButton & LButton:: Sleep 200 SendInput ^v return ~RButton Up:: if A_PriorKey!=RButton { Loop, 9 { IfWinExist, ahk_class #32768 WinClose, ahk_class #32768 ;在右键菜单出现时关闭它 Sleep 50 } } return #if