moving quickly through folders is not possible anymore?

Ask for help and post your question on how to use XnView Classic.

Moderators: XnTriq, helmut, xnview

User avatar
loth
Posts: 173
Joined: Thu Aug 11, 2005 3:21 pm
Location: Kölle

Re: moving quickly through folders is not possible anymore?

Post by loth »

some years later and some windows installations later...
and suprisingly this will not work for me. a pitty.
User avatar
xnview
Author of XnView
Posts: 43442
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: moving quickly through folders is not possible anymore?

Post by xnview »

How that? With keyboard?
Pierre.
delta
Posts: 14
Joined: Fri May 22, 2009 12:12 pm

Workaround!

Post by delta »

Gee, I really miss that functionality since I'm very used to it from total commander. So I hacked in a quick and dirty Autohotkey script that simulates this function. It's not heavily tested but I thought I share it so you can test it and help improve it. :)

The script reads the folder/file name from the folder/file under the thumbnail pane cursor from the status bar. In other words: In order for the script to work correctly the status bar needs to be turned on (not sure if you can turn it off at all). The script also does not check (yet) what you are doing in XnView so strange things could happen if you accidentally (or deliberately) start a search while, say, renaming categories. Also there is hardly any error handling whatsoever, so the script is definately not foolproof.

How the script works: If you hit Ctrl-Hyphen (Ctrl+-) you can enter a search string (displayed as tool tip in the middle of the screen). While you're entering your search string the script sends presses of the right cursor key to XnView to advance one folder/file in the thumbnail pane 'if necessary'. If you press escape the search is aborted. You can also abort the search by pressing enter or any cursor key. These keys will be passed through to XnView.

The script only searches forwards (for more or less obvious reasons). If you want to search the complete folder (and not only the part after the cursor), press 'home' before starting to search.

Code: Select all

; Quick find for XnView
; by delta (mavieseq(AT)gmx.net)
;
; Version 0.1
; May 27, 2009

#UseHook
CoordMode, ToolTip, Screen

; coordinates for the tooltip that displays the search string
xtip = 500
ytip = 500

; allowed chars for search string
matchlist = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z, ,1,2,3,4,5,6,7,8,9,0,-,_

; the part hereafter will only be executed when XnView is active
#IfWinActive, ahk_class XmainClass

; set search hotkey to Ctrl+- (Ctrl-Hyphen)
^-::
    sstring =
    lastfolder =
    
    ; focus to the thumbnail pane
    ControlFocus, SysListView321, ahk_class XmainClass
       
    ToolTip, Search:, %xtip%, %ytip%
    
    ; set up a timer triggered sub routine (called every 50ms) to advance one folder
    SetTimer, Browse, 50
    
    ; main loop for entering the search string
    Loop
        {
            ; input command
            ;    L1: wait for 1 input char
            ;     I: ignore input generated from the script itself, especially the key presses
            ;        of the timer triggered sub routine
            ;
            ;    {Enter} ... {Down} is a list of keys that end the input. actually every key
            ;    ends the input (due to option L1). nevertheless the end keys treated differently
            ;    from normal inputs.
            ;
            ;    matchlist is the list from above
            Input, userInput, L1 I, {Enter}{Escape}{Backspace}{Left}{Right}{Up}{Down}, %matchlist%
            
            ; actually timeout cannot occur, I had it in previously but it did not work the
            ; way I wanted it to work, so I took it out
            If (ErrorLevel = "timeout") or (ErrorLevel="EndKey:Escape")
                break
            
            If ErrorLevel = EndKey:Backspace
                {
                    If StrLen(sstring) > 1
                        StringLeft, sstring, sstring, StrLen(sstring)-1
                    ErrorLevel =
                }
                
            ; if an end key other than backspace or escape is pressed the search is ended
            ; and the key is passes through to XnView (via the send command)
            IfInString ErrorLevel, EndKey
                {
                    StringTrimLeft, KeyName, ErrorLevel, 7
                    Send, {%keyname%}
                    break
                }                
                                       
            If ErrorLevel = match
                {
                    sstring := sstring . userInput
                    lastfolder =
                }
            
            ; update the tool tip
            ToolTip, Search: %sstring%, %xtip%, %ytip%
        }
    
    ; deactivate the timer triggered sub routine
    SetTimer, Browse, Off
    
    ; erase the tool tip
    ToolTip
return

Browse:
    ; read the file name / folder name of the thumbnail under the cursor from the status bar
    StatusBarGetText, folder, 2, ahk_class XmainClass
    
    ; if the first letter of the search string does not match the first letter of the file/folder
    ; under the cursor, use the first letter (i.e. press it) to quickly navigate to the
    ; files/folder starting with that letter
    ;
    ; you can use != instead of > after sstring if you want to search forward and backward.
    ;
    ; n.b.: you will only notice this function if you are in a folder with files starting with
    ; different letters
    If StrLen(sstring) = 1
        {
            If (sstring > SubStr(folder, 1, 1)) and (sstring != " ")
                Send, %sstring%
        }

    ; lastfolder != folder is checked to prevent the script from frantically hitting the right
    ; cursor key even if there is nothing to advance
    If (lastfolder != folder)
        {
            If (sstring > folder)
                Send, {Right}
        }
                            
    lastfolder := folder
return
What's missing: The script should indicate if the file/folder can't be found anymore, i.e. if you enter 'foo' but the folder under the cursor is already 'foul'. Also the use of backspace is somewhat limited since the script does not go back. In order to make it more useful you would need some sort of history. It's roughly done in my head but I'm too lazy to hack it in right away, because actually I wanted to do something else but got carried away... :wink: Anyway, I hope you find it useful as it is. :)

/edit:
I just discovered that the status bar can be switched off but the script still works fine then. Seems the control (=status bar) is just invisible, not actually not-existent. :)
User avatar
loth
Posts: 173
Joined: Thu Aug 11, 2005 3:21 pm
Location: Kölle

Re: moving quickly through folders is not possible anymore?

Post by loth »

xnview wrote:How that? With keyboard?
yes. with keyboard. and in browser-mode. moving with the crsr-keys up/down is easy,
but trying to enter i.e. "foo" while pressing "f" + "o" + "o" directly jumps to the first folder which is starting with "F" and then jumping directly to the first folder starting with "O". which is *not* the desired behaviour.
funny, isnt it?
the next year, i'll try a new version of xnview and delete my xnview.ini and try, if it works like some other users reported.
Post Reply