;CopyCap-1.ahk (03/08/2008) ;a tool to copy active window's titlebar text and window class into clipboard. ;middle-click on the titlebar of any window to activate a menu that allows one ;to copy caption text and/or change it temporarily. ; ;Update: 01/11/2008 to add "Locate folder" feature. ; #Persistent #SingleInstance force #NoEnv #NoTrayIcon SetBatchLines, -1 CoordMode, Mouse, Screen SetMouseDelay, -1 Menu, CopyCaption, Add, Copy Caption Text, CopyCaption Menu, CopyCaption, Add, Copy Caption and Windows Class Text, CopyCaption Menu, CopyCaption, Add, Change Caption, ChangeCaption Menu, CopyCaption, Add Menu, CopyCaption, Add, Locate the folder, OpenFolder Menu, CopyCaption, Add Menu, CopyCaption, Add, Visit forum to discuss this program, SendFeedback Menu, CopyCaption, Add, Exit, ExitSub OnExit, ExitSub Return OpenFolder: WinGet, getPid, PID, ahk_id %WindowUnderMouseID% path:=GetModuleFileNameEx(getPid) SplitPath, path, , getDir ToolTip, Opening folder "%getDir%" SetTimer, RemoveToolTip, 2500 Run, explore, %getDir% Return GetModuleFileNameEx( p_pid ) { If A_OSVersion in WIN_95,WIN_98,WIN_ME { MsgBox, This Windows version (%A_OSVersion%) is not supported. Return } h_process := DllCall( "OpenProcess", "uint", 0x10|0x400, "int", false, "uint", p_pid ) if ( ErrorLevel or h_process = 0 ) Return name_size = 255 VarSetCapacity( name, name_size ) result := DllCall( "psapi.dll\GetModuleFileNameExA", "uint", h_process, "uint", 0, "str", name, "uint", name_size ) DllCall( "CloseHandle", h_process ) Return, name } CopyCaption: WinGetTitle, getTitle, ahk_id %WindowUnderMouseID% WinGetClass, getClass, ahk_id %WindowUnderMouseID% If A_ThisMenuItem=Copy Caption Text { ToolTip, Copied into clipboard:`n`nWindow title: %getTitle%. SetTimer, RemoveToolTip, 5000 Clipboard=%getTitle% ;Caption Only } Else { ToolTip, Copied into clipboard:`n`nWindow title: %getTitle% `nWindow class: ahk_class %getClass%. SetTimer, RemoveToolTip, 5000 Clipboard=%getTitle% ahk_class %getClass% ;Caption & Windows Class } Return ChangeCaption: WinGetTitle, getTitle, ahk_id %WindowUnderMouseID% Gui 10: Destroy Gui 10: +AlwaysOnTop +ToolWindow Gui 10: Add, Edit, vInput, %getTitle% Gui 10: Add, Button, Default ys, OK cutoff:=(A_ScreenWidth/3)*2 ;2/3rd of the screen If ClickX > %cutoff% ;if clicked part greater than 2/3rd of the screen then display in the center Gui 10: Show, xCenter y%ClickY%, Enter new title: Else Gui 10: Show, x%ClickX% y%ClickY%, Enter new title: Return 10GuiEscape: Gui 10: Destroy Return 10ButtonOK: ;for ChangeCaption Gui 10: Submit NewTitle = %Input% WinSetTitle, %getTitle%,,%NewTitle% ToolTip, Changed caption into:`n%NewTitle%. SetTimer, RemoveToolTip, 5000 Return MButton:: MouseGetPos, ClickX, ClickY, WindowUnderMouseID SendMessage, 0x84,, ( ClickY << 16 )|ClickX,, ahk_id %WindowUnderMouseID% If ErrorLevel in 2,3 ;in titlebar enclosed area - top of window { Menu, CopyCaption, Show Return } Else { If GetKeyState("MButton", "P") MouseClick, Middle, %ClickX%, %ClickY%,, Down Else MouseClick, Middle, %ClickX%, %ClickY% } Return SendFeedback: Run,http://www.donationcoder.com/Forums/bb/index.php?board=71.0,,UseErrorLevel Return RemoveToolTip: SetTimer, RemoveToolTip, Off ToolTip Return ExitSub: ExitApp