Totalcommander - Access Selection without Clipboard - Listboxtitle Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Totalcommander - Access Selection without Clipboard - Listboxtitle

16 Feb 2018, 14:13

Hi,

I wanna catch all selected items out of active Totalcommander (http://www.ghisler.com windows (right/left windows are there).

Therefore I get a hwnd-id via

Code: Select all

WM_User=1074
Sendmessage, WM_USER, 3,0, , ahk_id %vTCHandleID%
delivers a Hwnd from the active Window/Listbox in Totalcommander.

With that I can get what I want (using LB_GETSELCOUNT, LB_GETSELITEMS, LB_GETTEXT in conjunction with Sendmessage in that order).

But that selection result is without file path ..e.g. I'm getting back "test1.docx".

The relevant path name (eg. "c:\temp") is there, but as title/caption of that TC-Listbox.

How to access (=read) that Listbox-Caption/Title via Sendmessage (because I've a secure hwnd only for that) ?

J.B.
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle

16 Feb 2018, 14:49

I don't know how to access/read the ListBox-Caption/Title via SendMessage, but here's another approach that may (or may not) work. Add a custom column via Configuration>Options>Display>Custom columns>New. Call the new column whatever you want, such as FullName or NameWith Path, and select the TC built-in column fullname, which will show [=tc.fullname] in the field contents of the new custom column. Regards, Joe
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle

17 Feb 2018, 02:33

Hi JoeWinograd,

I think I understand what you mean.
But because I want to use that ahk-program for all our users (10) I cant resp. I dont want to change Totalcommander for all of them as you suggested.

What I've and what works is

Code: Select all

; catch hwnd of active Totalcommander-Window (left or right)
WM_USER=1024
Sendmessage, WM_USER+50, 3,0, , ahk_id %vTCHandleID%
tc_hwnd := ErrorLevel


; number of elements selected in TC
LB_GETSELCOUNT = 0x0190
sendmessage, LB_GETSELCOUNT,0,0,,ahk_id %tc_hwnd% 
selection_count := ErrorLevel

; catch indexes of selected elements to an array/object
LB_GETSELITEMS = 0x0191
ItemArray:=object()
VarSetCapacity(Items, selection_count * 4, 0)   ; set var-capacity
sendmessage, LB_GETSELITEMS, selection_count, &items, ,ahk_id %tc_hwnd% 
count_items_found:=ErrorLevel
Loop, % count_items_found
{
    ItemArray[A_Index] := NumGet(Items, (A_Index - 1) * 4, "UInt") + 1
}

; read those (selected) lines from active TC-Window according above catched Line-Indexes
VarSetCapacity(row_string, 1024) ; set var-capacity
LB_GETTEXT= 0x189
results_buffer:=object()
loop, % count_items_found
{
    selected_index := itemarray[a_index]-1   ; get index of lines wanted
    sendmessage, LB_GETTEXT, %selected_index%, &row_string, ,ahk_id %tc_hwnd% 
    results_buffer[a_index] := row_string         ; e.g. "winver_20180217_0809.jpg"
}
and that code gives me the name of the files as shown in the picture below (e.g. "finkzeit_2018-02-17_080525.jpg", "winver_20180217_0809.jpg", "ff_version_20180217_0809.jpg") in results_buffer, but not that caption/title (of the active Totalcommander-window), which is the path ("n:\joma") what I need too.
tc_problem_ahk.jpg
tc_problem_ahk.jpg (28.48 KiB) Viewed 2287 times
How to catch that caption/title with the hwnd (Var tc_hwnd) I've ?

J.B.
Last edited by Jovannb on 18 Feb 2018, 03:51, edited 1 time in total.
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle

17 Feb 2018, 12:57

I don't know how to catch that caption/title with the hwnd. Perhaps you can do Mark>Copy Names With Path To Clipboard (!m then p) on any file in the pane, which will put the full file name on the clipboard and then you can easily parse out the path. Regards, Joe
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle

17 Feb 2018, 13:40

Hi JoeWinograd,

yes I know, this

Code: Select all

; "cm_CopyFullNamesToClip" according to TOTALCMD.INC
WM_USER=1024
cm_CopyFullNamesToClip=2018
SendMessage,WM_USER+51, cm_CopyFullNamesToClip,0, , ahk_id%vTCHandleID%
does what you write, it copies all selected items (including path) in Totalcommander to clipboard

But thats not what I'm aiming for - I dont wanna touch my user's clipboards if not mandatory.

If there is no other option, then this will be my last opportunity.

J.B.
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle

17 Feb 2018, 14:00

Ah, sorry, now I see that in your title..."Access Access Selection without Clipboard". I'm sure you know that you can save the clipboard and then restore it before your script exits, but I don't know of a way to achieve what you want without utilizing the clipboard.
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle

17 Feb 2018, 14:06

because we use sometimes clipboard managers - to have eg. the last 20 clipboard items accessible - I'd like to avoid that
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle

17 Feb 2018, 14:16

Got it...excellent point!
TheHacker
Posts: 29
Joined: 24 Apr 2017, 07:53

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle  Topic is solved

17 Feb 2018, 19:21

Code: Select all

SendMessage, 1074, 17, , , ahk_class TTOTAL_CMD
WinGetText, PathInTC, ahk_id %ErrorLevel%
StringTrimRight, PathInTC, PathInTC, 3
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Re: Totalcommander - Access Selection without Clipboard - Listboxtitle

18 Feb 2018, 04:02

Hi TheHacker,

thank you, that did the trick.

In between I found what it does in detail according to TC-Changelog-History-File from 2016, excerpt:

Code: Select all

; Send WM_USER+50 with wparam=1..29 -> returns window handle of control. Controls are: 1=leftlist, 2=rightlist, 3=active list, 4=inactive list, 5=leftheader, 6=rightheader, 
; 7=leftsize, 8=rightsize, 9=leftpath, 10=rightpath, 11=leftinfo, 12=rightinfo, 13=leftdrives, 14=rightdrives, 15=leftpanel, 16=rightpanel, 17=bottompanel, 18=lefttree,
; 19=righttree, 20=cmdline, 21=curdirpanel, 22=inplaceedit, 23=splitpanel, 24=leftdrivepanel, 25=rightdrivepanel, 26=lefttabs, 27=righttabs, 28=buttonbar,
; 29=buttonbarvertical (32/64)
In my case, it is bottompanel and as far as tests showed up it is always the active bottompanel

J.B.
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 343 guests