Autohotkey (Microsoft Windows)

From MakeItFit - Wiki
Jump to: navigation, search
Autohotkey Icon
AutoHotKey offeres several different customized functions, e.g. additional keyboard shortcuts or actions initiated at a certain system event etc. All the behavior can be modified and customized by autohotkey scripts. It does not require administrative priviledges to install, configure and run it.

Reference

Requirements

Installation

Download and install AutoHotKey by doubleclicking the installation package and follow the instructions, the same way like all other Windows programs.

Configuration

The customized functions and behaviors are configured by scripts. Several functions can be defined in one script. On Windows XP I have stored the scripts in this path:

C:\<path>\AutoHotkey\Extras\Scripts\<script name>.ahk

It might by possible to store it in other places as well, it definitelly can be storedin any place on Windows 7.

The event initiating the execution of the action is defined by a line ending with ::. The scripts can manually be started by doubleclicking it. Link the script into the autostart items folder to make it starting at every system start or login.

Autohotkey Taskbar Icon
A running AutoHotKey script can be recognized by an icon in the task bar in the lover left corner. Hovering the mouse cursor over the icon reveals the running script. Each script causes its own AutoHotKey icon in the task bar to control the script. By right-clicking the icon, a menue appreas offering to edit the script. By reloading the changes in the script become directly active.

Hotkeys - Mouse, Joystick and Keyboard Shortcuts

The special keys on a Windows keyboard and other system events, socalled hotkeys, are coded according to this instruction.

Examples

Apple natural Scroll Behavior for Windows

Since OSX Lion Apple changed the standard scrolling behavior to the so called natural scrolling. It corresponds to the scrolling on touch screen devices like iPhone, iPad, but also Android smartphones and the old windows mobile phones (probably also the new windows 8 smartphones). The movement is pretty intuitive ans simluates the moving of the content "in" the device to see the next section. Unexperienced people adapt this guesters within minutes because it makes the device and the content behaving in a natural way.

One may like it or not. I experienced it as confusing having it in one direction at home and the other direction on the companies computer. As I like it and like it having consistent for all my devices. The methode described here works good without any delay and can even be installed in an account with limited privileges.

If one prefer the Windows behavior, the natural scrolling in OS X Lion and newer can be disabled in the -> system settings -> Mouse.

; Reverse Scrolling Script by How-To Geek

#MaxHotkeysPerInterval 200;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

WheelUp::
 Send {WheelDown}
Return

WheelLeft::
 Send {WheelRight}
Return

WheelRight::
 Send {WheelLeft}
Return

WheelDown::
 Send {WheelUp}
Return

Comment:

  • Based on different sources in the internet the first three lines are optional and seem to improve the scripts performance. The sections WheelUp, WheelLeft, WheelRight and WheelDown are the importanyt sections.
  • If the used mouse does not offer left and right scrolling or this behavior should not be changed, the according sections can be skiped.

Un-/Mute Microphone

^Numpad0::
soundget, isMute, MICROPHONE, MUTE
if isMute = Off
    toMute = 1
else
    toMute=0
SoundSet, toMute, MICROPHONE, MUTE
return

Change Audio Device in Windows XP and Cisco IP Communicator

; Set Sounddevice 1 (Conexant HD Audio output / Default Windows Audio Device)
#1::

; check if Cisco IP communicator is running
Process, Exist, communicatork9.exe
If errorLevel
{
    Communicator:= "true"
}
else
{
    Communicator:= "false"
}

