%Authors : quentin.vaney@gmail.com;xavier.freléchoz@gmail.com%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{screenshooter}[2024/05/06 Package that takes screenshot]

\RequirePackage{graphicx}
\RequirePackage{catchfile}

\newcommand{\screenshooter}[5]{%
   \immediate\write18{java -jar latexscreenshooter.jar #1 #2 #3 #4 #5}%
   \IfFileExists{#5#4.png}{%
     \begin{center}
       \includegraphics[width=#2px, height=#3px]{#5#4.png}%
     \end{center}
   }{%
     \IfFileExists{#5/#4.png}{%
       \begin{center}
         \includegraphics[width=#2px, height=#3px]{#5/#4.png}%
       \end{center}
     }{%
       \IfFileExists{#4.png}{%
         \begin{center}
           \includegraphics[width=#2px, height=#3px]{#4.png}%
         \end{center}
       }{%
         \begin{center}
           \fbox{\textbf{Image not found}}%
         \end{center}
       }%
     }%
   }%
}

