{"id":1263,"date":"2010-08-24T16:24:01","date_gmt":"2010-08-24T16:24:01","guid":{"rendered":"http:\/\/www.mjtnet.com\/blog\/?p=1263"},"modified":"2010-08-24T16:24:01","modified_gmt":"2010-08-24T16:24:01","slug":"dont-overwhelm-your-target","status":"publish","type":"post","link":"https:\/\/www.mjtnet.com\/blog\/2010\/08\/24\/dont-overwhelm-your-target\/","title":{"rendered":"Don&#8217;t Overwhelm your Target!"},"content":{"rendered":"<p>When sending keystrokes to other applications remember that Macro Scheduler works much faster than a human being can type.  Many applications do form field verification or background processing on the fly as the text is received.  And most applications were designed on the assumption that a human being would be operating them.  It may not have occurred to the developers that a robot might try to send a stream of text to the UI at the rate of 5000 characters a second!<\/p>\n<p>With some applications if you try to send too many characters at once you may find that some of those characters fail to show up, or the string is truncated.  <\/p>\n<p>The solution should be obvious by now.  That is to slow down the key send rate.  You can do this easily by setting the SK_DELAY parameter which introduces a specified millisecond delay between each character.<\/p>\n<pre name=\"code\" class=\"macroscript\">Let>SK_DELAY=20\r\nSend>long_string<\/pre>\n<p>Of course you could break the long string down into smaller chunks and insert a delay between them:<\/p>\n<pre name=\"code\" class=\"macroscript\">Send>part_1\r\nWait>0.3\r\nSend>part_2\r\nWait>0.2\r\nSend>part_3<\/pre>\n<p>But SK_DELAY is simpler and easier if you can&#8217;t control the length of the data easily.<\/p>\n<p>A related issue I see every now and then is when &#8220;tabbing&#8221; from one field to another on a form.  Pressing the tab key moves the focus to the next field, so we use this while sending data into a form.  Sometimes we&#8217;ll encounter an application which needs a bit of time after a field has been focused before it can accept data, or the other way around.  So sending Tab immediately after\/before sending the data with no delay fails to work.  Adding in a small delay between sending the data and the Tab solves it:<\/p>\n<pre name=\"code\" class=\"macroscript\">Send>field_data\r\nWait>0.3\r\nPress Tab\r\n\r\nWait>0.3\r\nSend>next_field\r\nWait>0.3\r\nPress Tab\r\n\r\netc<\/pre>\n<p>Similarly when we need to tab through lots of fields at once without sending data we may try to save ourselves coding time by writing:<\/p>\n<pre name=\"code\" class=\"macroscript\">Press Tab * 10<\/pre>\n<p>But if the app needs time to react between each tab we may have to split that out into separate tabs with delays between them or replace with a repeat\/until loop:<\/p>\n<pre name=\"code\" class=\"macroscript\">Let>tabs=0\r\nRepeat>tabs\r\n  Press Tab\r\n  Wait>0.2\r\n  Let>tabs=tabs+1\r\nUntil>tabs=10<\/pre>\n<p>As I&#8217;ve said many times before the most common causes of things not working as expected are either timing or focus.  Macros run way faster than a human can type which is often beneficial but if things aren&#8217;t quite right start off by slowing the macro down a bit.  You can always speed it up later!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When sending keystrokes to other applications remember that Macro Scheduler works much faster than a human being can type. Many applications do form field verification or background processing on the fly as the text is received. And most applications were designed on the assumption that a human being would be operating them. It may not [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,6],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1263"}],"collection":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/comments?post=1263"}],"version-history":[{"count":8,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1263\/revisions"}],"predecessor-version":[{"id":1271,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1263\/revisions\/1271"}],"wp:attachment":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/media?parent=1263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/categories?post=1263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/tags?post=1263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}