cm_RenameSingleFile and cm_EditPath lost state

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
yahuu
Junior Member
Junior Member
Posts: 68
Joined: 2015-01-15, 03:19 UTC

cm_RenameSingleFile and cm_EditPath lost state

Post by *yahuu »

autorun.cfg

Code: Select all

LoadLibrary "Plugins\Autorun_Runtime.dll"
RunThread ShowFullPathInTitle

Func ShowFullPathInTitle
   While 1
      srcPath = RequestCopyDataInfo(RequestCopyDataInfo("A") & "P")
      srcName = RequestCopyDataInfo(RequestCopyDataInfo("A") & "N")
      WinSetText(srcPath & srcName)
   Wend
EndFunc
TCx32: When the title displays content as expected, it does not affect the use of other functions.

TCx64: The title can also display content as expected, but commands like cm_RenameSingleFile and cm_EditPath cannot be used, and the editing state is lost immediately.
Fla$her
Power Member
Power Member
Posts: 2527
Joined: 2020-01-18, 04:03 UTC

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *Fla$her »

2yahuu
Instead of WM_CopyData you can use a different approach (I showed a similar here):

Code: Select all

LoadLibrary Plugins\Autorun_Runtime.dll

Global WS_CAPTION = 0x00C00000
# Since we respect the license, the original header should remain in place:
If Not AUTORUN_RESTARTCOUNT Then SetEnv('TC_Title', WinGetText() & ' | Current full name: ')
If WinHasStyle(WS_CAPTION) Then RunThread UpdateTCHeader

