Keyboard shortcuts assignment needed for 'Sort by' modes

Ideas for improvements and requests for new features in XnView MP

Moderator: xnview

tajinoxn
Posts: 18
Joined: Wed Aug 28, 2024 8:32 am

Keyboard shortcuts assignment needed for 'Sort by' modes

Post by tajinoxn »

As of XnView MP 1.11.5 and earlier, it is not possible to assign custom keyboard shorcuts to 'Sort by' modes. While 'View As' can be mapped to user keys, 'Sort by' modes should also be able to be assignable to user keys for quick access.

Although most of the Sort by modes can be set by clicking the Sort by Header, except for Sort by "Custom" order, to set it you either have to navigate the View menu or the Toolbar Sort by dropdown. This becomes cumbersome when you need to change Sort mode very often when viewer different folders especially that XnView treats Sort by modes as a global setting and not a per folder setting. This would be another feature request to have an option to save Sort by mode per folder would be very handy.

As a workaround, I use Autohotkey to send keystrokes to the View menu to set the few Sort by mode that I used most often, although it works, it is clumsy. A native keyboard shortcut implementation would be the most ideal, hence this feature request.

Code: Select all

;-------------- XnView MP key remap
#IfWinActive, ahk_exe xnviewmp.exe
!c::XnViewMP_sortMode("{Up 7}")    ;sort by Custom Order
!m::XnViewMP_sortMode("{Down 2}")  ;sort by Date Modified
!n::XnViewMP_sortMode("")          ;sort by Name
return


XnViewMP_sortMode(sortKey)
{ 
  LockMouse(True)  ; Lock mouse cursor in place
  
  ; Check if the physical Alt key is currently pressed down
  if GetKeyState("Alt", "P")
  {
      SendEvent, {Blind}v
  }
  else
  {
      SendEvent, !v
  }
  
  Sleep, 50            ; Allow menu to open
  SendEvent, {Blind}{Down 2}{Right}%sortKey%{Enter} ; Select sort Mode item
  LockMouse(False) ; Release mouse cursor
}

LockMouse(Lock := True) {
    if (Lock) {
        VarSetCapacity(rect, 16, 0)
        DllCall("GetCursorPos", "Ptr", &rect)
        ; Set bottom-right bounding coordinates (X+1, Y+1)
        NumPut(NumGet(rect, 0, "Int") + 1, rect, 8, "Int")
        NumPut(NumGet(rect, 4, "Int") + 1, rect, 12, "Int")
        DllCall("ClipCursor", "Ptr", &rect)
    } else {
        DllCall("ClipCursor", "Ptr", 0)
    }
}
hGU1xsZj5SMrgpn
Posts: 6
Joined: Wed Sep 23, 2026 3:36 am

Re: Keyboard shortcuts assignment needed for 'Sort by' modes

Post by hGU1xsZj5SMrgpn »

Second this, I just searched this exact problem and find this post.

Please consider!
KLE-France
Posts: 184
Joined: Mon Jan 14, 2019 3:00 pm

Re: Keyboard shortcuts assignment needed for 'Sort by' modes

Post by KLE-France »

Signing in specifically to give my support to this too.

It's important not to forget sort order as well. For example, let's say I assign E to exif date taken. Pressing E once should give me oldest to newest and pressing it again should give me newest to oldest. Or something similar (E and Ctrl+E...).

By the way, this "double press" concept is something I'd like to see as well with the View as function as an on/off. For example, I assign L to Thumbnails plus labels; pressing it again should return the view to whatever it was before.

... So, should pressing E a third time return my sort order to what it was before?? No. That's silly.
Last edited by KLE-France on Wed Sep 23, 2026 1:21 pm, edited 1 time in total.
hGU1xsZj5SMrgpn
Posts: 6
Joined: Wed Sep 23, 2026 3:36 am

Re: Keyboard shortcuts assignment needed for 'Sort by' modes

Post by hGU1xsZj5SMrgpn »

KLE-France wrote: Wed Sep 23, 2026 7:51 am Signing in specifically to give my support to this too.

It's important not to forget sort order as well. For example, let's say I assign E to exif date taken. Pressing E once should give me oldest to newest and pressing it again should give me newest to oldest. Or something similar (E and Ctrl+E...).

By the way, this "double press" concept is something I'd like to see as well with the View as function as an on/off. For example, I assign L to Thumbnails plus labels; pressing it again should return the view to whatever it was before.

... So, should pressing E a third time return my sort order to what it was before??
Execute the shortcut again to reverse the order is a great idea! second this too.
Execute the shortcut again to turn something on and off and a third press to return to the original sort order though might be too confusing, I for one would never remember how many times I have already pressed or what the original view was...... just cycling in two direction of the same state is more straightforward and intuitive imo.
KLE-France
Posts: 184
Joined: Mon Jan 14, 2019 3:00 pm

Re: Keyboard shortcuts assignment needed for 'Sort by' modes

Post by KLE-France »

hGU1xsZj5SMrgpn wrote: Wed Sep 23, 2026 8:13 am Execute the shortcut again to turn something on and off and a third press to return to the original sort order though might be too confusing (...) just cycling in two direction of the same state is more straightforward and intuitive imo.
About 30 minutes after writing what I did, I had that same thought: The three presses idea isn't a good one.

Cheers!