CapsLock::Ctrl
LControl::^+0
RControl::^+1
RunOrActivate(Target, WinTitle = "")
{
; Get the filename without a path
SplitPath, Target, TargetNameOnly
Process, Exist, %TargetNameOnly%
If ErrorLevel > 0
PID = %ErrorLevel%
Else
Run, %Target%, , , PID
If WinTitle <>
{
SetTitleMatchMode, 2
WinWait, %WinTitle%, , 3
WinActivate, %WinTitle%
}
Else
{
WinWait, ahk_pid %PID%, , 3
WinActivate, ahk_pid %PID%
}
}
~MButton & LButton::
Alt & LButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
if EWD_WinState = 0 ; Only if the window isn't maximized
SetTimer, EWD_WatchMouse, 10
return
EWD_WatchMouse:
GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U
{
SetTimer, EWD_WatchMouse, off
return
}
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D
{
SetTimer, EWD_WatchMouse, off
WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
return
}
CoordMode Mouse, Screen
~LButton::
MouseGetPos x0, y0 ; save start mouse position
Loop
{
Sleep 20 ; yield time to othersyield time to
GetKeyState keystate, LButton
IfEqual keystate, U, {
MouseGetPos x, y ; position when button released
break
}
}
if (x-x0 > 5 or x-x0 < -5 or y-y0 > 5 or y-y0 < -5)
{
IfWinActive ahk_class Emacs
{
return
}
Else
{
; mouse has moved
clip0 := ClipBoardAll ; save old clipboard
ClipBoard =
Send ^c ; selection -> clipboard
ClipWait 1, 1 ; restore clipboard if no data
IfEqual ClipBoard,, SetEnv ClipBoard, %clip0%
}
}
return
~Mbutton::Send ^v
!T::WinSet, Style, ^0xC00000, A
#Down::WinMinimize A
#Up::
WinGet MX, MinMax, A
If MX
WinRestore A
Else
WinMaximize A
Return
#Left::
WinRestore A
WinMove A, ,0,0,(A_ScreenWidth/2),A_ScreenHeight-30
Return
#Right::
WinRestore A
WinMove A, ,(A_ScreenWidth/2),0,(A_ScreenWidth/2),A_ScreenHeight-30
Return
#q::WinClose A
#f::RunOrActivate("C:\Program Files\Mozilla Firefox\firefox.exe")
#j::RunOrActivate("C:\Program Files\Pidgin\pidgin.exe")
#1::
IfWinExist ahk_class Emacs
{
WinActivate
}
else
{
Run "C:\Users\alecs\emacs-22.3\bin\runemacs.exe"
WinWait emacs@NIMBUS
WinActivate
}
Return
#IfWinActive, ahk_class MozillaUIWindowClass
{
!1::Send ^1
!2::Send ^2
!3::Send ^3
!4::Send ^4
!5::Send ^5
!6::Send ^6
!7::Send ^7
!8::Send ^8
!9::Send ^9
!0::Send ^0
return
}