2024年4月25日木曜日

xyzzyでスクリーンショット

xyzzyで

  • スクリーンショットを撮ってあらかじめ指定したディレクトリに保存
  • 保存したファイルのパスを貼り付け

という処理ができるようにする。winshotを利用。

準備

以下をsite-lispフォルダに保存。winshotのパスや保存フォルダは各自読み替えてください。

; -*- Mode: Lisp -*-
;;
;; winshotで矩形スクリーンショットを撮って保存。そのパスを貼り付ける
;;
;; Installation:
;;
;; ~/.xyzzy または $XYZZY/site-lisp/siteinit.l に以下のコードを追加
;;
;; (require "screenshot")
;winshotの実行ファイルパス
(defvar *winshot-exe* "D:\\bin\\winshot\\winshot.exe")
;スクリーンショット保存フォルダ
(defvar *screenshot-dir* "D:\\work\\SS")
;保存ファイルの書式
(defvar *screenshot-filename* "%Y-%m-%d-%H%M%S.jpg")
;winshotのオプション
(defvar *winshot-option* "-Jpeg -Rectangle -Close -File")
(defun screenshot ()
(interactive)
(let* ((filename (format-date-string *screenshot-filename*))
(dirname *screenshot-dir*)
(filepath (merge-pathnames filename dirname))
(winshotpath *winshot-exe*)
(option *winshot-option*))
(progn (call-process (concat winshotpath " " option " " filepath))
(insert (map-slash-to-backslash filepath)))))
view raw screenshot.l hosted with ❤ by GitHub

.xyzzyに以下を追記

(load-library "screenshot")    

やり方

M-x screenshot

スクリーンショットしたい箇所を矩形選択

スクリーンショットが保存され、かつそのパスが貼り付けられる

2024年4月9日火曜日

一行編集でエイリアスを登録

一行編集を利用し、実行ファイルを容易にエイリアスに登録できるようにする。

準備

まずは、実行ファイルを羅列した補完候補ファイルを用意する。作り方は色々あるが、*whereisを使うのが簡単。

*whereis -mask1:"a:d+;.exe" -path:"D:\bin" -dir:on -subdir:on -listfile:%0data\execpath -name

以下を編集して取込。

_Command    = {    ; ユーザコマンド・関数
setalias    = *string o,strings=%*input("" -title:"実行ファイルを選択してください" -mode:u,e -leavecancel -k:"*completelist -file:%%0data\execpath -match:6 -detail:""user"" %%: *mapkey use,K_exesearch")
 *string o,valuename=%"エイリアス名を登録してください"%{%*name(X,"%so"strings"")%}
 *alias %so"valuename"=%so"strings"
}

以下のコマンドを実行する。

*setalias

2024年4月7日日曜日

テキストファイルで画像ファイルを扱いたい

MV_click    = {    ; PPv メイン窓
LD_SPC    ,*ifmatch 0,0%*selecttext %: %K"@Q %: *stop
    *ifmatch "o:e,a:d-",%*selecttext %: *ppv %*selecttext %: *stop
    %K"@Q
}

今回は、テキストファイルで画像ファイルを扱う方法のアイデア。

画像ファイルのパスを挿入したテキストファイルをPPvで開き、[I]でキャレットモードに。ファイルパスにキャレットをあわせ、ダブルクリックする。

すると、ファイルパスの内容が別のPPvで表示される。