AHK: Some more examples and the oh-shit script

This time we are going to discuss some of the more advanced features of AHK. my last tutorial on the subject was rather brief and based on a limited amount of experience using AHK for daily tasks. Two years have passed and AHK is a big part of my toolbox so it's time for an update.

First an example of my day to day:

I administer twelve different systems during an eight hour period daily. These systems include OpenVMS, Linux, (RHE) and Unix (SunOS). My local system was recently upgraded to windows seven. After the business division releases control of the systems to myself I backup any changes to the systems and start the end of day processing. Which normally includes installing patches and rolling out new software from our development team. I hate repetitive tasks and because these systems cover such a wide spectrum Operating systems server side scripting doesn't really help. Logging into 12 different systems takes time, time I would rather spend doing more important things....

First I created the directory C:\myuser\bin and copied putty.exe there.

-NOTE: Things enclosed in "'s should be replaced with your actual information like in putty "session_title" would be the name of the putty window

#s::            ; windows key + s
IfWinNotExist "session_title"
Run C:\myuser\bin\putt.exe -load putty_session
WinActivate, "session_title"
Sleep, 1000     ;millaseconds
SendInput, myuser{Enter}
Sleep, 1000
SendInput, mypassword{enter}
return

Or when I have numerous windows that I want opened at once I use

F3::            ; F3 key
IfWinNotExist "session_title1"
Run C:\myuser\bin\putty.exe -load "putty_session1"
IfWinNotExist "session_title2"
Run C:\myuser\bin\putty.exe -load "putty_session2"
IfWinNotExist "session_title3"
Run C:\myuser\bin\putty.exe -load "putty_session3"

WinActivate, "session_title1"
        Sleep, 100      ;millaseconds
        SendInput, myuser{Enter}
        Sleep, 100
        SendInput, mypassword{enter}
WinActivate, "session_title2"
        Sleep, 100      ;millaseconds
        SendInput, myuser{Enter}
        Sleep, 100
        SendInput, mypassword{enter}
WinActivate, "session_title3"
        Sleep, 100      ;millaseconds
        SendInput, myuser{Enter}
        Sleep, 100
        SendInput, mypassword{enter}
return

Screen management is also important, seeing the right information at the right time is extremely important and I hate using a mouse. So:
NumpadIns::             ; Number pad 0 when num lock off
WinActivate, Oracle     ; Activates Virtual box
NumpadEnd::             ; Number pad 1 when num lock off
WinActivate, sx-note    ; this tutorial

Combining these scripts with hot-strings I have gotten a seven hour process down to about four hours. Leaving me extra time to browse Soldierx.com.

At the end of my last paper I discussed an "Emergency button".

^!#z::                  ; Ctrl + Alt + Win + Z
Run  C:\myuser\bin\putty.exe -load oh_shit
Run  C:\myuser\bin\oh_shit.ahk
WinActivate, oh-shit
Sleep, 1000     ;millaseconds
SendInput, myuser{Enter}
Sleep, 1000
SendInput, mypassword{enter}
Sleep, 1000
SendInput, rm -rf /incriminating/evidence/stored/here/
Sleep, 100
SendInput, echo “They have a warrant! Follow purge protocol!” | mail -s “Feds have Arrived!” <a href="mailto:[email protected]">[email protected]</a>
return
; The C:\myuser\bin\oh_shit.ahk file
; Starts the THEY ARE HERE process

C:\myuser\bin\truecrypt.exe /f /d       ;forces all encrypted volumes to dismount
Run <a href="http://www.somewhitehatpage.com<br />
Run" title="www.somewhitehatpage.com<br />
Run">www.somewhitehatpage.com<br />
Run</a> <a href="http://www.welove-thefeds.com<br />
Run" title="www.welove-thefeds.com<br />
Run">www.welove-thefeds.com<br />
Run</a> del /F \myuser\bin\oh_shit.ahk
Run C:\myuser\bin\Eraser.exe
return

Scripting is great, and AHK in my humble opinion is the best language for doing so inside Microsoft Windows

Xbutton2::
IfWinActive, Create Blog Entry | Soldierx.com
{
   SendInput, Nobody can stop information insemination
}
else
{
   return
}