; Read audio Device in from Cisco IP Communicator
RegRead, CiscoDevice, HKEY_CURRENT_USER, Software\Cisco Systems`, Inc.\Communicator, AudioHandsetDevice
Device := "Conexant HD Audio"

; Change it to audio device 1 (Conexant HD Audio output) or Default Windows Audio Device respectivelly if it is not already set.
if(CiscoDevice = "Plantronics .Audio 400 DSP") and (Communicator = "true")
{   
    Run %A_ProgramFiles%\Cisco Systems\Cisco IP Communicator\communicatork9.exe
    WinWait, Cisco
    IfWinNotActive, Cisco WinActivate, Cisco
    WinWaitActive, Cisco
    Send, !{s}
    Sleep, 25
    Send, {right 2}
    Sleep, 25
    Send, {Tab 3}
    Sleep, 25
    Send, {down}
    Sleep, 25
    Send, {Tab}
    Sleep, 25
    Send, {down}
    Sleep, 25
    Send, {Tab}
    Sleep, 25
    Send, {down}
    Sleep, 25
    Send, {Tab}
    Sleep, 25
    Send, {down 2}
    Sleep, 25
    Send, {Enter}	
    WinWait, Cisco
    IfWinNotActive, Cisco WinActivate, Cisco
    WinWaitActive, Cisco
    Send, !{F4}
}

; Read Windows audio device
RegRead, WindowsDevice, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback

; Change it to audio device 1 (Conexant HD Audio output) if it is not already set.
if (WindowsDevice = "Plantronics .Audio 400 DSP")
{
    Run, mmsys.cpl
    WinWait, Eigenschaften von Sounds und Audiogeräte
    IfWinNotActive, Eigenschaften von Sounds und Audiogeräte WinActivate, Eigenschaften von Sounds und Audiogeräte
    WinWaitActive, Eigenschaften von Sounds und Audiogeräte
    Send, ^{Tab 2}
    Sleep, 25
    Send, {Down}
    Sleep, 25
    Send, {Tab 3}
    Sleep, 25
    Send, {Down}
    Sleep, 25
    Send, !b
    Sleep, 25
    Send, ^{Tab}
    Sleep, 25
    Send, {Up}
    Sleep, 25
    Send, {Tab 3}
    Sleep, 25
    Send, {Up}
    Sleep, 25
    Send, {Enter}
}

; Show tool tip with now active audio device
ToolTip, % "Sound Device: " Device
    SetTimer, ResetToolTip, 2000
return

; Set Sounddevcie 2 (Plantronics .Audio 400 DSP)
#2::

; Read audio Device in from Cisco IP Communicator
RegRead, CiscoDevice, HKEY_CURRENT_USER, Software\Cisco Systems`, Inc.\Communicator, AudioHandsetDevice
Device := "Plantronics .Audio 400 DSP"

; check if Cisco IP communicator is running
Process, Exist, communicatork9.exe
If errorLevel
{
    Communicator:= "true"
}
else
{
    Communicator:= "false"
}

; Change it to audio device 2 (Plantronics .Audio 400 DSP) or Default Windows Audio Device respectivelly if it is not already set.
if(CiscoDevice = "Default Windows Audio Device") and (Communicator = "true")
{
    Run %A_ProgramFiles%\Cisco Systems\Cisco IP Communicator\communicatork9.exe
    WinWait, Cisco
    IfWinNotActive, Cisco WinActivate, Cisco
    WinWaitActive, Cisco
    Send, !{s}
    Sleep, 25
    Send, {right 2}
    Sleep, 25
    Send, {Tab 3}
    Sleep, 25
    Send, {up}
    Sleep, 25
    Send, {Tab}
    Sleep, 25
    Send, {up}
    Sleep, 25
    Send, {Tab}
    Sleep, 25
    Send, {up}
    Sleep, 25
    Send, {Tab}
    Sleep, 25
    Send, {up}
    Sleep, 25
    Send, {Enter}		
    WinWait, Cisco
    IfWinNotActive, Cisco WinActivate, Cisco
    WinWaitActive, Cisco
    Send, !{F4}
}

; Read Windows audio device
RegRead, WindowsDevice, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback

; Change it to audio device 2 (Plantronics .Audio 400 DSP) if it is not already set.
if (WindowsDevice = "Conexant HD Audio output")
{
    Run, mmsys.cpl
    WinWait, Eigenschaften von Sounds und Audiogeräte
    IfWinNotActive, Eigenschaften von Sounds und Audiogeräte WinActivate, Eigenschaften von Sounds und Audiogeräte
    WinWaitActive, Eigenschaften von Sounds und Audiogeräte
    Send, ^{Tab 2}
    Sleep, 25
    Send, {Down}
    Sleep, 25
    Send, {Tab 3}
    Sleep, 25
    Send, {Down}
    Sleep, 25
    Send, !b
    Sleep, 25
    Send, ^{Tab}
    Sleep, 25
    Send, {Up}
    Sleep, 25
    Send, {Tab 3}
    Sleep, 25
    Send, {Up}
    Sleep, 25
    Send, {Enter}
}

; Show tool tip with now active audio device
ToolTip, % "Sound Device: " Device
    SetTimer, ResetToolTip, 2000
return


; Clear the ToolTip
ReSetToolTip:
    ToolTip
    SetTimer, ReSetToolTip, Off
return

#3::
Process, Exist, communicatork9.exe
If errorlevel
{
	Communicator:= true
MsgBox, "läuft"
}
else
{
Communicator:= false
MsgBox, "läuft nicht"
}
if Communicator = true
{
MsgBox, "true"
}
else
{
MsgBox, "false"
}