Func UpdateTCHeader
   Local CD, sPos
   While 1
      If Not WinHasStyle(WS_CAPTION) Then Return
      CD = WinGetText(RequestInfo(10005))
      sPos = StrPos(CD, '\', -1)
      If sPos = 0 Then sPos = StrPos(CD, '/', -1)
      WinSetText(TC_Title & StrLeft(CD, sPos) & GetCurrentItem(3))
      Sleep 40
   Wend
EndFunc
For additional questions, you can contact the plugin thread.

Of course, it's desirable to fix the WM_CopyData problem.
Overquoting is evil! πŸ‘Ž
User avatar
yahuu
Junior Member
Junior Member
Posts: 68
Joined: 2015-01-15, 03:19 UTC

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *yahuu »

Fla$her wrote: ↑2024-09-29, 05:13 UTC
For additional questions, you can contact the plugin thread.

Of course, it's desirable to fix the WM_CopyData problem.
Thank you for providing new ideas. I did consult Loopbak at Autorun
He also suggested that it would be best for TC to come and fix it.
Fla$her
Power Member
Power Member
Posts: 2527
Joined: 2020-01-18, 04:03 UTC

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *Fla$her »

yahuu wrote: ↑2024-09-30, 12:03 UTCThank you for providing new ideas.
Well, they are not new to me. Have you tested my code on TC x64 with the commands you specified?
Overquoting is evil! πŸ‘Ž
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48565
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *ghisler(Author) »

I'm not a user of the autorun plugin, so I don't quite understand the bug report.

When exactly does cm_RenameSingleFile fail? Do you call it from somewhere in your script? If yes, can you post the script where it fails?
Author of Total Commander
https://www.ghisler.com
Fla$her
Power Member
Power Member
Posts: 2527
Joined: 2020-01-18, 04:03 UTC

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *Fla$her »

ghisler(Author) wrote: ↑2024-10-01, 12:59 UTC I'm not a user of the autorun plugin
This is a big omission.
ghisler(Author) wrote: ↑2024-10-01, 12:59 UTC When exactly does cm_RenameSingleFile fail?
It's about this:
25.11.11 Added: Send WM_COPYDATA with dwData='G'+256*'A' and lpData pointing to command to get back WM_COPYDATA with various info. Supported commands A: Active side (returns L or R), or two byte command: first byte: L=left, R=right, S=source, T=target. Second byte: P=current path, C=list count, I=caret index, N=name of file under caret. dwData of return is 'R'+256*'A' (32/64)
If you add this data in an infinite loop to the TC x64 header, then the focus of the named input fields is lost.
Overquoting is evil! πŸ‘Ž
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48565
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *ghisler(Author) »

Sorry, I still don't understand what you are trying to achieve.
Author of Total Commander
https://www.ghisler.com
Fla$her
Power Member
Power Member
Posts: 2527
Joined: 2020-01-18, 04:03 UTC

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *Fla$her »

I'm not trying to achieve anything, I'm not the topic author. I'm just telling you the source of the problem, which is only in x64.

If you are asking why it's necessary to show the full name of the current list item in the header, it's obviously to be aware of the cursor location in case you scroll the panel with the mouse wheel.

Code: Select all

;β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
; Display current full name in TC header
; AHK 1.1
;β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
#NoEnv
#KeyHistory, 0
ListLines, Off
SetBatchLines,-1
#SingleInstance force

#If WinActive("ahk_class TTOTAL_CMD")
WinGet, TCHwnd, ID, A
WinGetActiveTitle, Title
TCHeader := StrSplit(Title, " |")[1]
Loop {
   WinSetTitle, ahk_id %TCHwnd%,, % TCHeader . " | " . TC_SendData("SP") . TC_SendData("SN")
   Sleep, 40
}
#If

TC_SendData(Cmd, CmdType="", msg="", hwnd="") {
   Critical   ; Define "OnMessage" as STATIC it is registered at Script startup.
   STATIC om:=OnMessage(0x4a, "TC_SendData"), TC_ReceiveDataValue:="", TC_DataReceived:=""   ; 0x4a is WM_COPYDATA

   IF ((msg=0x4A) AND (hwnd=A_ScriptHwnd)) ; EnSure is trigered by this Script.
      EXIT (TC_ReceiveDataValue:=StrGet(NumGet(CmdType + A_PtrSize * 2)), TC_DataReceived:="1")

   VarSetCapacity(CopyDataStruct, A_PtrSize * 3), TC_ReceiveDataValue:=1, TC_DataReceived:=""
   CmdType=""
   CmdType:=(A_IsUnicode ? "GW" : "GA"), TC_ReceiveDataValue:=""

   If( A_IsUnicode ) {
      VarSetCapacity(cmdA, StrPut(cmd, "cp0"))
      Loop, % StrLen(cmd)
         NumPut( Asc(SubStr(cmd, A_Index, 1)), cmdA, A_Index - 1, "Char")
   }
   NumPut(Asc(SubStr(CmdType,1,1)) + 256 * Asc(SubStr(CmdType,2,1)), CopyDataStruct, 0)
   NumPut(StrLen(cmd), CopyDataStruct, A_PtrSize )
   NumPut((A_IsUnicode ? &cmdA : &cmd), CopyDataStruct, A_PtrSize * 2)
   SendMessage, 0x4A, %A_ScriptHwnd%, &CopyDataStruct,, A

   While (TC_ReceiveDataValue="") {
      IfEqual, TC_DataReceived,    1, Break
      IfGreaterOrEqual, A_Index, 500, Break
      Sleep,10
   }
   Return TC_ReceiveDataValue
}
Overquoting is evil! πŸ‘Ž
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48565
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *ghisler(Author) »

Well, the function ShowFullPathInTitle of the original poster just overwhelms Windows with a flood of messages, so I'm not surprised that it breaks Total Commander. I will not handle this and move this thread to the English forum for further discussion.
Author of Total Commander
https://www.ghisler.com
Fla$her
Power Member
Power Member
Posts: 2527
Joined: 2020-01-18, 04:03 UTC

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *Fla$her »

2ghisler(Author)
Let's remove the flood problem and go back to the sequence of calling cm_EditPath/cm_RenameSingleFile and getting this information while the field is focused/active. What do you say about this?
Overquoting is evil! πŸ‘Ž
User avatar
yahuu
Junior Member
Junior Member
Posts: 68
Joined: 2015-01-15, 03:19 UTC

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *yahuu »

Fla$her wrote: ↑2024-09-30, 13:48 UTC
yahuu wrote: ↑2024-09-30, 12:03 UTCThank you for providing new ideas.
Well, they are not new to me. Have you tested my code on TC x64 with the commands you specified?
Yes, I have tested it and your code works perfectly
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48565
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: cm_RenameSingleFile and cm_EditPath lost state

Post by *ghisler(Author) »

To avoid the problem in the first script, try adding a sleep command to the While 1 loop as Fla$her did in his script.
Author of Total Commander
https://www.ghisler.com
Post Reply