/* * * * Compile_AHK SETTINGS BEGIN * * * [AHK2EXE] Exe_File=%In_Dir%\Transpose.exe No_UPX=1 [VERSION] Set_Version_Info=1 File_Description=Transpose File_Version=2.3.3.3 Inc_File_Version=0 Legal_Copyright=2014 http://milesaheadsoftware.tk/ Product_Version=2.3.3.3 [ICONS] Icon_1=%In_Dir%\T.ico Icon_2=%In_Dir%\Key.ico Icon_3=%In_Dir%\Dollar.ico Icon_4=%In_Dir%\Quit.ico * * * Compile_AHK SETTINGS END * * * */ ; ; Transpose - copyright 2012 www.favessoft.com ; ; Utility to transpose 2 characters to the left of the caret ; in editors and/or browsers, for typo fix on the fly. ; ; I use this script as a kind of catch all for hotkeys ; that don't need ini file settings. See About Dialog ; for details ; ; Author: MilesAhead ; ; Use Visit Hotkey Page Tray Menu command to get latest version ; and view Windows Requirements. ; ; Use Donate Tray Menu command to support future releases ; ; FavesSoft Windows Utilities are free for you to use ; at your own risk. ; ; MilesAhead ; #SingleInstance force #NoEnv #Warn UseUnsetLocal, Off DetectHiddenWindows, On SetTitleMatchMode,2 SendMode Input SetWorkingDir %A_ScriptDir% CoordMode,ToolTip,Screen CoordMode,Mouse,Screen #Hotstring EndChars `t Menu Tray,NoStandard Menu Tray,Add,Donate,DoDonate Menu Tray,Add,Visit Hotkey Page,DoVisit Menu Tray,Add,About Transpose,DoAbout Menu Tray,Add Menu Tray,Add,Quit,DoQuit Menu Tray,Default,About Transpose Menu Tray,Click,1 if (A_IsCompiled) { Menu Tray,Icon,%A_ScriptFullPath%,1 Menu Tray, Icon, About Transpose, Transpose.exe,, 24 Menu Tray, Icon, Visit Hotkey Page, Transpose.exe,2, 24 Menu Tray, Icon, Donate, Transpose.exe,3, 24 Menu Tray, Icon, Quit, Transpose.exe,4, 24 } Menu Tray,Tip,Transpose ; Welcome := "Welcome to the Forums.`n" Thanks:= "Thanks for the rep. :)`n" Miles:="miles__ahead@hotmail.com" Kewl:="kewlbreez@hotmail.com" TMin := 0 TSec := 0 Selected := "" OrphanApp := "" EverythingShortcut := "C:\Users\Owner\Documents\Apps\Util\FileTools\Everything Search.lnk" GroupAdd,EditorGroup, ahk_class TFormEditPadLite ;EditPadLite GroupAdd,EditorGroup, ahk_class TFormEditPadLite7 ;EditPadLite7 GroupAdd,EditorGroup, ahk_class wxWindowClassNR ;FBIde GroupAdd,EditorGroup, ahk_class SciTEWindow ;Scite GroupAdd,EditorGroup, ahk_class MAINFBEDIT ;FBEdit GroupAdd,EditorGroup, ahk_class Notepad ;Notepad GroupAdd,EditorGroup, ahk_class TFormMain ;TreePad GroupAdd,EditorGroup, ahk_class Chrome_WidgetWin_0 ;Chromium Browser GroupAdd,EditorGroup, ahk_class Chrome_WidgetWin_1 ;Chromium 20.x GroupAdd,EditorGroup, ahk_class MozillaUIWindowClass ;Firefox Browser GroupAdd,EditorGroup, ahk_class MozillaWindowClass ;Firefox 4+ Browser GroupAdd,EditorGroup, ahk_class OperaWindowClass ;Opera 11 GroupAdd,EditorGroup, BBCeditor ; BBCeditor GroupAdd,BrowserGroup, ahk_class Chrome_WidgetWin_0 ;Chrome Browser GroupAdd,BrowserGroup, ahk_class Chrome_WidgetWin_1 ;Chromium 20.x GroupAdd,BrowserGroup, ahk_class MozillaUIWindowClass ;Firefox Browser GroupAdd,BrowserGroup, ahk_class MozillaWindowClass ;Firefox 4 Browser GroupAdd,BrowserGroup, ahk_class OpWindow ;Opera Browser GroupAdd,BrowserGroup, ahk_class OperaWindowClass ;Opera 11 GroupAdd, ChromeGroup, ahk_class Chrome_WidgetWin_0 ;Chrome Browser GroupAdd, ChromeGroup, ahk_class Chrome_WidgetWin_1 ;Chromium 20.x GroupAdd,ExplorerGroup, ahk_class CabinetWClass GroupAdd,ExplorerGroup, ahk_class ExploreWClass AboutOpen := false SetTimer,DumpMemory,-60000 ;newrev open FolderCache and reopen last folder ^+f:: If (! WinExist("ahk_exe foldercache.exe")) return Send,+{NumPadAdd} WinWaitActive,ahk_exe foldercache.exe,,1 If (ErrorLevel = 1) return Send {Tab} Send {Down}{Up} Send {Enter} return ; Invoke BrowserBunch with selected url from ; the active window. ^+F4:: ClipSave := Clipboard Clipboard := "" Send, ^c ClipWait,2 ; set BrowserBunch path for your system Run C:\Utils\BrowserBunch\BrowserBunch.exe %Clipboard% Clipboard := ClipSave ;MsgBox % Clipboard return ; close all Explorer windows ;~ #x:: ;~ if ( WinExist("ahk_group ExplorerGroup") ) ;~ WinClose,ahk_group ExplorerGroup ;~ SetTimer,DumpMemory,-30000 ;~ return ;~ #IfWinActive ahk_Group EditorGroup ;~ ; Launch BrowserBunch with Selection as arg ;~ ^+F4:: ;~ ClipSave := Clipboard ;~ Clipboard := "" ;~ Send, ^c ;~ ClipWait,2 ;~ ; set BrowserBunch path for your system ;~ Run C:\Utils\BrowserBunch\BrowserBunch.exe %Clipboard% ;~ Clipboard := ClipSave ;~ ;MsgBox % Clipboard ;~ return ; Launch BrowserBunch with url ; Note caret must be immediately left ; of the entire url and url must be at the ; end of a line #IfWinActive ahk_Group EditorGroup ^+F3:: ClipSave := Clipboard Clipboard = Send,+{End} Sleep,10 Send,^c ClipWait,2 Send,{Right} ; set BrowserBunch path for your system Run C:\Utils\BrowserBunch\BrowserBunch.exe %Clipboard% Clipboard := ClipSave return ^t:: ClipSaved := ClipboardAll ; save entire clipboard Clipboard= ; clear clipboard Send {Shift Down}{Left}{Shift Up} ; select char left of caret Send ^c ; copy char ClipWait,0 ;give copy time to complete ; the caret is positioned to insert ; the char from the clipboard. Editor ; must be in Insert Mode for it to work. ; The char is inserted, and caret positon restored. ; Send {Right} Send {BackSpace} Send {Left} Send {Raw}%Clipboard% ; avoid puntuaction being interpreted Send {Right} Clipboard := ClipSaved ClipSaved = ; free memory return #IfWinActive #IfWinActive ahk_group ChromeGroup ^LButton:: Send, ^+{LButton} return #IfWinActive #IfWinActive ahk_group ChromeGroup +LButton:: Send, ^{LButton} return #IfWinActive ; PdfXChange Editor #IfWinActive ahk_class PXE:{C5309AD3-73E4-4707-B1E1-2940D8AF3B9D} F1:: If FileExist("C:\Program Files\Tracker Software\PDF Editor\Help\help.pdf") Run,"C:\Program Files\Tracker Software\PDF Editor\Help\help.pdf" else Send {F1} return #IfWinActive ; send selected Url to Browser Bunch #IfWinActive ahk_Group BrowserGroup ::qq:: Clipboard = Send,^a Send,^c ClipWait,1 Send,{Right} Process,Exist,selector.exe if ErrorLevel Send,^{NumPadDiv} return !LButton:: pPath := WinGetProcessPath("A") Clipboard = Send,^c ClipWait,1 Selected = %Clipboard% Click if (pPath) && (Selected) Run, %pPath% %Selected% else if (Selected) Run, %Selected% return ; paste "Welcome to the Forums" ^+w:: Send %Welcome% return ; paste "Thanks for the rep" ^+t:: Send %Thanks% return ;paste MilesAhead email address ^+m:: SendRaw %Miles% return ;paste kewlbreez email address ^+k:: SendRaw %Kewl% return ^F10:: Clipboard = Send ^c ClipWait,1 Click Sleep, 100 Selected = %Clipboard% if Selected Run,http://www.thefreedictionary.com/%Selected% return +F10:: TMin := 0 TSec := 0 Clipboard = Send ^c ClipWait,2 Selected = %Clipboard% gosub,ShowResults return ^F9:: Clipboard = Send,^{LEFT}^+{RIGHT} Sleep,10 Send,^c ClipWait,0 Selected := Clipboard Send,{Right} Run,http://www.thefreedictionary.com/%Selected% return ; AutoCopy to clipboard in supported browsers ; ; Select text with mouse, holding left mouse ; button down. Press and release Shift, then release ; mouse button. If text copied to clipboard the ; selection will be cleared. ; ~Shift:: if not GetKeyState("LButton") return Clipboard = Send ^c ClipWait,1 Selected = %Clipboard% if not Selected return SoundPlay,*48 return #IfWinActive ; end of BrowserGroup block ; only send double click for muddle ; mouse click if clicking in Explorer ; window client area ; #IfWinActive ahk_Group ExplorerGroup ~MButton:: MouseGetPos,MouseX,MouseY,AWindow if (! AWindow) return SendMessage,0x84,,(MouseY<<16)|MouseX,,ahk_id %AWindow% ;WM_NCHITTEST=0x84 if (ErrorLevel != 2) { Send,{MButton Up} Sleep,10 MouseClick, left, , , 2 } return ;~ #IfWinActive ahk_Group ExplorerGroup ;~ MButton:: ;~ MouseClick, left, , , 2 ;~ return +MButton:: Progress, zh0 B fs12 CTBlue,Press a letter to open`nExplorer to that drive Input,keypress,L1 Progress, OFF dr := keypress . ":\" StringUpper,dr,dr If FileExist(dr) { Run,Explorer.exe /e`,%keypress%:\ } else { Progress, zh0 B fs12 CTRed,%dr% Drive Does Not Exist! Sleep,3000 Progress, OFF } return #IfWinActive ; end of ExplorerGroup block ;Newsbin floating Groups List ;show posts on Group Middle Click #IfWinActive ahk_class XTPDockingPaneMiniWnd MButton:: Send,^l return #IfWinActive ; Shift Backspace is my hotkey for Everything Search. ; If that is not running, launch it. Else cucomment UltraSearch block to ; use it instead. ; $+BS:: FileGetShortcut,%EverythingShortcut%,Target if (! ErrorLevel) { SplitPath,Target,prog Process,Exist,%prog% if ErrorLevel { if WinExist("ahk_class EVERYTHING") { WinActivate,ahk_class EVERYTHING ControlFocus,Edit1 if (! ErrorLevel) Send,{Home}{Shift Down}{End}{Shift Up} } else Send,+{BS} } else { Run, %Target% WinWait,ahk_class EVERYTHING,,8 if ErrorLevel return WinActivate,ahk_class EVERYTHING } } return ShowResults: Loop, parse, Selected, `n, `r { StartPos := RegExMatch(A_LoopField,"[0-9]+:") if (!StartPos) continue StringMid,found,A_LoopField,StartPos,5 if (found) { found = %found% StringLeft,nstr,found,InStr(found,":") - 1 TMin := TMin + nstr ;StringMid,nstr,found,InStr(found,":") + 1,2 StringRight,nstr,found,2 TSec := TSec + nstr if (TSec // 60) { TMin := TMin + TSec // 60 TSec := Mod(TSec,60) } } } TSec := (StrLen(TSec)=1) ? "0" TSec : TSec MsgBox, 4160, Transpose, Total Time: %TMin%:%TSec% return DoAbout: if (AboutOpen) return AboutOpen := true FileGetVersion,filever,Transpose.exe MyMsg = ( Transpose v %filever% Copyright (c) %A_Year% http://milesaheadsoftware.tk/`n Control-t Transposes the 2 characters left of the caret`n Supports edit controls in Chrome, Firefox and Opera Browsers. Supports EditPadLite, EditPadLite7, FBIde, FBEdit, Scite, Notepad, and TreePadLite Editors`n Chrome Browsers:`n`nControl-Click opens link in new foreground Tab`nShift-Click in new background Tab`n`nChrome. Firefox, and Opera Browsers:`n`nAlt Click opens Selected Text in new tab if valid URL`nShift/Release with left mouse key down to AutoCopy Text`nqq Tab in Edit Copies All text to Clipboard, triggers Selector`n`nControl F9 key looks up word left of caret on`nThe Free Dictionary Control F10 key looks up selection`n`nShift F10 key to total AllMusic play times`n Middle Mouse Click in Explorer to Double-Click`n Shift Middle Click an empty spot in Explorer to open a Drive Letter`n`n Note: IE Browser is not supported. ) if WinExist("UltraSearch.exe") MyMsg := MyMsg . "Shift Backspace Displays UltraSearch 1.5 if running in Tray" MsgBox, 4160, About Transpose, %MyMsg% SetTimer,DumpMemory,-30000 AboutOpen := false return ; reduce memory footprint sitting in tray DumpMemory: _EmptyWorkingSet() return DoDonate: Run,"http://milesaheadsoftware.tk/" SetTimer,DumpMemory,-30000 return DoVisit: Run,"http://milesaheadsoftware.tk/"" SetTimer,DumpMemory,-30000 return DoQuit: SetTimer,,Off ExitApp --- Helper Functions --- ; Usage: WinGetProcessPath("A") to get program path for active window ; returns "" on error, program path on success ; ; e.g. chromium browser might return C:\Program Files\Chromium\chrome.exe ; WinGetProcessPath(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") { VarSetCapacity(name, 520) WinGet pid, PID, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText% static hmod := DllCall("LoadLibrary", "str", "psapi") ; Preload psapi.dll. if !hproc := DllCall("OpenProcess", "uint", 0x410, "int", false, "uint", pid) { ErrorLevel := 1 return } if ( A_Is64bitOS ) name := _ExecPathWMI(pid) else DllCall("psapi\GetModuleFileNameEx" ( A_IsUnicode ? "W" : "A" ), "ptr", hproc, "ptr", 0, "str", name, "uint", 260) DllCall("CloseHandle", "ptr", hproc) return name } ; get Executable Path from Process ID using WMI _ExecPathWMI(ProcID) { x := 0 strComputer := "." objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . strComputer . "\root\cimv2") colItems := objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " ProcID,"WQL",0x30) if (! colItems) return "" for colItem in colItems if (colItem.ProcessID = ProcID) return colItem.ExecutablePath } ;call EmptyWorkingSet in AHK _EmptyWorkingSet() { return DllCall("psapi.dll\EmptyWorkingSet", "UInt", -1) } ; _PathResolve(filename,LookyHere = "") ; ; Uses PathResolve WinAPI call. ; ; Searches for filename first in LookyHere then in Path. If found ; the full path is returned. If LookyHere is left blank, then ; A_WorkingDir is used. Returns "" if filename not found. ; _PathResolve(filename,LookyHere = "") { max_path := 32768 * 2 max_dirpath := (LokkyHere) ? StrLen(LookyHere) * 2 + 2 : StrLen(A_WorkingDir) * 2 + 2 file_path := "" VarSetCapacity(fPath,max_path,0) VarSetCapacity(fWDir,max_dirpath,0) fWDir := (LookyHere) ? LookyHere : A_WorkingDir fPath := filename if DllCall("Shell32.dll\PathResolve","WStr",fPath,"WStr*",fWDir,"UInt",0) file_path := fPath fPath := 0 fWDir := 0 return file_path }