<input type="hidden" id="_wpnonce" name="_wpnonce" value="797351d72b" /><input type="hidden" name="_wp_http_referer" value="/blog/wp-json/wp/v2/posts/3504" /><input type="hidden" id="_wpnonce" name="_wpnonce" value="797351d72b" /><input type="hidden" name="_wp_http_referer" value="/blog/wp-json/wp/v2/posts/3504" />{"id":3504,"date":"2015-06-08T21:22:35","date_gmt":"2015-06-08T11:22:35","guid":{"rendered":"https:\/\/www.businesslegions.com\/blog\/?p=3504"},"modified":"2015-06-08T21:22:35","modified_gmt":"2015-06-08T11:22:35","slug":"using-screencapture-icyscreen-in-batch-file","status":"publish","type":"post","link":"https:\/\/www.businesslegions.com\/blog\/2015\/06\/08\/using-screencapture-icyscreen-in-batch-file\/","title":{"rendered":"Using Screencapture IcyScreen in batch file"},"content":{"rendered":"<!--CusAds0--><p>Several posts ago I mentioned about a tool that I use called IcyScreen to capture screenshots of a monitoring system that I use for work. You can read this here: <a href=\"https:\/\/www.businesslegions.com\/blog\/2015\/03\/06\/automatic-screenshots-using-icyscreen\/\" target=\"_blank\">Automatic Screenshots using IcyScreen<\/a>. I setup IcyScreen to capture the screen at an interval of 30 minutes, however, I found that this was not the best setup because the capture would often miss an important event. After several discussions with the team at IcyScreen (great support by the way), we came to a solution. Initially, I had the idea to write a visual basic script to run a batch file to start the monitoring software and then send the Print Screen command. Unfortunately, this was not possible with Visual Basic so the alternative was to setup the IcyScreen software with the Keyword Detection feature. So if a keyword is typed e.g &#8220;livemonitor&#8221;, it would take a screenshot. So combining this feature and creating a Visual Basic script solved the problem. See below for the VBS code.<\/p>\n<p><a href=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/IcyScreen-Keyword-Monitor.png?strip=all&w=2560\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3505\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/IcyScreen-Keyword-Monitor.png?strip=all\" alt=\"IcyScreen Keyword Monitor\" width=\"581\" height=\"507\" srcset=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/IcyScreen-Keyword-Monitor.png?strip=all 581w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/IcyScreen-Keyword-Monitor-300x262.png?strip=all 300w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/IcyScreen-Keyword-Monitor.png?strip=all&amp;w=116 116w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/IcyScreen-Keyword-Monitor.png?strip=all&amp;w=232 232w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/IcyScreen-Keyword-Monitor.png?strip=all&amp;w=464 464w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><\/a><\/p>\n<h2>The Visual Basic Code<\/h2>\n<div id=\"wpshdo_1\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_1\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_1\"><\/a><a id=\"wpshat_1\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_1\"  onClick=\"javascript:wpsh_toggleBlock(1)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_code(1)\" title=\"Show code only\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_print(1)\" title=\"Print code\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"https:\/\/www.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif?strip=all&w=960\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_1\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"php\" style=\"font-family:monospace;\">Dim WinScriptHost\nSet WinScriptHost <span class=\"sy0\">=<\/span> CreateObject<span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;WScript.Shell&quot;<\/span><span class=\"br0\">&#41;<\/span>\nWinScriptHost<span class=\"sy0\">.<\/span>Run <a href=\"http:\/\/www.php.net\/chr\"><span class=\"kw3\">Chr<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"nu0\">34<\/span><span class=\"br0\">&#41;<\/span> <span class=\"sy0\">&amp;<\/span> <span class=\"st0\">&quot;D:\\batchfile.bat&quot;<\/span> <span class=\"sy0\">&amp;<\/span> <a href=\"http:\/\/www.php.net\/chr\"><span class=\"kw3\">Chr<\/span><\/a><span class=\"br0\">&#40;<\/span>34<span class=\"br0\">&#41;<\/span><span class=\"sy0\">,<\/span> 0\nSet WinScriptHost <span class=\"sy0\">=<\/span> Nothing\nWScript<span class=\"sy0\">.<\/span><a href=\"http:\/\/www.php.net\/sleep\"><span class=\"kw3\">Sleep<\/span><\/a> <span class=\"nu0\">120000<\/span>\nSet WshShell <span class=\"sy0\">=<\/span> WScript<span class=\"sy0\">.<\/span>CreateObject<span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;WScript.Shell&quot;<\/span><span class=\"br0\">&#41;<\/span>\nWshShell<span class=\"sy0\">.<\/span>SendKeys <span class=\"st0\">&quot;livemonitor&quot;<\/span><\/pre><\/div><\/div>\n<h2>Download Example<\/h2>\n<div class='w3eden'><!-- WPDM Link Template: Default Template -->\n\n<div class=\"link-template-default card mb-2\">\n    <div class=\"card-body\">\n        <div class=\"media\">\n            <div class=\"mr-3 img-48\"><img decoding=\"async\" class=\"wpdm_icon\" alt=\"Icon\"   src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/download-manager\/assets\/file-type-icons\/css.png?strip=all&w=960\" \/><\/div>\n            <div class=\"media-body\">\n                <h3 class=\"package-title\"><a href='https:\/\/www.businesslegions.com\/blog\/download\/visual-basic-script-with-sendkeys\/'>Visual Basic Script with sendkeys<\/a><\/h3>\n                <div class=\"text-muted text-small\"><i class=\"fas fa-copy\"><\/i> 1 file(s) <i class=\"fas fa-hdd ml-3\"><\/i> 0.32 KB<\/div>\n            <\/div>\n            <div class=\"ml-3\">\n                <a class='wpdm-download-link download-on-click btn btn-primary ' rel='nofollow' href='#' data-downloadurl=\"https:\/\/www.businesslegions.com\/blog\/download\/visual-basic-script-with-sendkeys\/?wpdmdl=3508&refresh=6a0e3826931fa1779316774\">Download<\/a>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n\n<\/div>\n<h2>Script Explanation<\/h2>\n<h3>Part 1 &#8211; run batch file silently<\/h3>\n<pre>Dim WinScriptHost\r\nSet WinScriptHost = CreateObject(\"WScript.Shell\")\r\nWinScriptHost.Run Chr(34) &amp; \"D:\\batchfile.bat\" &amp; Chr(34), 0\r\nSet WinScriptHost = Nothing\r\n\r\n<\/pre>\n<p>The first 4 lines is used to run a batch file called batchfile.bat located on the D: of my computer. When this part of the visual basic script is executed, the command prompt run but it is not actually displayed at all i.e it run silently in the background.<\/p>\n<h3>Part 2 &#8211; Pause<\/h3>\n<pre>WScript.Sleep 120000<\/pre>\n<p>The script then waits for 120 seconds (2 minutes) before it runs the next section. Note that this is in milliseconds. I decided to put this in because it would take about 30 seconds for the tool to load completely and wanted to make sure it runs before it takes a screenshot.<\/p>\n<h3>Part 3 &#8211; Send keyword keys<\/h3>\n<pre>Set WshShell = WScript.CreateObject(\"WScript.Shell\") \r\nWshShell.SendKeys \"livemonitor\"<\/pre>\n<p>This part of the script sends the live monitoring keyword &#8220;livemonitor&#8221; (it&#8217;s like typing the keyword on the keyboard) so that the IcyScreen software can detect it and then take the screen capture.<\/p>\n<div class=\"lt-box\" style=\"border:1px solid #1a4ccc\"><div class=\"lt-box-title\" style=\"background-color:#215fff;border-top:1px solid #a6bfff;text-shadow:1px 1px 0 #0a1c4c\">RESOURCES<\/div><div class=\"lt-box-content\">Here&#8217;s a list of resources that you might find useful:<\/p>\n<p><a href=\"http:\/\/www.16software.com\/icyscreen\/\">IcyScreen Software<\/a> &#8211; Awesome software to take screen captures<\/p>\n<p>Example Visual Basic Script\u00a0<div class='w3eden'><!-- WPDM Link Template: Default Template -->\n\n<div class=\"link-template-default card mb-2\">\n    <div class=\"card-body\">\n        <div class=\"media\">\n            <div class=\"mr-3 img-48\"><img decoding=\"async\" class=\"wpdm_icon\" alt=\"Icon\"   src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/download-manager\/assets\/file-type-icons\/css.png?strip=all&w=960\" \/><\/div>\n            <div class=\"media-body\">\n                <h3 class=\"package-title\"><a href='https:\/\/www.businesslegions.com\/blog\/download\/visual-basic-script-with-sendkeys\/'>Visual Basic Script with sendkeys<\/a><\/h3>\n                <div class=\"text-muted text-small\"><i class=\"fas fa-copy\"><\/i> 1 file(s) <i class=\"fas fa-hdd ml-3\"><\/i> 0.32 KB<\/div>\n            <\/div>\n            <div class=\"ml-3\">\n                <a class='wpdm-download-link download-on-click btn btn-primary ' rel='nofollow' href='#' data-downloadurl=\"https:\/\/www.businesslegions.com\/blog\/download\/visual-basic-script-with-sendkeys\/?wpdmdl=3508&refresh=6a0e3826952751779316774\">Download<\/a>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n\n<\/div>\n<p><a href=\"https:\/\/www.businesslegions.com\/blog\/2014\/08\/09\/create-cron-jobs-wamp\/\">Article on how to setup schedule tasks<\/a><\/p>\n<\/div><\/div>\n<div class=\"lt-box\" style=\"border:1px solid #1d6a9e\"><div class=\"lt-box-title\" style=\"background-color:#2485C6;border-top:1px solid #a7cee8;text-shadow:1px 1px 0 #0b283b\">DO YOU LIKE WHAT YOU'VE READ?<\/div><div class=\"lt-box-content\">Join our subscription list and receive our content right in your mailbox. If you like to receive some Great deals our Freebies then subscribe now!\r\n\r\n<p><div class=\"tnp tnp-subscription \">\n<form method=\"post\" action=\"https:\/\/www.businesslegions.com\/blog\/wp-admin\/admin-ajax.php?action=tnp&amp;na=s\">\n<input type=\"hidden\" name=\"nlang\" value=\"\">\n<div class=\"tnp-field tnp-field-firstname\"><label for=\"tnp-1\">Name<\/label>\n<input class=\"tnp-name\" type=\"text\" name=\"nn\" id=\"tnp-1\" value=\"\" placeholder=\"\"><\/div>\n<div class=\"tnp-field tnp-field-email\"><label for=\"tnp-2\">Email<\/label>\n<input class=\"tnp-email\" type=\"email\" name=\"ne\" id=\"tnp-2\" value=\"\" placeholder=\"\" required><\/div>\n<div class=\"tnp-field tnp-field-button\" style=\"text-align: left\"><input class=\"tnp-submit\" type=\"submit\" value=\"Subscribe\" style=\"\">\n<\/div>\n<\/form>\n<\/div>\n<\/p>\r\n\r\n<\/div><\/div><!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Several posts ago I mentioned about a tool that I use called IcyScreen to capture screenshots of a monitoring system that I use for work. You can read this here: Automatic Screenshots using IcyScreen. I setup IcyScreen to capture the screen at an interval of 30 minutes, however, I found that this was not the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3511,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1882,1881,593,1851],"class_list":["post-3504","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-keyword-detection","tag-script-explanation","tag-setup","tag-visual-basic"],"_links":{"self":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/3504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/comments?post=3504"}],"version-history":[{"count":6,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/3504\/revisions"}],"predecessor-version":[{"id":3515,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/3504\/revisions\/3515"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/media\/3511"}],"wp:attachment":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/media?parent=3504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/categories?post=3504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/tags?post=3504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}