{"id":2268,"date":"2016-05-28T17:58:56","date_gmt":"2016-05-28T12:28:56","guid":{"rendered":"http:\/\/www.automationrepository.com\/?p=2268"},"modified":"2016-05-28T17:59:47","modified_gmt":"2016-05-28T12:29:47","slug":"qtp-uft-batch-run-prevent-windows-from-getting-locked","status":"publish","type":"post","link":"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/","title":{"rendered":"UFT Batch Run &#8211; Prevent Windows from getting locked during Script Execution"},"content":{"rendered":"<p>We had previously talked about a method whereby you can <a href=\"http:\/\/www.automationrepository.com\/2013\/07\/prevent-windows-lock-during-qtp-batch-run\/\" target=\"_blank\">use Windows Media Player to prevent Windows from getting locked<\/a> while your QTP\/UFT batch run is in progress. Here are few more alternative methods you can use to make this work<!--more--><\/p>\n<p>&nbsp;<\/p>\n<h3>1. Use VBScript SendKeys to simulate keypress at regular intervals<\/h3>\n<p>Copy the below code in a text file and save it with a .vbs extension<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nDim durationInMins\r\nSet obj = CreateObject(&quot;WScript.Shell&quot;)\r\n\r\n'Capture the input from user\r\ndurationInMins = InputBox (&quot;Enter time (in minutes) for which machine needs to remain unlocked&quot; &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; &quot;Enter 0 for indefinite time&quot;,&quot;Enter Duration&quot;)\r\n\r\nIf durationInMins &amp;gt; 0 Then\r\n\t'Run For loop for the duration specified by the user\r\n\tFor i=1 to durationInMins\r\n\t\tWScript.Sleep (60*1000)\r\n\t\tobj.SendKeys (&quot;{CAPSLOCK 2}&quot;)\r\n\tNext\r\nElseIf durationInMins = 0 Then\r\n\t'Run indefinite Do loop\r\n\tDo\r\n\t\tWScript.Sleep (60*1000)\r\n\t\tobj.SendKeys (&quot;{CAPSLOCK 2}&quot;)\r\n\tLoop\r\nEnd If\r\n<\/pre>\n<p>When you open this VBScript file in your machine, it will display a popup where you will need to specify the time (in minutes) for which Windows needs to remain unlocked. Enter 0 if you want this utility to run indefinitely. Entering a specific time limit rather than 0 is useful in scenarios where you don&#8217;t want the machine to keep running unnecessarily.<\/p>\n<p>For example, consider a scenario where you want to execute a nightly batch run. And you know, by previous experience, that the UFT would take around 2-3 hours to complete the batch execution. In such a case, it will be good to specify the time in the alert box as 180 or 200, so that the machine comes to normal mode after this time duration and gets locked or shutdown.<\/p>\n<p><strong>How this code works<\/strong><\/p>\n<p>This code simply uses VBScript SendKeys method to simulate keyboard key press every one minute; thereby preventing windows from getting locked. Here we are using CAPS LOCK key to simulate the key press, using the code &#8211; <strong>SendKeys (&#8220;{CAPSLOCK 2}&#8221;)<\/strong>.<\/p>\n<p>You would have noticed the number 2 next to CAPSLOCK. This means that the CAPSLOCK key is pressed twice in very quick succession. This makes sure that CAPSLOCK remains in the same state and doesn&#8217;t interfere in your work in any way.<\/p>\n<p>There are many other flavors of this code, in which people use different keys such as SCROLLLOCK, NUMLOCK, F15 etc. All these work fine without any issues and you can use any of these if you would want to modify the code.<\/p>\n<p>&nbsp;<\/p>\n<h3>2. Using 3rd party software<\/h3>\n<p>There are many 3rd party software (many with source code), which simulate keypress or mouse movements to keep your machine unlocked. Couple of them which I have used in the past are &#8211;<\/p>\n<p><a href=\"https:\/\/mousejiggler.codeplex.com\/\" target=\"_blank\">Mouse Jiggler<\/a> &#8211; This software works by jiggling the mouse pointer back and forth<\/p>\n<p><a href=\"http:\/\/www.zhornsoftware.co.uk\/caffeine\/\" target=\"_blank\">Caffeine<\/a> &#8211; Another useful utility which simulates F15 keypress to prevent windows getting locked<\/p>\n<p>&nbsp;<\/p>\n<h3>3. Plug and Use USB devices<\/h3>\n<p>While searching on the internet, I came across these USB devices which create constant mouse activity so your computer won&#8217;t go idle. You can search on Amazon if you want to have a look at these USB devices.<\/p>\n<p>These were all the different methods that I have heard of and tried (except Pt 3 &#8211; Plug and Use USB devices) on my own. You can even integrate these utilities with your <a href=\"http:\/\/www.automationrepository.com\/qtp-framework\/\" target=\"_blank\">UFT\/QTP frameworks<\/a> to provide more power to your automation frameworks.<\/p>\n<p>Have you used any other piece of code or utility, which is not covered here? Let us know about it in the comments section.<\/p>\n<p>&nbsp;<\/p>\n<div style=\"font-family: Verdana,sans-serif; border: 1px solid #C8B560; padding: 3mm; background: #FFF8C6; text-align: center;\">\n<p><strong>If you enjoyed this article, you can join our blog to get new articles delivered directly in your inbox.<\/strong><\/p>\n<form style=\"text-align: center;\" action=\"http:\/\/feedburner.google.com\/fb\/a\/mailverify\" method=\"post\" target=\"popupwindow\"><input style=\"width: 160px; height: 20px;\" type=\"text\" value=\"Enter Your Email Address\" \/> <input name=\"uri\" type=\"hidden\" value=\"automationrepository\/feeds\" \/> <input name=\"loc\" type=\"hidden\" value=\"en_US\" \/> <input type=\"submit\" value=\"Join Us\" \/><\/p>\n<p style=\"text-align: justify;\">\n<\/form>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We had previously talked about a method whereby you can use Windows Media Player to prevent Windows from getting locked while your QTP\/UFT batch run is in progress. Here are few more alternative methods you can use to make this work<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,9],"tags":[],"class_list":["post-2268","post","type-post","status-publish","format-standard","hentry","category-qtp-basic-stuff","category-qtp-concepts"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>UFT Batch Run - Prevent Windows from getting locked during Script Execution - XX<\/title>\n<meta name=\"description\" content=\"Use these methods to prevent windows from getting locked while executing your QTP\/UFT batch run. Implement it as an integral part of your QTP frameworks\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anish Pillai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/\",\"name\":\"UFT Batch Run - Prevent Windows from getting locked during Script Execution - XX\",\"isPartOf\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\"},\"datePublished\":\"2016-05-28T12:28:56+00:00\",\"dateModified\":\"2016-05-28T12:29:47+00:00\",\"author\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\"},\"description\":\"Use these methods to prevent windows from getting locked while executing your QTP\/UFT batch run. Implement it as an integral part of your QTP frameworks\",\"breadcrumb\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.automationrepository.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"UFT Batch Run &#8211; Prevent Windows from getting locked during Script Execution\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/\",\"name\":\"XX\",\"description\":\"\\r\\nasas\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.automationrepository.com\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\",\"name\":\"Anish Pillai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g\",\"caption\":\"Anish Pillai\"},\"description\":\"Find more about Anish Pillai on Google+\",\"sameAs\":[\"http:\/\/www.automationrepository.com\"],\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/author\/anish\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UFT Batch Run - Prevent Windows from getting locked during Script Execution - XX","description":"Use these methods to prevent windows from getting locked while executing your QTP\/UFT batch run. Implement it as an integral part of your QTP frameworks","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/","twitter_misc":{"Written by":"Anish Pillai","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/","url":"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/","name":"UFT Batch Run - Prevent Windows from getting locked during Script Execution - XX","isPartOf":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#website"},"datePublished":"2016-05-28T12:28:56+00:00","dateModified":"2016-05-28T12:29:47+00:00","author":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20"},"description":"Use these methods to prevent windows from getting locked while executing your QTP\/UFT batch run. Implement it as an integral part of your QTP frameworks","breadcrumb":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.automationrepository.com\/wordpress\/2016\/05\/qtp-uft-batch-run-prevent-windows-from-getting-locked\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.automationrepository.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"UFT Batch Run &#8211; Prevent Windows from getting locked during Script Execution"}]},{"@type":"WebSite","@id":"https:\/\/www.automationrepository.com\/wordpress\/#website","url":"https:\/\/www.automationrepository.com\/wordpress\/","name":"XX","description":"\r\nasas","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.automationrepository.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20","name":"Anish Pillai","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g","caption":"Anish Pillai"},"description":"Find more about Anish Pillai on Google+","sameAs":["http:\/\/www.automationrepository.com"],"url":"https:\/\/www.automationrepository.com\/wordpress\/author\/anish\/"}]}},"_links":{"self":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/2268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2268"}],"version-history":[{"count":12,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/2268\/revisions"}],"predecessor-version":[{"id":2280,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/2268\/revisions\/2280"}],"wp:attachment":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}