1. 程式人生 > 其它 >使用AutoIt自動截圖並生成pdf

使用AutoIt自動截圖並生成pdf

版本資訊:

AutoIt V3.0

截圖工具:Nircmd

png圖片壓縮工具:pngquant

-------------------------------------------------------------------------

1. 螢幕截圖

命令列方式截圖,採用nircmd工具,

>> nircmd.exe savescreenshot [螢幕矩形]

螢幕矩形包含四個元素(x,y,w,h),分別為螢幕起點(x,y), 矩形高度和寬度(w,h),

e.g. >> 1016 73 526 936

2. 圖片壓縮

命令列方式的壓縮,採用pngquant工具

>> pngquant.exe --force --output outputFile 128 inputFile

執行命令即可對png圖片進行壓縮,這裡128表示調色盤的顏色數量。

壓縮效果圖:

壓縮前為400多kb,壓縮後為100多kb, 壓縮率70%, 如果想要更好質量或者更高壓縮率,可以研究下命令選項,進行設定。

3. 生成PDF

採用Miktex套件生成pdf,由於素材為圖片,這裡採用graphicx巨集包,插入圖片,居中對齊。每個圖片佔用一頁。

\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\graphicspath{{D:/book/}}


\begin{document}
\clearpage
\begin{figure}[!h]
\centering
\includegraphics{0001.png}
\end{figure}

\clearpage
\begin{figure}[!h]
\centering
\includegraphics{0002.png}
\end{figure}

這裡直接用pdflatex命令,生成pdf

>>pdflatex main.tex

4. 流程控制和滑鼠/按鍵模擬

採用AutoIt進行滑鼠或者按鍵的模擬,以及流程控制。

主要涉及內容:

檔案拷貝>>DirRemove

資料夾建立>>DirCreate

命令列呼叫>>RunWait

滑鼠點選>> MouseClick

檔案寫入>>FileWrite

檔案開啟>>FileOpen

檔案關閉>>FileClose

                      ------------------------ 勿在浮沙築高臺