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

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

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

0 件のコメント:

コメントを投稿