<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andrew Guyton's Blog &#187; utility</title>
	<atom:link href="http://disavian.no-ip.info/tag/utility/feed/" rel="self" type="application/rss+xml" />
	<link>http://disavian.no-ip.info</link>
	<description>programming/photography/gaming/reviews</description>
	<lastBuildDate>Tue, 10 Nov 2009 06:03:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Better Together: AutoHotKey and WinSplit Revolution</title>
		<link>http://disavian.no-ip.info/autohotkey-winsplit-revolution/</link>
		<comments>http://disavian.no-ip.info/autohotkey-winsplit-revolution/#comments</comments>
		<pubDate>Thu, 28 May 2009 06:46:29 +0000</pubDate>
		<dc:creator>disavian</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[autohotkey]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://disavian.no-ip.info/?p=307</guid>
		<description><![CDATA[One of the quirks about my laptop is that the numpad is accessed by a mysterious [fn] key that doesn&#8217;t &#8220;show up&#8221; internally in Windows. As such, it&#8217;s apparently difficult to write commands that use it or any of the features it accesses. Instead of Send {fn}{F7} to decrease the brightness, for example, I&#8217;d have [...]]]></description>
			<content:encoded><![CDATA[<p>One of the quirks about my laptop is that the numpad is accessed by a mysterious [fn] key that doesn&#8217;t &#8220;show up&#8221; internally in Windows. As such, it&#8217;s apparently difficult to write commands that use it or any of the features it accesses. Instead of Send {fn}{F7} to decrease the brightness, for example, I&#8217;d have to do something more creative.</p>
<p>One of my favorite utilities is <a href="http://winsplit-revolution.com/">WinSplit Revolution</a>, which is especially handy for large displays. Its largest feature is the ability to press Ctrl+Alt+[Numpad number] to quickly move the active window to the desired side/corner of a window. Sadly, Ctrl+Alt+[fn][numpad] on my laptop doesn&#8217;t generate a keystroke. So, <a href="http://www.autohotkey.com/">AutoHotKey</a> to save the day.<span id="more-307"></span></p>
<p>It made sense to map the row of keys on the right side of my laptop (from top to bottom: home, page up, page down, end) as I probably wouldn&#8217;t be overriding another important keystroke, and they are sort of near where the number pad would be. While WinSplit lets you manually assign keystrokes, I wouldn&#8217;t have been able to use the Windows key, and if I connected a USB keyboard with a real number pad (something I sometimes do) I wanted all of the program&#8217;s normal functionality available.</p>
<p>The AHK script is as follows:</p>
<blockquote><pre>;WinSplit Revolution Laptop Compatibility
#Delete::Send ^!{Numpad5}
#PgUp::Send ^!{Numpad8}
#PgDn::Send ^!{Numpad2}
#Home::Send ^!{Numpad4}
#End::Send ^!{Numpad6}</pre>
</blockquote>
<p><br/></p>
<p>In plain english:</p>
<blockquote><pre>Win+Delete -> Center (fill/third/two thirds)
Win+Home -> Left half (half/third/two thirds)
Win+Pg up -> Top half
Win+Pg dn -> Bottom half
Win+End -> Right half</pre>
</blockquote>
<p><br/></p>
<p>While I&#8217;d initially decided that Ctrl+Win+(relevant key) would be a good replacement, I decided that I could drop the Ctrl to simplify the keystroke. There are probably many other intuitive (or more functional) methods I could have tried, such as attempting to replicate all </p>
]]></content:encoded>
			<wfw:commentRss>http://disavian.no-ip.info/autohotkey-winsplit-revolution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to AutoHotKey</title>
		<link>http://disavian.no-ip.info/introduction-to-autohotkey/</link>
		<comments>http://disavian.no-ip.info/introduction-to-autohotkey/#comments</comments>
		<pubDate>Wed, 04 Oct 2006 22:10:08 +0000</pubDate>
		<dc:creator>disavian</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[autohotkey]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://disavian.no-ip.info/blog/?p=4</guid>
		<description><![CDATA[When you use a system for years, you get used to the annoyances. You stop noticing things that don&#8217;t make sense, or work  around them. Every day, you do things that could be done a smarter way. It&#8217;s just the way things are. Macro programs, today&#8217;s  topic, are just another step in customizing [...]]]></description>
			<content:encoded><![CDATA[<p>When you use a system for years, you get used to the annoyances. You stop noticing things that don&#8217;t make sense, or work  around them. Every day, you do things that could be done a smarter way. It&#8217;s just the way things are. Macro programs, today&#8217;s  topic, are just another step in customizing your workspace, similar to rearranging toolbars or icons.<span id="more-4"></span></p>
<h3 id="toc-but-i-hate-macro-programs">But I hate macro programs!</h3>
<p>Now, when I think &#8220;macro program,&#8221; I generally think of the thousand iterations of confusing macro support in Microsoft  Office programs. Then, I think of the &#8220;actions&#8221; in Photoshop, which are actually useful. Don&#8217;t get me wrong, I&#8217;m sure somebody  out there uses the Office macro tools to good effect. I&#8217;m just saying that I&#8217;m not that somebody. They&#8217;re useful in Photoshop,  and I did use a program to automate fishing in an MMORPG called <a href="http://en.wikipedia.org/wiki/Tibia_%28computer_game%29">Tibia</a> a while back. I had a fishing level of about 40 afterwards.</p>
<p>AutoHotKey takes a different approach than those examples. Instead of recording specific mouse movements, you take more of  a scripting approach. Now, I&#8217;m a fan of strongly typed, compiled languages. Seeing the syntax of Visual Basic makes me nauseous. AHK, on the other hand, seems to handle scripting rather well without looking like the freak of nature that some  languages are. VB, etc, I&#8217;m looking at <em>you</em>.</p>
<h3 id="toc-okay-tell-me-more">Okay, tell me more.</h3>
<p>To assign a button to something, you follow the simple syntax of<br />
<code>[button]::[command]</code>. The first command I wrote was <code>#n::Run Notepad</code>, which opens notepad when I press  Win+N. That&#8217;s a very simple example, though. There are several built-in functions, and many that you can download as your  scripting gets more complex. Comments are denoted by semicolonws, by the way.</p>
<p>I&#8217;ve always wanted to be able to go to a url in a website that wasn&#8217;t linked. For example, let&#8217;s say you want to go to my  deviantArt page, http://disavian.deviantart.com. The way to do that (in firefox) without using an extension is to highlight  the url, press ctrl+c, press ctrl+t, press ctrl+v, and then press enter. When you break it down, they&#8217;re easy steps, but it&#8217;s  certainly a process.</p>
<h3 id="toc-okay-now-what">Okay, now what?</h3>
<p>I know it&#8217;s not a very complex process, but look at what you can do with AHK:</p>
<p><code> </code></p>
<pre>;;Firefox: Go to selection in new tab
#g::
   Send, ^c^t
   Sleep, 500 ;wait for firefox
   Send, ^v {enter}
Return</pre>
<p>Now I can highlight the string above, press Win+G, and firefox will open it in a new tab. It&#8217;s not a very difficult script,  and was my initial foray into multi-line scripts. As you can see, the usefulness of AHK is only limited by the uses you can  brainstorm. To that end, I considered the image-saving problem mentioned in the introduction.</p>
<h3 id="toc-i-see-what-youve-done-here">I see what you&#8217;ve done here&#8230;</h3>
<p>Now, I&#8217;d like the ability to push a button and save an image. This isn&#8217;t as easy, because you can&#8217;t just save an image with  an easy keystroke. Also, it&#8217;d be nice to be able to do this in IE, if only because it&#8217;s necessary to use IE every now and  then. Plus, some people actually use IE as their everyday browser, and the purpose of this article is to share my script. In  writing this, I used a few scripts available as references, but they didn&#8217;t do what I was looking for.</p>
<p>So, the typical method of saving an image involves right-clicking, selecting &#8220;save image,&#8221; and clicking okay. If it&#8217;s a  duplicate filename, you get another window, have to cancel, rename the image, and then press save. So, about three to six  steps. Definitely something that could be sped up. I&#8217;ll start with Firefox&#8217;s implementation.</p>
<h3 id="toc-now-for-the-nitty-gritty">Now for the nitty gritty&#8230;</h3>
<p>Translating that process to keystrokes and mouse clicks, you have to press (right mouse button) v (firefox&#8217;s context  shortcut for save), and then (enter). In IE, the context shortcut is s. If it&#8217;s a duplicate file, the &#8220;Save Image&#8221; (FF) or  &#8220;Save Picture&#8221; (IE) window will still be open, and you&#8217;ll have to rename the file. The easiest way to do this with a low  chance of collusion is a randomly generated number. The command <code>Random R, 0, 100000</code> generates a number R between  0 and 100000, as you might imagine. So, to deal with an existing file in FF, you&#8217;d press (enter)(skip to end of filename,  before extension)(type random number)(enter). In AHK, that translates to <code>Send {Enter}{Ctrl Down}{Left}{Ctrl  Up}{Left}%R%{Enter}</code>. Trust me on that.</p>
<h3 id="toc-huh">Huh?</h3>
<p>Now that you understand most of the parts, the best way to really illustrate this is to show you the final product.  Observe:</p>
<p><code> </code></p>
<pre>;; save image using [ctrl]+[right-click]
;;           and [windows]+[right-click]
^RButton::
#RButton::
    Random R, 0, 100000 ; get a random number
    ;Msgbox %R%
    MouseGetPos,,,, Control
    IfInString, Control, Internet Explorer
    {
        Send {RButton}s{Enter}
        Sleep, 500
        IfWinActive Save Picture
        {
            ;Duplicate file!
            Send {Enter}{End}%R%{Enter}
        }
    }
    IfInString, Control, Mozilla
    {
        Send {RButton}v{Enter}
        Sleep, 500
        IfWinActive Save Image
        {
	    ;Duplicate file!
            ;Line split for readability
            Send {Enter}{Ctrl Down}{Left}
            Send {Ctrl Up}{Left}%R%{Enter}
        }
    }
Return</pre>
<p>If you paste this into the AHK script you&#8217;re building, you&#8217;ll get that spiffy functionality. The only problem is that if  you don&#8217;t press the windows key just right, the windows menu pops up. Now that you&#8217;ve been introduced to AutoHotKey, go learn about all of the things you can do with it. It can even create forms, but I never learned how to do that. If I need a form, I&#8217;ll write a C# application.</p>
<h3 id="toc-other-uses">Other uses</h3>
<p>I own an xbox. Therefore, I have roughly a billion xbox controllers. Wanting to use one of them on my computer, I went down to Fry&#8217;s and bought a cheap ($7.50, I believe) xbox controller-to-usb converter. After installing <a href="http://www.redcl0ud.com/xbcd.html">this driver</a>, it works perfectly. I discovered that AHK will let you assign commands to controller buttons. I even found a script that lets you use the controller as a mouse, but it was difficult to use; it was more or less impossible to move the mouse with precision. It was a simple matter, however, of assigning keyboard shortcuts used in the game I was playing (on <a href="http://vba.ngemu.com">VisualBoyAdvance</a>) to the white, black, and start buttons on my controller. Even better, the start button still sends <code>{start}</code> when pressed. Also, I put some winamp functions in there that I found online. I know that winamp has global function keys, but can those also open winamp for you? Didn&#8217;t think so. If you&#8217;re interested, I&#8217;ve posted my entire script below.</p>
<h3 id="toc-related-links">Related links</h3>
<ul>
<li><a href="http://disavian.no-ip.info/archive/introduction_to_autohotkey/aguyton.ahk"><strong>My AHK script</strong></a></li>
<li><a href="http://en.wikipedia.org/wiki/Autohotkey">AutoHotKey on wikipedia</a></li>
<li><a href="http://www.autohotkey.com/">AutoHotKey offical website</a></li>
<li><a href="http://www.autohotkey.com/forum/topic3284.html">Extensive script catalogue</a></li>
<li><a href="http://www.biancolo.com/content_show.cfm?content_id=25569">System-wide autocorrect using AHK</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://disavian.no-ip.info/introduction-to-autohotkey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
