Because of this and this thread I decided to make an ahk script, that change the behavior of the keys and mouse-clicks inside the inline-rename-box. It takes effect in pane1, pane2, tree and the catalog. The script comes in 3 flavors (see below). Since the code is available, everybody can adapt it to his/her own likings.
Requirements:
For the ahk-code version of the script to run, you must have AutoHotkey installed: https://www.autohotkey.com/
Downloads:
The zips each contain an ahk-code-file. "Ultimate" also contains a compiled exe, just in case someone trusts me and likes this way better. USAGE AT EVERYBODY'S OWN RISK!!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Flavor A: XYAHK_inlineRenameOldStyle:
Implements only small changes: On a current selection the arrow keys behave as in Windows Explorer. The up and down keys switch to the next filename in the list immediately even if there is a current selection (only if the basic XY setting is activated in configuration of course). Changes of v0.003: XY changed its Edit-IDs - I adjusted the script accordingly.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Flavor B: XYAHK_customInlineRenameMouse++:
On double click it makes the edit box select only only alpha-numeric connected characters (e.g. excluding the extension-dot from the selection). Changes of v0.003: XY changed its Edit-IDs - I adjusted the script accordingly.
Note: "OldStyle" and "Mouse++" can be run together, if desired. "Ultimate", though, includes the other two already, so do not run it together with them.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Flavor C: XYAHK_customInlineRenameKeys ("ultimate" version):
The ultimate in XYplorer inline-renaming (as far as I could make it). If I think of "perfecting" the behaviour of inline-renaming in XYplorer then this is (almost) kind of the way I would want it:
Functionalities of "XYAHK_inlineRenameOldStyle" and "XYAHK_customInlineRenameMouse++" is already build-in. On top of that it has lots of build-in logic: End and Home first jump to the ends of a current selection. End (without current selection) toggles between end of name base and of extension. Multiple F2 toggles nicer. Ctrl-Tab and Ctrl-Shift-Tab select the current/next/previous word, as inspired by sfwood in this thread below. Up and Down have a smartness of where to put the caret in the next filename. Changes of v0.007: XY changed its Edit-IDs - I adjusted the script accordingly. // Added Ctrl-Tab and Ctrl-Shift-Tab to select the current/next/previous word, as inspired by sfwood in this thread below.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Archive of old versions: Here is the ahk code of the first two (simpler) versions without having to download:
XYAHK_inlineRenameOldStyle_v0.003.ahk:
Code: Select all
; copyright: Stephan Bartl, 1st version on October 8th, 2014
; script name: XYAHK_inlineRenameOldStyle
; version 0.002
; version 0.003 - 200205: The inline rename edit fields' EditNN names changed in XY. Updated those EditNN names and put them into a variable defined at the beginning.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent
#SingleInstance force
titleMatchStringForXY := "XYplorer ahk_class ThunderRT6FormDC"
editNNof_XY_RPanel_Catalog_LPanel_Tree := "Edit16|Edit18|Edit19|Edit20"
SetTitleMatchMode, 2
SetKeyDelay, 0
#if editNNHavingFocus := _XYOneOfEditNNHasFocus(editNNof_XY_RPanel_Catalog_LPanel_Tree, titleMatchStringForXY)
Left::
ControlGet, selectedText, Selected, , %editNNHavingFocus%, %titleMatchStringForXY%
if (selectedText)
ControlSend, %editNNHavingFocus%, {Right}{Left}, %titleMatchStringForXY%
else
ControlSend, %editNNHavingFocus%, {Left}, %titleMatchStringForXY%
return
Right::
ControlGet, selectedText, Selected, , %editNNHavingFocus%, %titleMatchStringForXY%
if (selectedText)
ControlSend, %editNNHavingFocus%, {Right}{Right}, %titleMatchStringForXY%
else
ControlSend, %editNNHavingFocus%, {Right}, %titleMatchStringForXY%
return
Up::
ControlGet, selectedText, Selected, , %editNNHavingFocus%, %titleMatchStringForXY%
if (selectedText)
ControlSend, %editNNHavingFocus%, {Right}{Up}, %titleMatchStringForXY%
else
ControlSend, %editNNHavingFocus%, {Up}, %titleMatchStringForXY%
return
Down::
ControlGet, selectedText, Selected, , %editNNHavingFocus%, %titleMatchStringForXY%
if (selectedText)
ControlSend, %editNNHavingFocus%, {Right}{Down}, %titleMatchStringForXY%
else
ControlSend, %editNNHavingFocus%, {Down}, %titleMatchStringForXY%
return
End::
;~ indexOfTargetChar := 3
;~ ControlGet, hEdit, Hwnd, , %editNNHavingFocus%, %titleMatchStringForXY%
;~ Edit_PosFromChar(hEdit, indexOfTargetChar, X, Y)
;~ MsgBox x:%x% y:%y%
;~ VarSetCapacity(iX, 4, 0)
;~ VarSetCapacity(iY, 4, 0)
;~ NumPut(X, iX, 0, "Int")
;~ NumPut(Y, iY, 0, "Int")
;~ DllCall("User32.dll\SetCaretPos", "Int", iX, "Int", iY)
VarSetCapacity(POINT, 8, 0)
DllCall("User32.dll\GetCaretPos", "Ptr", &POINT)
X := NumGet(POINT, 0, "Int")
Y := NumGet(POINT, 4, "Int")
ControlGet, hEdit, Hwnd, , %editNNHavingFocus%, %titleMatchStringForXY%
EM_CHARFROMPOS(hEdit, X, Y, CharPos, Line)
EM_GETSEL(HEDIT, Start, End)
MsgBox x: %X% y: %Y% hEdit: %hEdit% charPos: %CharPos%
;~ MsgBox, 0, Selection, Start: %Start%`nEnd: %End%`nCaret: %CharPos%
return
#if
_XYOneOfEditNNHasFocus(listOfEditNNs, WinTitle)
{
ControlGetFocus, focusedControl, %WinTitle%
return InStr(listOfEditNNs . "|", focusedControl . "|") ? focusedControl : 0
}
; ======================================================================================================================
; Gets the starting and ending character positions of the current selection in an edit control.
; Start - receives the start of the current selection
; End - receives the end of the current selection
; ======================================================================================================================
EM_GETSEL(HWND, ByRef Start, ByRef End) {
; EM_GETSEL = 0x00B0 -> msdn.microsoft.com/en-us/library/bb761598(v=vs.85).aspx
Start := End := 0
DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", 0x00B0, "UIntP", Start, "UIntP", End, "Ptr")
Start++, End++
Return True
}
; ======================================================================================================================
; Gets information about the character closest to a specified point in the client area of an edit control.
; X, Y - the X- and Y-positions of the point.
; CharPos, Line - receive the character position and the line number.
; ======================================================================================================================
EM_CHARFROMPOS(HWND, X, Y, ByRef CharPos, ByRef Line) {
; EM_CHARFROMPOS = 0x00D7 -> msdn.microsoft.com/en-us/library/bb761566(v=vs.85).aspx
CharPos := Line := 0
CharLine := DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", 0x00D7, "Ptr", 0, "UInt", (Y << 16) | X, "Ptr")
CharPos := (CharLine & 0xFFFF) + 1
Line := (CharLine >> 16) + 1
Return True
}
Edit_PosFromChar(hEdit,p_CharPos,ByRef X,ByRef Y) ;I found this function in one of the ahk forums
{
Static EM_POSFROMCHAR:=0xD6
SendMessage EM_POSFROMCHAR,p_CharPos,0,,ahk_id %hEdit%
X:=(ErrorLevel & 0xFFFF)<<48>>48
;-- LOWORD of result and converted from UShort to Short
Y:=(ErrorLevel>>16)<<48>>48
;-- HIWORD of result and converted from UShort to Short
}
Code: Select all
; copyright: Stephan Bartl, 1st version on October 8th, 2014
; script name: XYAHK_customInlineRenameMouse++
; version 0.002
; version 0.003 - 200205: The inline rename edit fields' EditNN names changed in XY. Updated those EditNN names and put them into a variable defined at the beginning.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent
#SingleInstance force
SetTitleMatchMode, 2
SetKeyDelay, 0
SetMouseDelay, 0
titleMatchStringForXY := "XYplorer ahk_class ThunderRT6FormDC"
editNNof_XY_RPanel_Catalog_LPanel_Tree := "Edit16|Edit18|Edit19|Edit20"
clicks := mouseX1 := mouseY1 := 0
;code for mapping the double click based on http://www.autohotkey.com/board/topic/16321-map-a-double-left-mouse-click-to-a-single-key/?p=105959 by user jonny
#if (editNNHavingFocus := _XYOneOfEditNNsHasFocus(editNNof_XY_RPanel_Catalog_LPanel_Tree, titleMatchStringForXY)) and clicks = 0
~LButton::
CoordMode, Mouse, Window
MouseGetPos, mouseX1, mouseY1
clicks := 1
SetTimer, ClickWait, 400
return
#if (editNNHavingFocus := _XYOneOfEditNNsHasFocus(editNNof_XY_RPanel_Catalog_LPanel_Tree, titleMatchStringForXY)) and clicks > 0
LButton::
CoordMode, Mouse, Window
clicks++
if (clicks = 2)
{
MouseGetPos, mouseX2, mouseY2
if (mouseX1 = mouseX2 and mouseY1 = mouseY2)
{
ControlGetText, textOfEdit, %editNNHavingFocus%, %titleMatchStringForXY%
caretPos := _Edit_CaretGetPos(editNNHavingFocus, titleMatchStringForXY)
selectFromPos := 0
selectToPos := caretPos
Loop, parse, textOfEdit
{
if (A_Index <= caretPos)
{
if A_LoopField is not alnum
selectFromPos := A_Index
}
else if (A_Index > caretPos)
if A_LoopField is alnum
selectToPos++
else
break
}
_Edit_Select(selectFromPos, selectToPos, editNNHavingFocus, titleMatchStringForXY)
}
else
{
SetTimer, ClickWait, off
clicks := 0
}
}
else if (clicks = 3)
{
MouseGetPos, mouseX3, mouseY3
if (mouseX3 = mouseX2 and mouseY3 = mouseY2)
{
_Edit_Select(0, -1, editNNHavingFocus, titleMatchStringForXY)
}
else
{
SetTimer, ClickWait, off
clicks := 0
}
}
return
ClickWait:
SetTimer, ClickWait, off
clicks := 0
return
#if
_XYOneOfEditNNsHasFocus(listOfEditNNs, wintitle)
{
; This script retrieves the ahk_id (HWND) of the active window's focused control. - taken from the ahk help file
GuiThreadInfoSize = 48
VarSetCapacity(GuiThreadInfo, GuiThreadInfoSize)
NumPut(GuiThreadInfoSize, GuiThreadInfo, 0)
if not DllCall("GetGUIThreadInfo", uint, 0, str, GuiThreadInfo)
{
focusedHWND := 0
}
else
focusedHWND := NumGet(GuiThreadInfo, 12) ; Retrieve the hwndFocus field from the struct.
returnValue := 0
Loop, parse, listOfEditNNs, |
{
ControlGet, hEdit, hwnd, , %A_LoopField%, %wintitle%
if (hEdit = focusedHWND)
returnValue := A_LoopField
}
return returnValue
}
; Gets the current caret position (zero-based) of an edit control having input focus
; (at least for XYplorer inline-edit-controls).
; This function is IMHO preferable over ControlGet, outVar, CurrentCol, ... because
; the build in function is not reliable with the caret position around selections.
;
_Edit_CaretGetPos(editNNHavingFocus, wintitle)
{
ControlGetFocus, focusedControl, %wintitle%
if (focusedControl = editNNHavingFocus)
{
ControlGet, hEdit, hwnd, , %editNNHavingFocus%, %wintitle%
ControlGetPos, editX, editY, editW, editH, %editNNHavingFocus%, %wintitle%
CoordMode, Caret, Window
_EM_CHARFROMPOS(hEdit, A_CaretX - editX, A_CaretY - editY, charPos, line)
}
else
charPos := ""
return charPos
}
;***** the following function from http://ahkscript.org/boards/viewtopic.php?f=5&t=4826&p=27883#p27857 by user "just me"
;***** alteration: made the returned index number zero-based
; ======================================================================================================================
; Gets information about the character closest to a specified point in the client area of an edit control.
; X, Y - the X- and Y-positions of the point.
; CharPos, Line - receive the character position and the line number.
; ======================================================================================================================
_EM_CHARFROMPOS(HWND, X, Y, ByRef CharPos, ByRef Line) {
; _EM_CHARFROMPOS = 0x00D7 -> msdn.microsoft.com/en-us/library/bb761566(v=vs.85).aspx
CharPos := Line := 0
CharLine := DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", 0x00D7, "Ptr", 0, "UInt", (Y << 16) | X, "Ptr")
CharPos := (CharLine & 0xFFFF)
Line := (CharLine >> 16)
Return True
}
;*******following functions from http://www.autohotkey.com/board/topic/20981-edit-control-functions/ by user Lexikos
; Standard parameters:
; Control, WinTitle If WinTitle is not specified, 'Control' may be the
; unique ID (hwnd) of the control. If "A" is specified
; in Control, the control with input focus is used.
;
; Standard/default return value:
; true on success, otherwise false.
_Edit_Standard_Params(ByRef Control, ByRef WinTitle) { ; Helper function.
if (Control="A" && WinTitle="") { ; Control is "A", use focused control.
ControlGetFocus, Control, A
WinTitle = A
} else if (Control+0!="" && WinTitle="") { ; Control is numeric, assume its a ahk_id.
WinTitle := "ahk_id " . Control
Control =
}
}
; Selects text in a text box, given absolute character positions (starting at 0.)
;
; start: Starting character offset, or -1 to deselect.
; end: Ending character offset, or -1 for "end of text."
;
_Edit_Select(start=0, end=-1, Control="", WinTitle="")
{
_Edit_Standard_Params(Control, WinTitle)
SendMessage, 0xB1, start, end, %Control%, %WinTitle% ; EM_SETSEL
return (ErrorLevel != "FAIL")
}