【脚本信息】———————————————–
作者:Kawvin(285781427)
功能:快捷粘贴常用数据,临时从剪贴板获取的数据
【热键信息】———————————————–
快捷键:可打开文件修改,说明:^=Ctrl,+=Shift,!=Alt,#=Win
显示窗体:Win+v
顺序粘贴:Win+b
临时复制:Alt+c
【使用方法】———————————————–
1、单项粘贴: ①在要粘贴数据的窗体上Win+v打开界面,先在窗体上选择插入位置,然后双击要插入的数据,如果插入失败,可以再使用Ctrl+V粘贴;
②勾选【自动回车】,则粘贴数据后回车换行;
2、连续粘贴:
①勾选【连续粘贴】后,选择分隔符,则上面选中的数据,在每项粘贴后,插入分隔符Tab/Enter/指定的字符/方向键(向上/向下/向左/向右)
②勾选【末位不添加】,最后一项输入后无分隔符;
3、从剪贴板导入:选中内容,按Ctrl+C复制后,回到本界面,【从剪贴板导入】导入【临时数据】列表,勾选【持续】,可连续导入;
4、热键从剪贴板导入:选中内容,按临时复制热键(Alt+c)直接导入【临时数据】列表,勾选【持续】,可连续导入;
5、打开列表:默认为INI文件,可修改添加数据,列表以[xxx]分隔,下面是数据项;
6、指定程序:指定粘贴到的窗体,如果不对,可选择或【刷新程序】后再选择。
↓↓↓↓↓↓↓↓↓↓↓↓↓下面是源码↓↓↓↓↓↓↓↓↓↓↓↓↓
/*Kawvin闪电粘贴
程序: Kawvin闪电粘贴
作用: 快捷粘贴已保存的列表的数据项
作者: Kawvin
版本: 0.7
使用方法:
V0.7_2022.02.24
(1)增加置顶及右下角定位功能
(2)添加全部导入剪贴板功能
(3)修正连接粘贴错误,功能键及字符错误
V0.6_2021.11.28:
(1)增加Excel横向复制Tab快速粘贴功能
V0.5_2021.6.23:
(1)增加复制快捷键Alt+C,可修改
(2)添加连续复制导入功能
(3)添加使用说明按键
V0.4.1_2021.6.18:
(1)分隔符增加方向键功能,向上/向下/向左/向右
(2)临时从剪贴板导入数据,列表显示【临时数据】
V0.3.1_2021.6.15:新增功能
(1)增加连续粘贴功能,以分隔符切换,添加分隔符的类型为Tab/Enter/指定字符
(2)调整界面
(3)添加右键菜单
V0.2_2021.6.15:新增功能
(1)见操作界面
(2)增加自定义快捷键功能
include 进入QZ,修改:
(1)第36、37行,修改INI文件的路径
(2)注销第41-55行Label_RegHotKey,取消自动注册热键功能
(3)启用第32行,启用热键【Win+v】,启用第192行热键【Ctrl+Shift+v】
*/
Label_ScriptSetting: ;{ 脚本前参数设置
#SingleInstance force
;}
;~ #v:: ;QZ插件,启用本行,热键【Win+v】
Label_DefVar: ;{ 设置主参数
AppName=Kawvin闪电粘贴
AppVer=0.7_2022.07.20
MyWordsINI=%A_ScriptDir%\我的常用词.ini ;独立版本
;~ MyWordsINI=%A_ScriptDir%\KawvinLib\我的常用词.ini ;QZ版本
IfNotExist,%MyWordsINI%
{
FileAppend,[通用设置]`n,%MyWordsINI%
FileAppend,粘贴热键=#v`n,%MyWordsINI%
FileAppend,连续热键=#b`n,%MyWordsINI%
FileAppend,复制热键=!c`n`n,%MyWordsINI%
FileAppend,[示例1]`n,%MyWordsINI%
FileAppend,aaaaaaa`n,%MyWordsINI%
FileAppend,bbbbbb`n,%MyWordsINI%
FileAppend,[示例2]`n,%MyWordsINI%
FileAppend,1111111`n,%MyWordsINI%
FileAppend,2222222`n,%MyWordsINI%
}
;}
;QZ插件,注销Label_RegHotKey,启用,第32行热键【Win+v】、第192行热键【Ctrl+Shift+v】
Label_RegHotKey: ;{ 注册热键
iniRead,PasteHotKey,%MyWordsINI%,通用设置,粘贴热键
iniRead,OrderHotKey,%MyWordsINI%,通用设置,连续热键
;~ iniRead,SingleHotKey,%MyWordsINI%,通用设置,单项热键
iniRead,CopyHotKey,%MyWordsINI%,通用设置,复制热键
;替换热键到正常键
LPasteHotKey:=MyFun_RetrunKeys(PasteHotKey)
PasteHotKey=$%PasteHotKey%
LOrderHotKey:=MyFun_RetrunKeys(OrderHotKey)
OrderHotKey=$%OrderHotKey%
;~ LSingleHotKey:=MyFun_RetrunKeys(SingleHotKey)
;~ SingleHotKey=$%SingleHotKey%
LCopyHotKey:=MyFun_RetrunKeys(CopyHotKey)
CopyHotKey=$%CopyHotKey%
;注册热键
hotkey,%PasteHotKey%,Label_Main
hotkey,%OrderHotKey%,KyPasteWin_顺序粘贴
;~ hotkey,%SingleHotKey%,KyPasteWin_单行粘贴
hotkey,%CopyHotKey%,KyPasteWin_复制数据
;}
Label_Main: ;{ 主运行脚本
MouseGetPos,,,CurWin_id ;当前鼠标下的进程ID
WinGet, CurWin_Fullpath,ProcessPath,Ahk_ID %CurWin_id% ;当前进程的路径
WinGetTitle, CurWin_Title,Ahk_ID %CurWin_id% ;当前进程的标题
;}
Label_ReadINI: ;{ 读取INI分组
IniRead,MyGroups,%MyWordsINI%
Array_Group:=""
Loop,parse,MyGroups,`n,`r
{
if (A_LoopField="" or A_LoopField="通用设置")
continue
if (A_Index=2)
Array_Group=%Array_Group%%A_LoopField%||
else
Array_Group=%Array_Group%%A_LoopField%|
}
Array_Group=%Array_Group%临时数据
;}
KyPasteWin_显示KyPasteWin: ;{ 显示列表窗体
try
Gui KyPasteWin:Destroy
Gui KyPasteWin:New
Gui KyPasteWin:+AlwaysOnTop
Gui KyPasteWin:Font, s11
Gui KyPasteWin:Add,Text, x10 y13 h21,常用词列表:
Gui,KyPasteWin:Add, DropDownList,x100 y10 w285 vMyWordsGroup gKyPasteWin_刷新常用词列表,
Gui KyPasteWin:Add,Text, x10 y38 h21,指定的程序:
Gui,KyPasteWin:Add, DropDownList,x100 y35 w285 vactivewindow,
Gui KyPasteWin:Add,Button,x390 y9 w80 h25 gKyPasteWin_打开,打开列表
Gui KyPasteWin:Add,Button,x390 y35 w80 h25 gKyPasteWin_刷新程序列表,刷新程序
Gui KyPasteWin:Add, Listview, x10 w460 h430 -Hdr -Multi vMyListItem gKyPasteWin_Sub_MyListItem,数据内容
KyPasteWin_刷新程序列表()
Gui,KyPasteWin:Add, Checkbox, Section x10 y+13 vMyAutoEnter1,自动回车
Gui KyPasteWin:Add,Button,ys-5 w40 ,上移
Gui KyPasteWin:Add,Button,ys-5 w40 ,下移
Gui KyPasteWin:Add,Button,ys-5 w100 ,从剪贴板导入
Gui KyPasteWin:Add,Checkbox,ys xp+108 vSustain,持续
Gui KyPasteWin:Add,Button,ys-5 xp+57 w88 ,导入剪贴板
;~ Gui,KyPasteWin:Add, Checkbox, ys-5 x+50 w80 vMyAutoEnter1,自动回车
Gui,KyPasteWin:Add, Checkbox, Section x10 y+13 vMyOrderPaste gKyPasteWin_启用连续粘贴,连续粘贴
Gui KyPasteWin:Add,Text, ys h21, 分隔:
Gui,KyPasteWin:Add, DropDownList, ys-3 w80 vSpliterType gKyPasteWin_分隔切换, Tab||Enter|字符|方向键
Gui,KyPasteWin:Add, Edit, ys-3 w70 Hidden vSpliter,
Gui,KyPasteWin:Add, DropDownList, ys-3 xp w70 Hidden vSpliter_Des,向上|向下||向左|向右
Gui,KyPasteWin:Add, Checkbox, ys checked vNoLast, 末位不添加
Gui KyPasteWin:Add,Button,ys-3 xp+100 w25 h25 gKyPasteWin_Sub_Help,?
Gui KyPasteWin:Font
;~ Gui KyPasteWin:Show, w480 h540, %AppName%%AppVer%
Gui KyPasteWin:Show, , %AppName%%AppVer%
GuiControl,KyPasteWin:,MyWordsGroup, %Array_Group%
;GuiControl,KyPasteWin:,activewindow,%CurWin_Title%
;~ msgbox % CurWin_Title
GuiControl,ChooseString,activewindow,%CurWin_Title%
gosub,KyPasteWin_刷新常用词列表
;以下为移动窗体到屏幕右下角 ;{
WinGet, MyID, ID, A ; 获取 窗体ID.
WinGetPos,,, MyWindowWidth, MyWindowHeight, A
;---- 放置屏幕键盘在屏幕的底部(考虑到任务栏的位置):
SysGet, MyWorkArea, MonitorWorkArea, %MyMonitor%
; 计算用户窗体X坐标:
MyWindowX = %MyWorkAreaRight%
MyWindowX -= %MyWorkAreaLeft% ; 现在 MyWindowX 包含了显示器的宽度.
MyWindowX -= %MyWindowWidth%
MyWindowX += %MyWorkAreaWidth% ; 计算水平靠右的位置.
; 以下操作是为了防止窗体不是主显示器,或者任务栏停靠在屏幕左侧:
MyWindowX += %MyWorkAreaLeft%
; 计算用户窗体Y坐标:
MyWindowY = %MyWorkAreaBottom%
MyWindowY -= %MyWindowHeight%
WinMove, A,, %MyWindowX%, %MyWindowY%
WinSet, AlwaysOnTop, On, ahMyid %MyID%
;WinSet, TransColor, %TransColor% 220, ahMyid %MyID%
;}
return
;}
KyPasteWin_刷新常用词列表: ;{ ;KyPasteWin_刷新常用词列表
Gui KyPasteWin:Default
LV_Delete()
MyWordsList:=""
GuiControlget, MyWordsGroup,KyPasteWin:
IniRead,MyWordsList,%MyWordsINI%,%MyWordsGroup%
Loop,parse,MyWordsList,`n,`r
{
if (A_LoopField="")
continue
LV_Add(,A_LoopField)
}
return
;}
KyPasteWin_Sub_MyListItem: ;{ LV事件
if (A_GuiEvent="Normal"){
}else if (A_GuiEvent="DoubleClick"){
gosub,KyPasteWin_单项粘贴
}
return
;}
KyPasteWin_Sub_Help: ;{ 帮助
MsgStr:=""
MsgStr=%MsgStr%【脚本信息】-----------------------------------------------`n
MsgStr=%MsgStr%作者:Kawvin(285781427)`n
MsgStr=%MsgStr%功能:快捷粘贴常用数据,临时从剪贴板获取的数据`n
MsgStr=%MsgStr%【热键信息】-----------------------------------------------`n
MsgStr=%MsgStr%快捷键:可打开文件修改,说明:^=Ctrl,+=Shift,!=Alt,#=Win`n
MsgStr=%MsgStr%显示窗体:%LPasteHotKey%`n
MsgStr=%MsgStr%顺序粘贴:%LOrderHotKey%`n
MsgStr=%MsgStr%临时复制:%LCopyHotKey%`n
MsgStr=%MsgStr%【使用方法】-----------------------------------------------`n
MsgStr=%MsgStr%1、单项粘贴:`n ①在要粘贴数据的窗体上%LPasteHotKey%打开界面,先在窗体上选择插入位置,然后双击要插入的数据,如果插入失败,可以再使用Ctrl+V粘贴;`n②勾选【自动回车】,则粘贴数据后回车换行;`n
MsgStr=%MsgStr%2、连续粘贴:`n ①勾选【连续粘贴】后,选择分隔符,则上面选中的数据,在每项粘贴后,插入分隔符Tab/Enter/指定的字符/方向键(向上/向下/向左/向右)`n②勾选【末位不添加】,最后一项输入后无分隔符;`n
MsgStr=%MsgStr%3、从剪贴板导入:选中内容,按Ctrl+C复制后,回到本界面,【从剪贴板导入】导入【临时数据】列表,勾选【持续】,可连续导入;`n
MsgStr=%MsgStr%4、热键从剪贴板导入:选中内容,按临时复制热键(%LCopyHotKey%)直接导入【临时数据】列表,勾选【持续】,可连续导入;`n
MsgStr=%MsgStr%5、打开列表:默认为INI文件,可修改添加数据,列表以[xxx]分隔,下面是数据项;`n
MsgStr=%MsgStr%6、指定程序:指定粘贴到的窗体,如果不对,可选择或【刷新程序】后再选择。
MsgBox, 64, 提示, %MsgStr%
return
;}
KyPasteWin_单项粘贴: ;{ 粘贴选中项
Gui KyPasteWin:Default
GuiControlGet,MyOrderPaste,,MyOrderPaste
if (MyOrderPaste=1){
MsgBox, 16, 提示, 如果要使用双击粘贴,请关闭【连续粘贴】!
return
}
GuiControlget, MyAutoEnter1, KyPasteWin:
GuiControlget, Activewindow, KyPasteWin:
if (Activewindow="")
Activewindow:=CurWin_Title
FocusedRowNumber := LV_GetNext(0, "F") ; 查找焦点行.
if not FocusedRowNumber ; 没有焦点行.
return
LV_GetText(PasteContect, FocusedRowNumber, 1) ; 获取首个字段的文本.
ClipBoard:=PasteContect
ClipWait,0.5
WinActivate, %Activewindow%
sleep 300
send,^{vk56}
sleep,300
if (MyAutoEnter1=1) ;如果自动回车
send,{Enter}
return
;}
KyPasteWin_单行粘贴: ;{ 粘贴选中项
Gui KyPasteWin:Default
GuiControlGet,MyOrderPaste,,MyOrderPaste
if (MyOrderPaste=1){
MsgBox, 16, 提示, 如果要使用双击粘贴,请关闭【连续粘贴】!
return
}
GuiControlget, MyAutoEnter1, KyPasteWin:
GuiControlget, Activewindow, KyPasteWin:
if (Activewindow="")
Activewindow:=CurWin_Title
FocusedRowNumber := LV_GetNext(0, "F") ; 查找焦点行.
if not FocusedRowNumber ; 没有焦点行.
return
LV_GetText(PasteContect, FocusedRowNumber, 1) ; 获取首个字段的文本.
ClipBoard:=PasteContect
ClipWait,0.5
WinActivate, %Activewindow%
sleep 300
send,^{vk56}
sleep,300
if (MyAutoEnter1=1) ;如果自动回车
send,{Enter}
return
;}
;~ ^+v:: ;QZ插件,启用本行,热键【Ctrl+Shift+v】
KyPasteWin_顺序粘贴: ;{ 顺序粘贴选中项
Gui KyPasteWin:Default
GuiControlGet,MyOrderPaste,,MyOrderPaste
if (MyOrderPaste=0){
MsgBox, 16, 提示, 如果要使用双击粘贴,请勾选【连续粘贴】并选择多项内容!
return
}
GuiControlget, Activewindow, KyPasteWin:
if (Activewindow="")
Activewindow:=CurWin_Title
GuiControlGet,SpliterType,,SpliterType
GuiControlGet,Spliter,,Spliter
GuiControlGet,Spliter_Des,,Spliter_Des
GuiControlGet,NoLast,,NoLast
SelectedRows:=[]
RowNumber = 0 ; 这样使得首次循环从列表的顶部开始搜索.
Loop
{
RowNumber := LV_GetNext(RowNumber) ; 在前一次找到的位置后继续搜索.
SelectedRows.push(RowNumber)
if not RowNumber ; 上面返回零, 所以选择的行已经都找到了.
break
}
loop,% SelectedRows.length()
{
PasteContect:=SelectedRows[A_Index]
RowNumber := LV_GetNext(RowNumber) ; 在前一次找到的位置后继续搜索.
LV_GetText(PasteContect, RowNumber, 1)
if (PasteContect="数据内容") ;因为最后一个是LV的标题【数据内容】
break
ClipBoard:=PasteContect
ClipWait,0.5
WinActivate, %Activewindow%
sleep 300
send,^{vk56}
sleep,300
if (NoLast=1 && A_Index=SelectedRows.length()-1) ;因为最后一个是LV的标题【数据内容】,所以-1
break
if (SpliterType="Tab"){
send,{tab}
}else if (SpliterType="Enter"){
send,{Enter}
} else if (SpliterType="字符"){
Clipboard:=Spliter
sleep 100
send,^{vk56}
;~ send,{Raw}%Spliter%
} else if (SpliterType="方向键"){
if (Spliter_Des="向上"){
Send,{Up}
} if (Spliter_Des="向下"){
Send,{Down}
} if (Spliter_Des="向左"){
Send,{Left}
} if (Spliter_Des="向右"){
Send,{Right}
}
}
}
return
;}
KyPasteWin_复制数据: ;{ 复制数据
Gui,Submit,NoHide
MouseGetPos,,,CurWin_id ;当前鼠标下的进程ID
WinGet, CurWin_Fullpath,ProcessPath,Ahk_ID %CurWin_id% ;当前进程的路径
WinGetTitle, CurWin_Title,Ahk_ID %CurWin_id% ;当前进程的标题
CurWin_Saved_ClipBoard := ClipboardAll
Clipboard =
Send, ^c
ClipWait,0.5
if ( ErrorLevel ) ;如果没有选择到什么东西,则退出
{
Clipboard := CurWin_Saved_ClipBoard ;还原粘贴板
CurWin_Saved_ClipBoard =
Return
}
; 导入数据
Gui KyPasteWin:Default
if (MyWordsGroup!="临时数据")
GuiControl,ChooseString,MyWordsGroup, 临时数据
GuiControlGet,Sustain,,Sustain
if (Sustain!=1){
LV_Delete()
}
Loop,parse,Clipboard,`n,`r
{
if (A_LoopField="")
continue
LV_Add(,A_LoopField)
}
Clipboard := CurWin_Saved_ClipBoard
return
;}
KyPasteWin_启用连续粘贴: ;{
Gui KyPasteWin:Default
GuiControlGet,MyOrderPaste,,MyOrderPaste
if (MyOrderPaste=1){
GuiControl, +Multi, MyListItem
}else{
GuiControl, -Multi, MyListItem
}
return
;}
KyPasteWin_分隔切换: ;{
Gui KyPasteWin:Default
GuiControlGet,SpliterType,,SpliterType
if (SpliterType="字符"){
GuiControl, Hide, Spliter_Des
GuiControl,,Spliter,
GuiControl, Show, Spliter
} else if (SpliterType="方向键") {
GuiControl, Hide, Spliter
GuiControl,Choose,Spliter_Des, 2
GuiControl, Show, Spliter_Des
}else {
GuiControl, Hide, Spliter
GuiControl, Hide, Spliter_Des
}
return
;}
KyPasteWinGuiContextMenu: ;{ 右键菜单-备份项目列表
if (A_GuiControl="MyListItem") {
Menu,MyRightMenu,add
Menu,MyRightMenu,DeleteAll
Menu,MyRightMenu,add,单项粘贴,KyPasteWin_单项粘贴
Menu,MyRightMenu,add
Menu,MyRightMenu,add,顺序粘贴,KyPasteWin_顺序粘贴
Menu,MyRightMenu,add
Menu,MyRightMenu,add,向上移动,KyPasteWinButton向上移动
Menu,MyRightMenu,add,向下移动,KyPasteWinButton向下移动
menu,MyRightMenu,Show
}
return
;}
KyPasteWin_打开: ;{
run,%MyWordsINI%
return
;}
KyPasteWin_刷新程序列表(){ ;刷新已有窗体列表
droplist:=
GuiControl,KyPasteWin:,activewindow,|
WinGet, id, list,,, Program Manager
Loop, %id%
{
this_id := id%A_Index%
WinGetTitle, this_title, ahk_id %this_id%
if this_title=
continue
if (this_title=CurWin_Title)
droplist=%droplist%%this_title%||
else
droplist=%droplist%%this_title%|
}
GuiControl,KyPasteWin:,activewindow, %droplist%
;Gui, KyPasteWin:Add, DropDownList,x100 y5 w370 vactivewindow, %droplist%
}
KyPasteWinButton向上移动: ;{ 向上移动
Gui KyPasteWin:Default
FocusedRowNumber := LV_GetNext(0, "F") ; 查找焦点行.
if not FocusedRowNumber ; 没有焦点行.
return
if (FocusedRowNumber=1)
return
LV_GetText(LV_Item11, FocusedRowNumber, 1) ; 获取首个字段的文本.
LV_GetText(LV_Item21, FocusedRowNumber-1, 1) ; 获取首个字段的文本.
LV_Modify(FocusedRowNumber,, LV_Item21)
LV_Modify(FocusedRowNumber-1,, LV_Item11)
LV_Modify(FocusedRowNumber, "-Select . -Focus")
LV_Modify(FocusedRowNumber-1, "Select . Focus")
return
;}
KyPasteWinButton向下移动: ;{ 向下移动
Gui KyPasteWin:Default
FocusedRowNumber := LV_GetNext(0, "F") ; 查找焦点行.
if not FocusedRowNumber ; 没有焦点行.
return
if (FocusedRowNumber=LV_GetCount())
return
LV_GetText(LV_Item11, FocusedRowNumber, 1) ; 获取首个字段的文本.
LV_GetText(LV_Item21, FocusedRowNumber+1, 1) ; 获取首个字段的文本.
LV_Modify(FocusedRowNumber,, LV_Item21)
LV_Modify(FocusedRowNumber+1,, LV_Item11)
LV_Modify(FocusedRowNumber, "-Select . -Focus")
LV_Modify(FocusedRowNumber+1, "Select . Focus")
return
;}
KyPasteWinButton从剪贴板导入: ;{ 从剪贴板导入
Gui,Submit,NoHide
Gui KyPasteWin:Default
if (MyWordsGroup!="临时数据")
GuiControl,ChooseString,MyWordsGroup, 临时数据
GuiControlGet,Sustain,,Sustain
if (Sustain!=1){
LV_Delete()
}
Loop,parse,Clipboard,`n,`r
{
if (A_LoopField="")
continue
LV_Add(,A_LoopField)
}
GuiControl,ChooseString,MyWordsGroup, 临时数据
return
;}
KyPasteWinButton导入剪贴板: ;{ 导入剪贴板
Gui,Submit,NoHide
Gui KyPasteWin:Default
TempStr:=""
Loop % LV_GetCount()
{
LV_GetText(TemItem, A_Index,1)
TempStr .=TemItem "`n"
}
Clipboard:=TempStr
return
;}
MyFun_RetrunKeys(HotKeyString){ ;替换热键
StringReplace,HotKeyString,HotKeyString,`+,Shift`+,All
StringReplace,HotKeyString,HotKeyString,`!,Alt`+,All
StringReplace,HotKeyString,HotKeyString,`^,Ctrl`+,All
StringReplace,HotKeyString,HotKeyString,`#,Win`+,All
return , % HotKeyString
}
;~ KyPasteWinGuiClose:
;~ ExitApp
请教下,qz是啥?复制运行报错啊
学习
同样报错…打不开呀大佬