{"id":175,"date":"2010-08-04T21:20:37","date_gmt":"2010-08-05T04:20:37","guid":{"rendered":"http:\/\/www.dreness.com\/blog\/?p=175"},"modified":"2010-08-04T21:20:37","modified_gmt":"2010-08-05T04:20:37","slug":"somniac-and-a-ui-scripting-quickie","status":"publish","type":"post","link":"https:\/\/dreness.com\/blog\/archives\/175","title":{"rendered":"Somniac and a UI scripting quickie"},"content":{"rendered":"<p>Just about every time I want an AppleScript to wait a second or two during script execution, I instinctively insert a &#8220;sleep x&#8221; statement, where x is some small number of seconds. Every time, I&#8217;m surprised when I test the script and my computer promptly&#8230; goes to sleep. The command to use is delay, not sleep :)<\/p>\n<p>&#8212;<\/p>\n<p>Here&#8217;s a short bit of UI scripting I use to wrangle the MouseZoom prefpane, which I require prior to playing Quake4 to get just the right mouse acceleration curve. Even though it&#8217;s just an extra click-and-wait, the whole 32 \/ 64 bit prefpane shuffle has me kinda annoyed, hence this script.<\/p>\n<pre>tell application \"System Events\"\r\n\ttell application \"System Preferences\"\r\n\t\tactivate\r\n\t\tset current pane to pane id \"com.benhines.mousezoompp\"\r\n\tend tell\r\n\tdelay 1\r\n\ttell process \"System Preferences\"\r\n\t\tclick button \"OK\" of sheet 1 of window \"Loading MouseZoom\u2026\"\r\n                             --that's an elipsis! accessibility inspector ftw\r\n\t\tdelay 2\r\n\t\tkeystroke tab\r\n\t\tkeystroke tab\r\n\t\tkeystroke \".02\"\r\n\t\tkeystroke tab\r\n\tend tell\r\nend tel<\/pre>\n<p><a href=\"http:\/\/www.dreness.com\/blog\/wp-content\/uploads\/2010\/03\/loading-mousezoom.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-147\" title=\"loading-mousezoom\" src=\"http:\/\/www.dreness.com\/blog\/wp-content\/uploads\/2010\/03\/loading-mousezoom.png\" alt=\"\" width=\"501\" height=\"549\" srcset=\"https:\/\/dreness.com\/blog\/wp-content\/uploads\/2010\/03\/loading-mousezoom.png 501w, https:\/\/dreness.com\/blog\/wp-content\/uploads\/2010\/03\/loading-mousezoom-273x300.png 273w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just about every time I want an AppleScript to wait a second or two during script execution, I instinctively insert a &#8220;sleep x&#8221; statement, where x is some small number of seconds. Every time, I&#8217;m surprised when I test the &hellip; <a href=\"https:\/\/dreness.com\/blog\/archives\/175\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,6,13],"tags":[],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-bitbucket","category-scripts","category-the-more-you-know"],"_links":{"self":[{"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":3,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":178,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions\/178"}],"wp:attachment":[{"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}