Custom navigation by skipping several files?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Maximko
Junior Member
Junior Member
Posts: 3
Joined: 2017-11-26, 15:33 UTC

Custom navigation by skipping several files?

Post by *Maximko »

When navigating in a directory with lots of files, it is convenient to have an option of "intermediate-scale" navigation. Up/down arrows are "fine-scale", as the move up/down one item. PageUp/PageDown are too "large-scale", as they jump by "pages". Is it possible to assign, say, Left/Right keys to move by 10 files backward/forward? I couldn't find an appropriate cm_* command in Navigation. Maybe possible to define a user command?
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Maximko,
An AutoHotkey script as a workaround:

Code: Select all

#NoEnv

SendMode, Input

Keys := {Left: "{Up 10}", Right: "{Down 10}"}

#IfWinActive, ahk_class TTOTAL_CMD
Right::
Left::
	SendMessage, 1074, 3
	ActiveFilePanelHwnd = %ErrorLevel%
	ControlGetFocus, FocusedControl, A
	ControlGet, FocusedControlHwnd, Hwnd, , %FocusedControl%, A
	IfEqual, FocusedControlHwnd, %ActiveFilePanelHwnd%
		Send, % Keys[A_ThisHotkey]
	Else
		Send, {%A_ThisHotkey%}
Return
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Maximko
Junior Member
Junior Member
Posts: 3
Joined: 2017-11-26, 15:33 UTC

Post by *Maximko »

Wow, many thanks! Just what I needed.

For what it's worth, maybe you'll hint a further modification to the script which will allow to go one directory higher with the Left key, if I have reached the top of the list in the panel?


Oh, and also this: for some reason, if I put your script at the beginning of my ahk-file with my other scripts, my other scripts stop working ;) If I put your script after my scripts, your script isn't working. Of course, I can separate them into different files, but - do you maybe know what could be the reason for the conflict? (I have a few simple scripts for shortcuts starting applications).
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Maximko,
Wow, many thanks!
Welcome. ;)
go one directory higher with the Left key, if I have reached the top of the list in the panel

Code: Select all

#NoEnv

SendMode, Input

Keys := {Left: "{Up 10}", Right: "{Down 10}"}

#IfWinActive, ahk_class TTOTAL_CMD
Right::
Left::
;	Get the handle of the active panel control
	SendMessage, 1074, 3
	ActiveFilePanelHwnd = %ErrorLevel%

;	Get the handle of the currently focused control
	ControlGetFocus, FocusedControl, A
	ControlGet, FocusedControlHwnd, Hwnd, , %FocusedControl%, A
	
;	If the currently focused control is TC's active panel
	IfEqual, FocusedControlHwnd, %ActiveFilePanelHwnd%
	{
;		Get the cursor position
		SendMessage, 1074, 1000
		ActiveFilePanelId = %ErrorLevel%
		SendMessage, 1074, 1006 + ActiveFilePanelId
		CursorPos = %ErrorLevel%

		If (A_ThisHotkey = "Left") AND (CursorPos = 0)
			SendMessage, 1075, 2002		; cm_GoToParent
		Else
			Send, % Keys[A_ThisHotkey]
	}
	Else
		Send, {%A_ThisHotkey%}
Return
if I put your script at the beginning of my ahk-file with my other scripts, my other scripts stop working ;) If I put your script after my scripts, your script isn't working. Of course, I can separate them into different files, but - do you maybe know what could be the reason for the conflict?
Hard to say without seeing your script. If you put my script at the beginning, you might need to an

Code: Select all

#IfWinActive
right after it so the rest of the script (your part) is not affected by the #IfWinActive, ahk_class TTOTAL_CMD directive. But that does not explain why my script wouldn't work if it's at the end. The easiest way would be to post your script if there are no sensitive information.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Maximko
Junior Member
Junior Member
Posts: 3
Joined: 2017-11-26, 15:33 UTC

Post by *Maximko »

Thanks again. Adding #IfWInActive after your snippet restores the functionality of my scripts. Based on your sample code, I think I'll be able to dig deeper into autohotkey ;)
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Maximko,
Glad to hear that. ;)

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Post Reply