Skip to content

Commit

Permalink
Add common Library directory for scripts & Add Clipboard lib
Browse files Browse the repository at this point in the history
`Run` `Vim`: Support VSCode case
  • Loading branch information
pilgrimlyieu committed Oct 4, 2023
1 parent b5804aa commit d752ea6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
7 changes: 3 additions & 4 deletions General/Common/Run.ahk
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#NoTrayIcon

#Include ..\..\Library\Clipboard.ahk

; 请将 Everything 目录放 PATH
#f::{
ClipSaved := ClipboardAll(), A_Clipboard := ""
SendInput("{Ctrl Down}c{Ctrl Up}")
ClipWait(0.5, 0)
selected := Trim(A_Clipboard)
ClipLists := GetSelectedText(), ClipSaved := ClipLists[1], selected := ClipLists[2]
if DirExist(selected)
; "Run(everything -path `"" selected "`"") ; 为路径则打开路径(包括子文件夹)
Run("everything -parent `"" selected "`"") ; 为路径则打开路径(不包括子文件夹)
Expand Down
8 changes: 4 additions & 4 deletions General/Specific/Vim/Vim.ahk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#NoTrayIcon

#Include ..\..\..\Library\Clipboard.ahk

SetTitleMatchMode "RegEx"
SetWinDelay 0
MonitorGetWorkArea( , , , &WorkAreaInfoRight, &WorkAreaInfoBottom)
Expand Down Expand Up @@ -32,9 +34,7 @@ ListJoin(list, string) {
#HotIf !WinActive("ahk_class Vim")

!q::{
ClipSaved := ClipboardAll(), A_Clipboard := ""
SendInput("{Ctrl Down}c{Ctrl Up}")
clip_result := ClipWait(0.5, 0)
ClipLists := GetSelectedText(), ClipSaved := ClipLists[1], clip_result := ClipLists[2]
if InStr(A_Clipboard, "`r`n")
Run("gvim -d `"" ListJoin(StrSplit(A_Clipboard, "`r`n"), "`" `"") "`"", , , &process_id)
else if clip_result
Expand Down Expand Up @@ -62,4 +62,4 @@ CapsLock::SendInput("{Alt Down}{F12}{Alt Up}")
#Hotstring * C0 ? X

::jk::SendInput("{Esc}")
::kj::SendInput("{Esc}")
::kj::SendInput("{Esc}")
9 changes: 9 additions & 0 deletions Library/Clipboard.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
GetSelectedText(wait := 0.5) {
ClipSaved := ClipboardAll(), A_Clipboard := ""
if WinActive("ahk_exe Code.exe")
SendInput("{Alt Down}{Shift Down}c{shift Up}{Alt Up}")
else
SendInput("{Ctrl Down}c{Ctrl Up}")
ClipWait(0.5, 0)
return [ClipSaved, Trim(A_Clipboard)]
}

0 comments on commit d752ea6

Please sign in to comment.