人気ブログランキング | 話題のタグを見る

AutoHotKey_Lで、パスリストをX-Finderのクリップフォルダに変換。Ver.1.2

 先々週書いたEverythingの検索結果をX-Finderで開くシリーズの最新版なんだけど、関数をEverything以外でも使えるようにしてみた。これで\n区切りのパスリストがあれば、なんでもサムネで確認できるよ!やったねry
 もっと機能追加してからPostしようと思って大していじらず1週間たってしまったのでエターナる前にPost。

 使用例は相変わらずEverything。検索結果の任意のアイテムを選択状態にしてF11を打鍵すると、X-Finderでクリップフォルダとして開く。Ctrl+F11なら、前回のクリップフォルダに追加。

 Everything以外は各自勝手に。InputBoxでIni名指定できたらブックマーク的に使えて便利かも。

 デフォルトのIni名にプレフィックスつけたんで、X-Finderのクリップフォルダ設定に;Extra:%X-Finder%CF_*.iniと加えとくと便利。

;--------------------------------------------------------------------------------------
; Everything
;--------------------------------------------------------------------------------------
#IfWinActive ahk_class ahk_class EVERYTHING

F11::
  #ClipboardTimeout 200000
  
  ClipWaitNull()
  Send, ^c
  ClipWait, 3
  if !ErrorLevel {
    CFPath := Path2ClipFld(Clipboard, "CF_Everything.ini")
    Run, "C:\X-Finder\XF.exe" "Extra:%CFPath%"  ; X-Finderのフルパス。
  }
  ClipWaitRestore()
return

^F11::
  #ClipboardTimeout 200000
  
  ClipWaitNull()
  Send, ^c
  ClipWait, 3
  if !ErrorLevel {
    CFPath := Path2ClipFld(Clipboard, "CF_Everything.ini", 1)
    Run, "C:\X-Finder\XF.exe" "Extra:%CFPath%"  ; X-Finderのフルパス。
  }
  ClipWaitRestore()
return


Path2ClipFld(PathList, ClipFldPath = 0, AddSW = 0) {  ; Ver.1.2
  XFPath := "C:\X-Finder\"  ; パスリストのデフォルト保存先。
  if ClipFldPath {
    IfNotInString, ClipFldPath, :\
      ClipFldPath := XFPath ClipFldPath
  } else {
    ClipFldPath := XFPath "CF_.ini"
  }
  
  StringReplace, PathList, PathList, `n, `n, UseErrorLevel
  PathNum := ErrorLevel + 1
  
  if AddSW
    IniRead, IniCnt, %ClipFldPath%, X-Finder, Count, 0
  else
    IniCnt := 0
  
  if !IniCnt
    ClipFldBuf := "[X-Finder]`nCount=" PathNum
  
  Loop, Parse, PathList, `n, `r
  {
    if ("\" == SubStr(A_LoopField, 0))
      ItemPath := SubStr(A_LoopField, 1, -1)
    else
      ItemPath := A_LoopField
    
    SplitPath, ItemPath, ItemName
    ItemNum := A_Index + IniCnt - 1
    
    ClipFldBuf .= "`nName" ItemNum "=" Str2RefStr(ItemName) "`nPath" ItemNum "=""" Str2RefStr(ItemPath) """`nType" ItemNum "=1"
  }
  
  if AddSW {
    IniCnt += PathNum
    IniWrite, %IniCnt%, %ClipFldPath%, X-Finder, Count
  } else {
    FileDelete, %ClipFldPath%
  }
  
  FileAppend, %ClipFldBuf%, %ClipFldPath%, CP932
  return, ClipFldPath
}

Str2RefStr(StrBuf) {
  Transform, StrBuf, HTML, %StrBuf%, 2
  SetFormat, Integer, H
  Loop {
    if !RegExMatch(StrBuf, "&#(\d+);", $)
      break
    
    TipNum := 0 + $1
    StringTrimLeft, TipNum, TipNum, 2
    if (0 != TipLen := 4 - StrLen(TipNum))
      Loop, %TipLen%
        TipNum := "0" + TipNum
    
    StringReplace, StrBuf, StrBuf, &#%$1%;, &#x%TipNum%;, All
  }
  SetFormat, Integer, D
  StringReplace, StrBuf, StrBuf, &, &, All
  return, StrBuf
}


ClipWaitNull(SW = 1) {
  if SW {
    global CBBackup
    CBBackup := ClipboardAll
  }
  
  Clipboard :=
  while Clipboard
    Sleep, 100
}

ClipWaitRestore() {
  global CBBackup
  
  ClipWaitNull(0)
  Clipboard := CBBackup
  ClipWait
}

 先人の作った「list2xf.exe」との違いは――AHKで応用しやすいってのと、Unicode文字対応ってあたりかなー。

 Everything Ver.1.4は普通のListViewになってたので、Clipboard経由せずControlGet, PathList, List, Selected, SysListView321, Aで取得して加工してもよい。





おまけ。

 拙作のOpenLater.ahkの登録アイテムを変換してみた。

;--------------------------------------------------------------------------------------
; OpenLater.ahk
;--------------------------------------------------------------------------------------
#IfWinActive OpenLater.ahk ahk_class AutoHotkeyGUI

F12::
  ControlGet, PathList, List, Col3, SysListView321
  CFPath := Path2ClipFld(PathList, "CF_OpenLater.ini")
  
  Run, "C:\X-Finder\XF.exe" "Extra:%CFPath%"  ; X-Finderのフルパス。
return


by lordnoesis | 2014-01-17 19:25 | テクノロジ | Trackback(5) | Comments(0)
Tracked from 名称未定っぽい。 at 2014-10-07 22:32
タイトル : AutoHotKey_Lで、標準出力を得る方法。
 AHKでCUIアプリの吐く標準出力を得る方法が分からんかったので調べたらフォーラムにあったのでメモ。日本語環境用にラスト1行だけ書き換えた。; http://www.autohotkey.com/board/topic/15455-stdouttovar/page-8#entry540600 MsgBox % sOutput := StdoutToVar_CreateProcess("tasklist /s " A_ComputerName) StdoutToVar_CreateProc...... more
Tracked from canada pharm.. at 2023-01-08 06:42
タイトル : canada pharmacy
AutoHotKey_Lで、パスリストをX-Finderのクリップフォルダに変換。Ver.1.2 : 名称未定っぽい。... more
Tracked from canadian onl.. at 2023-01-09 15:55
タイトル : canadian online pharmacies
AutoHotKey_Lで、パスリストをX-Finderのクリップフォルダに変換。Ver.1.2 : 名称未定っぽい。... more
Tracked from canada pharm.. at 2023-01-10 18:39
タイトル : canada pharmaceuticals online
AutoHotKey_Lで、パスリストをX-Finderのクリップフォルダに変換。Ver.1.2 : 名称未定っぽい。... more
Tracked from pharmeasy at 2023-01-11 13:02
タイトル : pharmeasy
AutoHotKey_Lで、パスリストをX-Finderのクリップフォルダに変換。Ver.1.2 : 名称未定っぽい。... more
ブログトップ | ファンになる