博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
剪贴板增强---Kawvin增强剪贴板_V2.0
阅读量:6095 次
发布时间:2019-06-20

本文共 17272 字,大约阅读时间需要 57 分钟。

#Persistent  SetWorkingDir,%A_ScriptDir%      ;设置工作目录  #MaxThreadsPerHotkey 5              ;最大热键数量  #NoEnv  ;#Warn  #SingleInstance force                      ;单脚本运行  #WinActivateForce                          ;强制激活窗体  Process Priority,,High                       ;线程,主,高级  CoordMode, Mouse                          ;鼠标相对于屏幕  AutoTrim,on                                     ;自动省略首尾的空格和Tab  SetBatchLines -1                              ;让脚本无休眠地执行(换句话说,也就是让脚本全速运行)  ComObjError(0)                               ;禁用  COM 错误通告  Menu, Tray, UseErrorLevel               ;阻止显示对话框和终止线程  ; #NoTrayIcon    Label_DefVar:      global MyAppVer:="Kawvin增强剪贴板v2.0(Q285781427)"      global MyClipBoard_ini:= "MyClipBoard.ini"            global All_Modes:="一次复制多次粘贴|多次复制一次粘贴|同时使用2个剪贴板|临时记事本|禁用"      global Sel_Mode:=                       ;当前模式      global EnableSound:=                ;启用声音      global CopyHotKey:=                 ;复制热键      global PasteHotKey:=                    ;粘贴热键      global BackHotKey:=                 ;多次向前      global PrevHotKey:=                 ;多次向后      global MenuHotKey:=             ;菜单热键      global ListWinHotKey:=              ;列表窗体热键      global LCopyHotKey:=                ;用于显示-复制热键      global LPasteHotKey:=               ;用于显示-粘贴热键      global LBackHotKey:=                ;用于显示-多次向前      global LPrevHotKey:=                    ;用于显示-多次向后      global LMenuHotKey:=                ;用于显示-菜单热键      global LListWinHotKey:=         ;用于显示-列表窗体热键        global MyClipMenu:=         ;定义剪贴板菜单      global CurWin_Title:=           ;当前鼠标下的窗体标题            global MyUseTongPei :=0     ;设置是否启用通配符      global MyPasteLine :=0      ;定义目前将要粘贴的行数      global MyClipArray:={}      ;定义剪贴板历史记录      global MyMaxID:=0           ;最大序号      global MySel:=                  ;定义临时存放变量      global MySelRich:=              ;定义临时存放变量      global MyAutoEnter :=       ;定义是否自动回车      global MyFirText:=              ;第一剪贴板内容      global MySecText:=          ;第二剪贴板内容      global MyWS:=                   ;位数      global MyStart:=                ;起始序号      global MyEnd:=                  ;终止序号      global MySpace:=                ;间距    Label_Start:      iniRead,Sel_Mode,%MyClipBoard_ini%,通用设置,当前模式      iniRead,EnableSound,%MyClipBoard_ini%,通用设置,启用声音      iniRead,CopyHotKey,%MyClipBoard_ini%,通用设置,复制热键      iniRead,PasteHotKey,%MyClipBoard_ini%,通用设置,粘贴热键      iniRead,BackHotKey,%MyClipBoard_ini%,通用设置,多次向前      iniRead,PrevHotKey,%MyClipBoard_ini%,通用设置,多次向后      iniRead,MenuHotKey,%MyClipBoard_ini%,通用设置,菜单热键      iniRead,ListWinHotKey,%MyClipBoard_ini%,通用设置,窗体热键        ;替换热键到正常键      LCopyHotKey:=MyFun_RetrunKeys(CopyHotKey)      LPasteHotKey:=MyFun_RetrunKeys(PasteHotKey)      LBackHotKey:=MyFun_RetrunKeys(BackHotKey)      LPrevHotKey:=MyFun_RetrunKeys(PrevHotKey)      LMenuHotKey:=MyFun_RetrunKeys(MenuHotKey)      LListWinHotKey:=MyFun_RetrunKeys(ListWinHotKey)      SkSub_CreatTrayMenu()      Label_RegHotKey:      CopyHotKey=$%CopyHotKey%      PasteHotKey=$%PasteHotKey%      BackHotKey=$%BackHotKey%      PrevHotKey=$%PrevHotKey%      MenuHotKey=$%MenuHotKey%      ListWinHotKey=$%ListWinHotKey%      if (Sel_Mode!="禁用")      {          hotkey,%CopyHotKey%,Label_Copy          hotkey,%PasteHotKey%,Label_Paste          hotkey,%BackHotKey%,Label_PasteBack          hotkey,%PrevHotKey%,Label_PastePrev          hotkey,%MenuHotKey%,TrayHandle_ShowMyClipArrayMenu          hotkey,%ListWinHotKey%,TrayHandle_ShowListWin      }    Label_DrawGUI:      gui Destroy      if Sel_Mode=一次复制多次粘贴      {          gui Main:+AlwaysOnTop          Gui Font, w700 cRed          Gui, Add, Text, x10 y5  h20 , 复制/添加:%LCopyHotKey%,1次粘贴:%LPasteHotKey%,②多次向:前%LBackHotKey%/后%LPrevHotKey%          Gui Font          Gui, Add, Edit, vMyFirText x12 y22 w360 h330 ,          Gui Font, w700 cRed          Gui, Add, CheckBox, Checked vMyAutoEnter gLabel_AutoEnter x230 y360 w210 h20 , 粘贴后自动回车          Gui Font          Gui, Add, Button, gLabel_GetData x20 y360 w80 h35 , ①数据确认          Gui, Add, Button, gLabel_Clear x102 y360 w80 h35 , 清空重置          Gui Font, s10 w700 cRed          gui,Add,Text,x195 y382 h20,当前模式:%Sel_Mode%          Gui Font          Gui, Show, x127 y87 h402 w385, %MyAppVer%      }       if Sel_Mode=多次复制一次粘贴      {          gui Main:+AlwaysOnTop          Gui Font, w700 cRed          Gui, Add, Text, x10 y5  h20 ,复制/添加:%LCopyHotKey%,粘贴:%LPasteHotKey%          Gui Font          Gui, Add, Edit, vMyFirText x12 y22 w360 h330 ,          Gui Font, w700 cRed          Gui, Add, CheckBox, Checked vMyAutoEnter gLabel_AutoEnter x230 y360 w210 h20 , 粘贴后自动回车          Gui Font          ;Gui, Add, Button, gLabel_GetData x20 y360 w80 h35 , 数据确认          Gui, Add, Button, gLabel_Clear x102 y360 w80 h35 , 清空重置          Gui Font, s10 w700 cRed          gui,Add,Text,x195 y382 h20,当前模式:%Sel_Mode%          Gui Font          Gui, Show, x127 y87 h402 w385, %MyAppVer%      }       if Sel_Mode=同时使用2个剪贴板      {          gui Main:+AlwaysOnTop          Gui Font, w700 cRed          Gui, Add, Text, x10 y5  h20 , 第1剪切板(复制:Alt+F11,粘贴:%LBackHotKey%)          Gui Font          Gui, Add, Edit, vMyFirText x12 y22 w360 h185 ,          Gui Font, w700 cRed          Gui, Add, Text, x12 y213 h20 , 第2剪切板(复制:Alt+F12,粘贴:%LPrevHotKey%)          Gui, Add, CheckBox, vMyUseTongPei gLabel_EnabledTongPei x273 y210 w120 h20 , 启用通配符(*)          Gui Font          Gui, Add, Edit, vMySecText x12 y230 w360 h90 ,          Gui, Add, Text, x12 y334 w30 h20 , 位数          Gui, Add, Edit, vMyWS x38 y330 w50 h20 ,          Gui, Add, UpDown, range1-9 x82 y330 w20 h20 , 1          Gui, Add, Text, x108 y334 w30 h20 , 起始          Gui, Add, Edit, vMyStart x134 y330 w50 h20 , 1          Gui, Add, UpDown, range1-999 x162 y330 w20 h20 , 1          Gui, Add, Text, x204 y334 w30 h20 , 终止          Gui, Add, Edit, vMyEnd x230 y330 w50 h20 ,          Gui, Add, UpDown, range1-999 x212 y330 w20 h20 , 99          Gui, Add, Text, x295 y334 w30 h20 , 间距          Gui, Add, Edit, vMySpace x322 y330 w50 h20 ,          Gui, Add, UpDown, range1-999 x352 y330 w20 h20 , 1          Gui Font, w700 cRed          Gui, Add, CheckBox, Checked vMyAutoEnter gLabel_AutoEnter x230 y360 w210 h20 , 粘贴后自动回车          Gui Font          ;Gui, Add, Button, gLabel_GetData x20 y360 w80 h35 , 数据确认          Gui, Add, Button, gLabel_Clear x102 y360 w80 h35 , 清空重置          Gui Font, s10 w700 cRed          gui,Add,Text,x195 y382 h20,当前模式:%Sel_Mode%          Gui Font          Gui, Show, x127 y87 h402 w385, %MyAppVer%      }       if Sel_Mode=临时记事本      {          gui Main:+AlwaysOnTop          Gui Font, w700 cRed          Gui, Add, Text, x10 y5  h20 , 复制/添加:%LCopyHotKey%,1次粘贴:%LPasteHotKey%,②多次向:前%LBackHotKey%/后%LPrevHotKey%          Gui Font          Gui, Add, Edit, vMyFirText x12 y22 w360 h330 ,          Gui Font, w700 cRed          Gui, Add, CheckBox, Checked vMyAutoEnter gLabel_AutoEnter x230 y360 w210 h20 , 粘贴后自动回车          Gui Font          Gui, Add, Button, gLabel_GetData x20 y360 w80 h35 , ①数据确认          Gui, Add, Button, gLabel_Clear x102 y360 w80 h35 , 清空重置          Gui Font, s10 w700 cRed          gui,Add,Text,x195 y382 h20,当前模式:%Sel_Mode%          Gui Font          Gui, Show, x127 y87 h402 w385, %MyAppVer%      }       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    ;=========================  ;我的过程  SkSub_CreatTrayMenu()  {      Menu,Tray,DeleteAll      Menu, Tray, NoStandard        ;自定义菜单放在标准菜单上面      iniRead,Sel_Mode,%MyClipBoard_ini%,通用设置,当前模式      if Sel_Mode=禁用          menu,tray,icon,ICONS\KCx.ico      else          menu,tray,icon,ICONS\KC.ico      loop,parse,All_Modes,`|      {          if A_LoopField!=          {              Menu, tray, add,%A_LoopField%,TrayHandle_ModeChange              if (A_LoopField=Sel_Mode)                  menu,tray,Check ,%A_LoopField%          }      }      Menu,tray, add ; 分隔符      menu,tray,add,清空剪贴板,TrayHandle_ClearCllipBoard      Menu, tray, add ,剪贴板序列菜单,TrayHandle_ShowMyClipArrayMenu      Menu, tray, add ,显示剪贴板列表窗体,TrayHandle_ShowListWin      Menu, tray, add ; 分隔符      Menu,tray, add,参数设置,TrayHandle_EditSetting      Menu,tray, add ; 分隔符      Menu, tray, add ,退出,TrayHandle_Exit      Menu, Tray, Default, 剪贴板序列菜单      Menu, Tray, Click, 1   }  return    SkSub_CreatMyClipArrayMenu()  {      if MyClipArray.Length()<=1          return      Menu,MyClipMenu,DeleteAll      loop % MyClipArray.Length()      {          MyClipItem:=          if strlen(MyClipArray[A_Index])>20          {              MyClipItem:=substr(MyClipArray[A_Index],1,20) . "......"           } else {              MyClipItem:=% MyClipArray[A_Index]          }          menu,MyClipMenu,add,%MyClipItem%,MenuHandle_SetMenuItemToClipBoard          menu,MyClipMenu,Icon,%MyClipItem%,ICONS\%A_Index%.ico      }      menu,MyClipMenu,add      menu,MyClipMenu,add,清空历史记录,MenuHandle_ClearMenuItem      ;Menu, MyClipMenu, Show   }  return    TrayHandle_ShowMyClipArrayMenu:  {      ;MouseGetPos,Menu_X, Menu_Y      MouseGetPos,,,CurWin_id         ;当前鼠标下的进程ID      WinGet, CurWin_Fullpath,ProcessPath,Ahk_ID %CurWin_id%    ;当前进程的路径      WinGetTitle, CurWin_Title,Ahk_ID %CurWin_id%    ;当前进程的标题      Menu, MyClipMenu, Show  }  return    MenuHandle_SetMenuItemToClipBoard:      MyPasteLine:=A_ThisMenuItemPos      ClipBoard:=MyClipArray[MyPasteLine]      ClipWait,0.5      send,^{vk56}  return    MenuHandle_ClearMenuItem:      MyClipArray:={}      Clipboard:=      Menu,MyClipMenu,DeleteAll  return    TrayHandle_ShowListWin:      gosub ,Label_GetData      GuiControlGet,MyFirText,,MyFirText      MouseGetPos,,,CurWin_id         ;当前鼠标下的进程ID      WinGet, CurWin_Fullpath,ProcessPath,Ahk_ID %CurWin_id%    ;当前进程的路径      WinGetTitle, CurWin_Title,Ahk_ID %CurWin_id%    ;当前进程的标题      Gui MyListWin:New      Gui MyListWin:+AlwaysOnTop      Gui MyListWin:Font, s12      Gui MyListWin:Add,Text, x5 y13  h21,指定的程序:      Gui,MyListWin:Add, DropDownList,x100 y10 w300 vactivewindow,       Gui MyListWin:Add,Button,x405 y9 w70 gMySub_RefreshList,刷新      MySub_RefreshList()      MyListItems:=      if MyClipArray.Length()=0          return      loop % MyClipArray.Length()      {          if (A_Index=1)              MyListItems:=MyClipArray[A_Index]          else              MyListItems:=MyListItems . "|" . MyClipArray[A_Index]      }            Gui MyListWin:Add,ListBox,  x5  w470 h465 vMyListItem gMySub_PastMyListItem, %MyListItems%      Gui MyListWin:Font      Gui MyListWin:Show, w480 h500, 剪贴板列表  return    TrayHandle_ClearCllipBoard:      Clipboard:=  return    TrayHandle_ModeChange:      Sel_Mode:=A_ThisMenuItem      iniwrite,%Sel_Mode%,%MyClipBoard_ini%,通用设置,当前模式      Reload  return        TrayHandle_EditSetting:      ;gui Destroy      gui MySetWin:New      ;Gui MySetWin:+OwnerMain      gui MySetWin:+AlwaysOnTop      Gui MySetWin:Font, s12      Gui MySetWin:Add, GroupBox, x11 y6 w315 h185, 热键指定:通用      Gui MySetWin:Font      Gui MySetWin:Font, s11      Gui MySetWin:Add, Text, x25 y35 w105 h23 +0x200 Right, 复制:      Gui MySetWin:Add, Edit, x145 y35 w165 h21      Gui MySetWin:Add, Text, x25 y65 w105 h23 +0x200 Right, 一次性粘贴:      Gui MySetWin:Add, Edit, x145 y65 w165 h21      Gui MySetWin:Add, Text, x25 y95 w105 h23 +0x200 Right, 向前粘贴:      Gui MySetWin:Add, Edit, x145 y95 w165 h21      Gui MySetWin:Add, Text, x25 y125 w105 h23 +0x200 Right, 向后粘贴:      Gui MySetWin:Add, Edit, x145 y125 w165 h21      Gui MySetWin:Add, Text, x25 y155 w105 h23 +0x200 Right, 弹出菜单:      Gui MySetWin:Add, Edit, x145 y155 w165 h21      Gui MySetWin:Add, Button, x65 y205 w75 h30, 确认      Gui MySetWin:Add, Button, gWinSetButtonCancel x200 y205 w75 h30, 取消      Gui MySetWin:Font      Gui MySetWin:Show, w340 h250, 参数设置  return    MySub_RefreshList()  {      droplist:=      GuiControl,MyListWin:,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,MyListWin:,activewindow, %droplist%      ;Gui, MyListWin:Add, DropDownList,x100 y5 w370 vactivewindow, %droplist%  }    MySub_PastMyListItem()  {      GuiControlget,activewindow,MyListWin:      ;MsgBox % activewindow      if A_GuiEvent =DoubleClick      {          ClipBoard:=MyClipArray[A_EventInfo]          sleep 100          ;WinWaitActive, %CurWin_Title% ,,5          WinActivate, %activewindow%          send,^{vk56}      }  }    WinSetButtonCancel:  {      Gui MySetWin:Destroy      return  }    MySetWin确认:  {      Gui MySetWin:Destroy      return  }    Label_Copy:      if (Sel_Mode="一次复制多次粘贴" or Sel_Mode="多次复制一次粘贴" or Sel_Mode="临时记事本")      {          Clipboard =          Send, ^{vk43}          ClipWait,0.5          if ( ErrorLevel  )          ;如果没有选择到什么东西,则退出              Return          if MyFirText=              MyFirText=%Clipboard%          else              MyFirText=%MyFirText%`n%Clipboard%          Clipboard =          GuiControl,,MyFirText,%MyFirText%      }   return    Label_Paste:      Critical, On      GuiControlget, MyAutoEnter      GuiControlget, MyFirText      if (Sel_Mode="一次复制多次粘贴" or Sel_Mode="多次复制一次粘贴" or Sel_Mode="临时记事本")      {          if MyFirText=              return          else          {              if MyClipArray.Length()=0                  Clipboard:=MyFirText              sleep 100              if (MyAutoEnter=1)      ;如果自动回车              {                  send,^{vk56}                  send,{Enter}              } else {                  send,^{vk56}              }              Clipboard:=          }      }   return    !F11::      Critical, On      if Sel_Mode=同时使用2个剪贴板      {          GuiControl,,MyFirText,          Clipboard =          Send, ^{vk43}          ClipWait,0.5          if ( ErrorLevel  )          ;如果没有选择到什么东西,则退出              Return          GuiControl,,MyFirText,%Clipboard%          Clipboard =      }   return    !F12::      Critical, On      if Sel_Mode=同时使用2个剪贴板      {          GuiControl,,MySecText,          Clipboard =          Send, ^{vk43}          ClipWait,0.5          if ( ErrorLevel  )          ;如果没有选择到什么东西,则退出              Return          GuiControl,,MySecText,%Clipboard%          Clipboard =      }   return    Label_PasteBack:      Critical, On      GuiControlget, MyAutoEnter      if (Sel_Mode="一次复制多次粘贴" or  Sel_Mode="临时记事本")      {          if (MyPasteLine=-1) ;粘贴行数-1时,退出              Return          MyPasteLine -=1          if (MyPasteLine <1)  ;粘贴行数大于最大行数,不粘贴          {              MyPasteLine:=0              return          }          Clipboard:=MyClipArray[MyPasteLine]          sleep 100          if (MyAutoEnter=1)      ;如果自动回车          {              send,^{vk56}              send,{Enter}          } else {              send,^{vk56}          }          Clipboard:=      }       if (Sel_Mode="同时使用2个剪贴板")      {          GuiControlGet, MyFirText          if MyFirText=              return          else          {              Clipboard:=MyFirText              sleep 100              if (MyAutoEnter=1)      ;如果自动回车              {                  send,^{vk56}                  send,{Enter}              } else {                  send,^{vk56}              }              Clipboard:=          }      }   return    Label_PastePrev:      Critical, On      GuiControlget, MyAutoEnter      if (Sel_Mode="一次复制多次粘贴" or  Sel_Mode="临时记事本")      {          if (MyPasteLine=-1) ;粘贴行数-1时,退出              Return          MyPasteLine +=1          if (MyPasteLine > MyMaxID)   ;粘贴行数大于最大行数,不粘贴          {              MyPasteLine:=MyMaxID+1              return          }          Clipboard:=MyClipArray[MyPasteLine]          sleep 100          if (MyAutoEnter=1)      ;如果自动回车          {              send,^{vk56}              send,{Enter}          } else {              send,^{vk56}          }          Clipboard:=      }       if (Sel_Mode="同时使用2个剪贴板")      {          GuiControlGet, MySecText          GuiControlGet, MyWS          GuiControlGet, MyStart          GuiControlGet, MyEnd          GuiControlGet, MySpace          GuiControlGet, MyUseTongPei          if MySecText=       ;第二剪贴板为空,退出              Return          if (MyUseTongPei=0) ;不启用通配符          {              Clipboard:=MySecText              sleep 100              if (MyAutoEnter=1)  ;如果自动回车              {                  send,^{vk56}                  send,{Enter}              } else {                  send,^{vk56}              }              Clipboard:=          }          if (MyUseTongPei=1) ;启用通配符          {              if (MyStart

 

转载于:https://www.cnblogs.com/zhanglei1371/p/6664883.html

你可能感兴趣的文章
【FJOI2015】金币换位问题
查看>>
HighChar
查看>>
window上安装pymysql
查看>>
控件调用函数
查看>>
activity的启动模式
查看>>
Android主线程、子线程通信(Thread+handler)
查看>>
gitlab配置邮箱
查看>>
Win10桌面奔溃怎么办?雨林木风Win10奔溃解决方法教程
查看>>
mysql Inoodb 内核
查看>>
Redis 基础
查看>>
UITextField的returnkey点击事件
查看>>
特殊字体引用
查看>>
owlcar 用法心得 自定义导航
查看>>
数据结构 学习笔记03——栈与队列
查看>>
DB2 OLAP函数的使用(转)
查看>>
数学之美系列二十 -- 自然语言处理的教父 马库斯
查看>>
Android实现自定义位置无标题Dialog
查看>>
面试总结
查看>>
Chrome浏览器播放HTML5音频没声音的解决方案
查看>>
easyui datagrid 行编辑功能
查看>>