Select Filename in TC7 using AHK

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

Code: Select all

      if (sss = fn) or (sss="")
      {
         SendMessage, LB_SETCARETINDEX, A_Index, 1, TMyListBox%panel%, ahk_class TTOTAL_CMD
         break
      }
The first line should be

Code: Select all

      if (sss = fn)
as it select a null file right after the last in the list if no filename match was found. Dangerous. Seemigly didnt do any harm though.
I switched to Linux, bye and thanks for all the fish!
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

yeah, right :P
And you get the infinite loop then. The code should be:

Code: Select all

if (sss = fn) or (sss="") 
      { 
         if sss =
               break
         SendMessage, LB_SETCARETINDEX, A_Index, 1, TMyListBox%panel%, ahk_class TTOTAL_CMD 
         break 
      }
Guys, I did it with half brain... i was staying long time last night...

But I see you discovered alot of errors and fixed them.
Habemus majkam!
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2majkinetor !
You are brilliant even with half brain :-)
I switched to Linux, bye and thanks for all the fish!
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

BTW,

Code: Select all

ControlGet, List
finally works due to the LB_GETTEXT support!
I switched to Linux, bye and thanks for all the fish!
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Cool :D

Sound very nice in combination with regular expressions :)
Can be done some kind of MRT in in AHK now :) Very easily. Even better RegExp and faster then in TC.
Habemus majkam!
User avatar
van Dusen
Power Member
Power Member
Posts: 684
Joined: 2004-09-16, 19:30 UTC
Location: Sinzig (Rhein), Germany

Post by *van Dusen »

robinsiebler wrote:That rocks! I wish AutoIT and AHK would merge so I could do stuff like that in AutoIT. :(
Just use the <GuiList.au3> UDF for GuiList Management. List of functions:

_GUICtrlListAddDir ... Add File/Folder names to the list displayed by the list box
_GUICtrlListAddItem ... Add an item to the List
_GUICtrlListClear... Remove all items from the list box
_GUICtrlListCount ... Get the number of items in the list box
_GUICtrlListDeleteItem ... Delete an Item from the List
_GUICtrlListFindString ... Return the index of matching item
_GUICtrlListGetAnchorIndex ... Get the Anchor Index
_GUICtrlListGetCaretIndex ... Return index of item that has the focus rectangle
_GUICtrlListGetHorizontalExtent ... Retrieve from a list box the the scrollable width (pixels)
_GUICtrlListGetInfo ... Retrieve the number of items per column in a specified list box.
_GUICtrlListGetItemRect ... Retrieve the dimensions of the rectangle that bounds a list box item.
_GUICtrlListGetLocale ... Current Locale of the listbox
_GUICtrlListGetSelCount ... Get the number of items selected
_GUICtrlListGetSelItems ... Get item indices of selected items
_GUICtrlListGetSelItemsText ... Get the text of selected items
_GUICtrlListGetSelState ... Get the selection state of item
_GUICtrlListGetText ... Returns the item (string) at the specified index
_GUICtrlListGetTextLen ... Alternative to StringLen
_GUICtrlListGetTopIndex ... Retrieve the index of the first visible item in a list
_GUICtrlListInsertItem ... Insert a string into the list
_GUICtrlListReplaceString ... Replaces the text of an item at index
_GUICtrlListSelectedIndex ... Return the index of selected item
_GUICtrlListSelectIndex ... Select a string and scroll it into view, if necessary
_GUICtrlListSelectString ... Select item using search string
_GUICtrlListSelItemRange ... Select range by index in a multiple-selection list box
_GUICtrlListSelItemRangeEx ... Selects items from $i_start to $i_stop
_GUICtrlListSetAnchorIndex ... Set the Anchor Index
_GUICtrlListSetCaretIndex ... Set the focus rectangle to the item at the specified index.
_GUICtrlListSetHorizontalExtent ... Set the width, in pixels, by which a list box can be scrolled horizontally
_GUICtrlListSetLocale ... Set the locale
_GUICtrlListSetSel ... Select string(s) in a multiple-selection list box
_GUICtrlListSetTopIndex ... Ensure that a particular item in a list box is visible
_GUICtrlListSort ... Re-sorts list box if it has the $LBS_SORT style
_GUICtrlListSwapString ... Swaps the text of two items at the specified indices



Example (similar to the given AHK script):

Code: Select all

;*** SetTCFilename
AutoItSetOption("WinTitleMatchMode", 4)
#Include <GuiList.au3>

;*** $strPanelSearched:  2=Left panel, 1=Right panel
;*** $booSelectFilename: TRUE=(Un)Select filename, FALSE=Just set focus on filename
;*** $intSelectFilename: 0=Unselect; 1=Select; -1=Toggle
_SetTCFilename(InputBox("SetTCFilename", "Filename", "Windows", "", Default, 100), "2", True, 1)
Exit

Func _SetTCFilename($strFilenameSearchedFor, $strPanelSearched="2", $booSelectFilename=False, $intSelectFilename=1)
	$hndListBox = ControlGetHandle("classname=TTOTAL_CMD", "", "TMyListBox" & $strPanelSearched)
	For $intListBoxIndex = 0 To _GUICtrlListCount($hndListBox)
		If StringInStr(_GUICtrlListGetText($hndListBox, $intListBoxIndex), $strFilenameSearchedFor) = 1 Then
			_GUICtrlListSetCaretIndex($hndListBox, $intListBoxIndex, False)
			If $booSelectFilename Then _GUICtrlListSetSel($hndListBox, $intSelectFilename, $intListBoxIndex)
			ExitLoop
		EndIf
	Next
EndFunc

Unfortunately I don't know yet, why

Code: Select all

$intListBoxIndex = _GUICtrlListFindString($hndListBox, $strFilenameSearchedFor)
or

Code: Select all

$intListBoxIndex = _GUICtrlListSelectString($hndListBox, $strFilenameSearchedFor)
doesn't work (return value is set to $LB_ERR, when used for TC's file panels) :(
It seems to be necessary to check the filenames in a loop (For $intListBoxIndex = 0 To _GUICtrlListCount($hndListBox) ... Next)
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

I changed the function on first page with more robust one.

Also, TC doesn't recognize LB_COUNT message. Possibly ghisler forgot to provide support for this.
Habemus majkam!
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Edit: Err, somehow I confused this thread with the Locate thread. So, whatever has been written here before, forget it! ;)

It looks like ghisler has forgotten to support several commands, probably all those which are not needed by the blind? This needs further investigation...

Icfu
This account is for sale
Post Reply