{"id":1026,"date":"2015-09-05T20:23:38","date_gmt":"2015-09-05T14:23:38","guid":{"rendered":"http:\/\/promincproductions.com\/blog\/?p=1026"},"modified":"2015-09-04T21:00:51","modified_gmt":"2015-09-04T15:00:51","slug":"automate-website-screenshots-autohotkey-and-fireshot","status":"publish","type":"post","link":"https:\/\/promincproductions.com\/blog\/automate-website-screenshots-autohotkey-and-fireshot\/","title":{"rendered":"Automate Website Screenshots &#8211; AutoHotKey and FireShot"},"content":{"rendered":"<p>I like to keep a snapshot of websites on a daily basis for various reasons. \u00a0<a href=\"http:\/\/getfireshot.com\/\" target=\"_blank\" data-lasso-id=\"487\" rel=\"noopener\">FireShot<\/a> certainly is one of the best plugins for accomplishing screenshots, but it doesn&#8217;t have an automated method inherently built into it. \u00a0So that&#8217;s where <a href=\"http:\/\/www.autohotkey.com\/\" target=\"_blank\" data-lasso-id=\"488\" rel=\"noopener\">AutoHotkey <\/a>comes into play. \u00a0AutoHotkey allows you to automate some remedial tasks in Windows.<\/p>\n<figure id=\"attachment_1027\" aria-describedby=\"caption-attachment-1027\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/09\/AutoHotkey-FireShot-Chrome.jpg\" rel=\"attachment wp-att-027\" data-lasso-id=\"489\" data-rel=\"lightbox-gallery-DLdhAa7N\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" class=\"size-medium wp-image-1027\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/09\/AutoHotkey-FireShot-Chrome-500x228.jpg\" alt=\"AutoHotkey FireShot Chrome to Automate Screenshots\" width=\"500\" height=\"228\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/09\/AutoHotkey-FireShot-Chrome-500x228.jpg 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/09\/AutoHotkey-FireShot-Chrome-150x69.jpg 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/09\/AutoHotkey-FireShot-Chrome.jpg 600w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-1027\" class=\"wp-caption-text\">Use FireShot in Chrome with AutoHotkey to automate screenshots. The scripts can then be automated with Windows Task Scheduler.<\/figcaption><\/figure>\n<h2>Install Software<\/h2>\n<p>First thing is first, for this tutorial you&#8217;ll need a Windows based machine with Chrome installed. \u00a0Also install AutoHotkey and FireShot. \u00a0I&#8217;m not going to go into detail on how to get there.<\/p>\n<h2>Configure Keyboard Shortcut in Chrome for\u00a0FireShot<\/h2>\n<p>The next step is getting Chrome to be able to run FireShot within Chrome via a keyboard shortcut. \u00a0This is where I ran into the biggest issue &#8211; FireShot does allow for setting keyboard shortcuts to various functions via their options. \u00a0And I was using this in AutoHotkey for the longest time, and then it stopped working and I haven&#8217;t fully figured out why. \u00a0But even using the keyboard shortcut outside of the automation at times seems to not work the best&#8230; \u00a0That&#8217;s the reason for using the API like this method suggests.<\/p>\n<h3>Create Custom Search Engine<\/h3>\n<ul>\n<li>Right-click on the address bar in Chrome and choose\u00a0<strong>Edit search engines&#8230;<\/strong>.<\/li>\n<li>Scroll to the bottom and find the blank fields to add a new search engine.\n<ul>\n<li>The first field is the name of the search engine &#8211; this can be anything you&#8217;d like.<\/li>\n<li>In the keyword field is where you enter what keyword will trigger the search engine &#8211; I sued\u00a0<strong>SaveVisible<\/strong><\/li>\n<li>The last field is where you put the FireShot API code. \u00a0So enter this in that field:\n<pre><code>javascript: \r\n var element = document.createElement(\"FireShotDataElement\");\r\n element.setAttribute(\"Entire\", \"false\");\r\n element.setAttribute(\"Action\", 1);\r\n element.setAttribute(\"Key\", \"\");\r\n element.setAttribute(\"BASE64Content\", \"\");\r\n element.setAttribute(\"Data\", \"fireshot\");\r\n\r\n if (typeof(CapturedFrameId) != \"undefined\")\r\n element.setAttribute(\"CapturedFrameId\", CapturedFrameId);\r\n\r\n document.documentElement.appendChild(element);\r\n\r\n var evt = document.createEvent(\"Events\");\r\n evt.initEvent(\"capturePageEvt\", true, false);\r\n\r\n element.dispatchEvent(evt);<\/code><\/pre>\n<\/li>\n<li>Click\u00a0<strong>Done<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Create Bookmarklet (Optional)<\/h3>\n<p>This really isn&#8217;t needed for the automation piece, but if you&#8217;d like you could create a bookmarklet in Chrome with the same block of code above. \u00a0This way you can click one button to trigger something different if you&#8217;d like.<\/p>\n<ul>\n<li>On the bookmark bar in Chrome, right-click and choose\u00a0<strong>Add page&#8230;<\/strong><\/li>\n<li>In the\u00a0<strong>Name<\/strong>\u00a0field, choose whatever name you&#8217;d like to show on the bookmark bar.<\/li>\n<li>In the\u00a0<strong>URL<\/strong> field enter the block of code above.<\/li>\n<li>Click\u00a0<strong>Save<\/strong>.<\/li>\n<\/ul>\n<h3>FireShot API Options (Optional)<\/h3>\n<p>There are a few customizations you can make to the code above.<\/p>\n<ul>\n<li>Line 3 &#8211; Entire\n<ul>\n<li>This allows you to specify if you want to capture the entire page or just what is visible.<\/li>\n<li>Possible Values:\n<ul>\n<li>true = entire page<\/li>\n<li>false = visible portion<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Line 4 &#8211; Action\n<ul>\n<li>This specifies what action you&#8217;d like FireShot to perform.<\/li>\n<li>Possible Values:\n<ul>\n<li>0 &#8211; Edit in FireShot<\/li>\n<li>1 &#8211; Save to Hard Drive<\/li>\n<li>2 &#8211; Copy\u00a0to Clipboard<\/li>\n<li>3 &#8211; Email image<\/li>\n<li>4 &#8211; Export to 3rd party editor<\/li>\n<li>5 &#8211; Upload to free image hosting<\/li>\n<li>7 &#8211; Print<\/li>\n<li>8 &#8211; Base64 Encode<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>File Naming Options<\/h3>\n<p>The file name that the image saves as can be customized in the Chrome extension directly. \u00a0Click on the icon in Chrome and choose\u00a0<strong>Miscellaneous\u00a0-&gt; Options<\/strong>. \u00a0Then under\u00a0<strong>Editor options<\/strong> click\u00a0<strong>Click to setup&#8230;<\/strong>. \u00a0Choose\u00a0<strong>Capturing<\/strong> and in here you can setup the file name pattern.<\/p>\n<h2>AutoHotkey Script<\/h2>\n<p>Now that you have FireShot all setup, it&#8217;s time to write an AutoHotkey script that will trigger this. \u00a0You can use any text editor (Notepad, Notepad++, etc.) to create this.<\/p>\n<ul>\n<li>Create a new file<\/li>\n<li>Save it to any location on your computer with whatever filename you like. \u00a0The file extension needs to be .ahk<\/li>\n<li>Add this code to the file and save it.\n<pre><code>; Open Chrome and focus\r\nRun, chrome.exe, , max\r\nWinWait, New Tab\r\n\r\n; Get window ID\r\nWinGet, active_id, ID, A\r\n\r\n; Maximize window\r\nWinMaximize, ahk_id %active_id%\r\n\r\n\r\n\r\n; +++ Capture Page #1 +++ ;\r\n;Highlight address bar\r\nSendInput, ^l\r\nSleep, 2000\r\n\r\n; Navigate\r\nSendInput, www.promincproductions.com\/blog\/{Enter}\r\nSleep, 11000\r\n\r\n;Highlight address bar\r\nSendInput, ^l\r\nSleep, 2000\r\n\r\n;Save visible using a custom search engine that triggers the Fireshot API\r\nSendInput, SaveVisible{Enter}\r\nSleep, 3000\r\nSend !s\r\nSleep, 6000\r\nSend {Enter}\r\n\r\n\r\n\r\n; +++ Capture Page #2 +++ ;\r\n; Reactivate window - Minumum should be 4000\r\nSleep, 10000\r\nWinActivate, ahk_id %active_id%\r\n\r\n;Highlight address bar\r\nSendInput, ^l\r\nSleep, 2000\r\n\r\n; Navigate\r\nSendInput, youtube.com\/prominc{Enter}\r\nSleep, 11000\r\n\r\n;Highlight address bar\r\nSendInput, ^l\r\nSleep, 2000\r\n\r\n;Save visible using a custom search engine that triggers the Fireshot API\r\nSendInput, SaveVisible{Enter}\r\nSleep, 3000\r\nSend !s\r\nSleep, 6000\r\nSend {Enter}\r\n\r\n\r\n\r\n; Reactivate window\r\nSleep, 4000\r\nWinActivate, ahk_id %active_id%\r\nWinClose, ahk_id %active_id%\r\n\r\n\r\n; Open the destination directory to leave a trace that this ran\r\nRun explorer.exe C:\\`,\/e\r\n\r\nreturn<\/code><\/pre>\n<\/li>\n<li>This script has a few assumptions in it that you may want to change.\n<ul>\n<li>The Chrome custom search engine I put in above is named\u00a0<strong>SaveVisible<\/strong> &#8211; change that to whatever name you used.<\/li>\n<li>This script runs through two webpages and captures the screen &#8211; you will want to change those two URLs to whatever sites you wish to capture. \u00a0Lines 19 &amp; 45.<\/li>\n<li>After the script has ran, it opens a Windows Explorer window to show that it ran. \u00a0I set this to the location of where the images were saved. \u00a0But for this example script it&#8217;s set to the root of the C drive. \u00a0Line 68\n<ul>\n<li>Note &#8211; FireShot will save to the last used folder by default. \u00a0So keep that in mind and try to use the same folder for this process.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Schedule The Script To Run<\/h2>\n<p>Now we can use the Windows Scheduler to run this script moving forward.<\/p>\n<ul>\n<li>Start Button -&gt; Control Panel -&gt; Administrative Tools -&gt; Task Scheduler.<\/li>\n<li>Click\u00a0<strong>Create Task<\/strong>\u00a0<\/li>\n<li>Set the <strong>General<\/strong> tab as you see fit.<\/li>\n<li>Under the <strong>Triggers<\/strong> tab, create whatever trigger you wish &#8211; I prefer a time based trigger.<\/li>\n<li>Under the\u00a0<strong>Actions<\/strong> tab click\u00a0<strong>New<\/strong> to create a new action.\n<ul>\n<li>Choose\u00a0<strong>Start<\/strong>\u00a0<strong>a Program<\/strong><\/li>\n<li>Browse to the .ahk file you created in the above step<\/li>\n<\/ul>\n<\/li>\n<li>Save this task and you should be all set to go!<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>I like to keep a snapshot of websites on a daily basis for various reasons. \u00a0FireShot certainly is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1027,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[53,18],"tags":[],"class_list":["post-1026","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-autohotkey","category-computers"],"jetpack_featured_media_url":"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/09\/AutoHotkey-FireShot-Chrome.jpg","jetpack_shortlink":"https:\/\/wp.me\/p4BbcR-gy","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/comments?post=1026"}],"version-history":[{"count":1,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1026\/revisions"}],"predecessor-version":[{"id":1028,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1026\/revisions\/1028"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media\/1027"}],"wp:attachment":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media?parent=1026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/categories?post=1026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/tags?post=1026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}