To not show unwanted items in the file context menu

Features wanted...
Post Reply
John_C
Posts: 336
Joined: 16 May 2018 20:04

To not show unwanted items in the file context menu

Post by John_C »

Windows itself and different third party software often add many different items in the file context menu and eventually cluttering it.

Here is how the context menu of png files looks in my case:
png-files-context-menu-small.png
This might be a good idea to allow XY to be our bodyguard here, that is, to have control which items to show and which items to not show.
You do not have the required permissions to view the files attached to this post.

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: To not show unwanted items in the file context menu

Post by highend »

It shows the shell menu so control those entries where they need to be controlled, either through the app that installed them or via ShellMenuView from Nirsoft
One of my scripts helped you out? Please donate via Paypal

WirlyWirly
Posts: 312
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 10 @ 100% (3440x1440)

Re: To not show unwanted items in the file context menu

Post by WirlyWirly »

Since the context menu is binded to the system and therefore not portable, what I've done is scripted a custom menu with only the right-click options that I've found useful.

After making my selection, I simply press the assigned hotkey and I get this menu. I use AHK to emulate Vim's modal modes on XY, so this is a perfect solution. If you use a mouse with programmable buttons you can make it just as easy on yourself.

I posted the code if you'd like to use it as reference for your own menu...

viewtopic.php?p=196960#p196960

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: To not show unwanted items in the file context menu

Post by highend »

I use AHK to emulate Vim's modal modes on XY
Interesting. Can you share the .ahk script?
One of my scripts helped you out? Please donate via Paypal

John_C
Posts: 336
Joined: 16 May 2018 20:04

Re: To not show unwanted items in the file context menu

Post by John_C »

WirlyWirly wrote: 24 Mar 2022 17:53 After making my selection, I simply press the assigned hotkey and I get this menu.
Good idea. It seems we can bind the CEA that invokes custom menu to middle-click on file, and then simply remap middle and right clicks with AutoHotkey.

WirlyWirly
Posts: 312
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 10 @ 100% (3440x1440)

Re: To not show unwanted items in the file context menu

Post by WirlyWirly »

highend wrote: 24 Mar 2022 20:03
I use AHK to emulate Vim's modal modes on XY
Interesting. Can you share the .ahk script?
It's pretty crude, but I'm basically using AHK to remap keyboard keys within XY to be used as navigation and XY hotkeys (commands, scripts, etc). When in "insert mode" I have bash-like line navigation for quickly jumping the carat around the line.

If you're familiar with vim you'll recognize h,j,k,l for basic navigation, gg for top line, G for bottom line, <CTRL-f> for pgdown, gt for next tab, i for "insert mode" (which will temporarily return the keyboard to normal until <CTRL-[> or <Esc> is pressed), etc...

Aside from vim-like navigation, I've mapped XY specific things to keys that I've found intuitive: r for rename, R for your ColumnEdit script, o for open in new tab, O for open in new tab on other pane, tt for duplicate tab, TT for duplicate tab to other pane, / for Live Filter + Insert Mode, <Shift-/> for Quick Search + Insert Mode, etc.

It's kind of a hot-mess to anyone but me, but I've been using this script since the first week I started with XY. It works great, since I'm fluent in the keys I remapped I can jump around XY much quicker than if I needed a mouse.

XYplorer specific remaps start at line 171

Code: Select all

#SingleInstance Force
#Persistent
#NoEnv

menu, tray, icon, %A_ScriptDir%\icon_active.ico
DetectHiddenWindows, On
SetKeyDelay, 0

GroupAdd, programs, ahk_exe calibre.exe
GroupAdd, programs, ahk_exe Everything64.exe
GroupAdd, programs, ahk_exe mpc-be.exe
GroupAdd, programs, ahk_exe MusicBee.exe
GroupAdd, programs, ahk_exe PDFXEdit.exe
GroupAdd, programs, ahk_exe PortableAppsPlatform.exe
GroupAdd, programs, ahk_exe sizer.exe
GroupAdd, programs, ahk_exe WinSCP.exe
GroupAdd, programs, ahk_exe i_view32.exe

GroupAdd, explorer, ahk_exe explorer.exe
GroupAdd, explorer, ahk_exe Q-Dir_x64.exe
GroupAdd, explorer, ahk_exe XYplorer.exe

; ----- Insert mode -----
GroupAdd, edit_titles, ahk_exe XYplorer.exe ; XYplorer
GroupAdd, edit_titles, ahk_exe MusicBee.exe ; MusicBee

; Text input ID's for various programs and windows
edit_controls := "Edit1|Edit2|Edit16|Edit17|Edit18|Edit19|Edit20|Edit21|WindowsForms10.EDIT.app.0.2bf8098_r7_ad11"

; Bash-like text navigation (If a program in either group and insert mode is active)
#If (WinActive("ahk_group programs") or WinActive("ahk_group explorer")) and (insert_status := _insert_status())
^a::Send {Home} ; Beggining
^b::Send {Left} ; Left
!b::Send ^{Left} ; Back a word
!d::^Delete ; Delete next word
^d::Send {Delete} ; Delete nex character
^e::Send {End} ; End
!f::Send ^{Right} ; Forward a word
^f::Send {Right} ; Right
^h::Send {Backspace} ; Backspace
^k::Send +{End}{Delete} ; Delete everything after the cursour
^n::Send {Down} ; Down
^p::Send {Up} ; Up
!r::Send ^z ; Undo
^u::Send +{Home}{Delete} ; Delete everything before cursour
^w::Send ^+{Left}{Delete}
^y::Send ^v ; Paste

^c:: ; Copy
    Send ^c
    if (A_PriorHotkey == "^c") and (A_TimeSincePriorHotkey < 300)
        {
            ; Copy all
            Send ^a^c{Right}
            return
        }
    return

Escape:: ; Exit insert mode
    SplashImage, off
    menu, tray, icon, %A_ScriptDir%\icon_active.ico
    insert_mode := False
    return

^[:: ; <Esc> and exit insert mode
    Send {Escape}
    Sleep, 100
    if (!edit_status := _edit_status(edit_controls))
        {
            SplashImage, off
            menu, tray, icon, %A_ScriptDir%\icon_active.ico
            insert_mode := False
            return
        }
    return

Enter:: ; <Enter> and exit insert mode
    Send {Enter}
    Sleep, 100
    if (!edit_status := _edit_status(edit_controls))
        {
            SplashImage, off
            menu, tray, icon, %A_ScriptDir%\icon_active.ico
            insert_mode := False
            return
        }
    return

Tab:: ; <Tab> and exit insert mode
    Send {Tab}
    Sleep, 100
    if (!edit_status := _edit_status(edit_controls))
        {
            SplashImage, off
            menu, tray, icon, %A_ScriptDir%\icon_active.ico
            insert_mode := False
            return
        }
    return

#if

; Vim-Like naviation (If a program from the group 'programs' is active and NOT insert mode)
#If WinActive("ahk_group programs") and (!insert_status := _insert_status())
^[::Send {Escape} ; Escape
^b::Send {PgUp} ; Page-up
^d::Send {Down 5} ; 5 lines down
^f::Send {PgDn} ; Page-down
+g::Send {End} ; End
^h::^+Tab ; Previous tab
h::Send {Left} ; Left
j::Send {Down} ; Down
k::Send {Up} ; Up
^l::^Tab ; Next tab
l::Send {Right} ; Right
m::AppsKey ; Shortcut menu (Right-click)
^u::Send {Up 5} ; 5 lines up

i:: ; Insert Mode
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

/::
    Send ^f ; Search
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return


g::
    if (A_PriorHotkey == "g") and (A_TimeSincePriorHotkey < 300)
        {
            ; Top
            Send {Home}
            return
        }
        return

+t::
    if (A_PriorHotkey == "g") and (A_TimeSincePriorHotkey < 800)
        {
            ; Previous tab
            Send ^+{Tab}
            return
        }
        return

t::
    if (A_PriorHotkey == "g") and (A_TimeSincePriorHotkey < 800)
        {
            ; Next tab
            Send ^{Tab}
            return
        }
    if (A_Priorkey == "d") and (A_TimeSincePriorKey < 800)
        {
            ; Close tab
            Send ^w
            return
        }
        return

#IfWinActive


; Vim-Like Navigation (If a program from the group 'explorer' is active, and NOT insert mode) ! Lots of xyPlorer exclusive hotkeys
#If WinActive("ahk_group explorer") and (!insert_status := _insert_status())
|::Send ^+!l ; #811 = Swap Locations
^[::Send {Escape} ; #1000 = Escape
[::!Left ; #527 = Navigate Back
]::!Right ; #528 = Navigate Forward
`;::^+l ; #533 = Go-to Line
$::Send +{End} ; Highlight until last
^::Send +{Home} ; Highlight until first
+::Send +{PgUp} ; Highlight Page-up
_::Send +{PgDn} ; Highlight Page-down
%::Send ^a ; #250 = Select All
^Space::Send ^!m ; #253 = Smart Selection filter (+Insert Mode)
a::Send ^+!0 ; Script = Applications.xys
^b::Send {PgUp} ; Page-up
c::^+!4 ; Script = XYCollector.xys
^d::Send {Down 10} ; 10x Down
f::^+!8 ; Script = FolderPanePreview.xys
+g::Send {End} ; Bottom
^+h::Send ^+![ ; #1044 = Move tab Left
^h::^+Tab ; #1019 = Previous tab
+h::+Left ; Highlight Left
h::Send {Left} ; Left
+j::+Down ; Highlight Down
j::Send {Down} ; Down
+k::+Up ; Highlight Up
k::Send {Up} ; Up
^+l::Send ^+!] ; #1045 = Move tab Right
^l::^Tab ; #1018 = Next tab
+l::+Right ; Highlight Right
l::Send {Right} ; Right
^f::Send {PgDn} ; Page-down
+m::^+!5 ; Script = Operations.xys
m::^+!1 ; Script = Launcher.xys
n::Send ^+!n ; #240 = New item menu
+o::Send ^+!' ; #1063 = Open item in new tab in other pane
o::Send ^+!; ; #1043 = Open item in new tab
^p::Send {F11} ; #168 = Pop-up preview
+p::Send ^4 ; #1023 = Preview window
p::^v ; #202 = Paste
^r::^+z ; #204 = Re-do
+r::^+!3 ; Script = XYColumnsEdit.xys
+s::Send +{F5} ; #487 = Calculate Folder Size
s::^+!2 ; Script = SessionsMenu.xys
^u::Send {Up 10} ; 10x Up
+u::Send ^+!u ; #343 = Re-open last closed tab
u::^z ; #203 = Undo
^v::^+!6 ; Script = QuickFolderViews.xys
v::Send ^+{F5} ; #486 = Reset view


+Space::
    Send ^+!b ; #415 = Toggle Checkboxes
    Send ^+!s ; #413 = Toggle Sticky Selection
    return

!Space:: ; #254 = Select by Selected Type(s)
    Send ^m
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

\:: ; #1014 = Focus on Address Bar
    Send !`;
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

+/:: ; #266 = Quick Search (+Insert Mode)
    Send {F3}
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return


/:: ; #1080 = Live-Filter (+Insert Mode)
    Send ^!x
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

+`;:: ; #532 = Go-to Folder
    Send ^+g
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

+d::
    if (A_PriorHotkey == "+d") and (A_TimeSincePriorHotkey < 300)
        {
            ; #170 = Delete no Recycle Bin
            Send +{Delete}
            return
        }
    return

d::
    if (A_PriorHotkey == "d") and (A_TimeSincePriorHotkey < 300)
        {
            ; #169 = Delete
            Send {Delete}
            return
        }
    return

e:: ; Script = Everything.xys (+Insert Mode)
    Send ^+!9
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

g::
    if (A_PriorHotkey == "g") and (A_TimeSincePriorHotkey < 300)
        {
            ; Top
            Send {Home}
            return
        }
        return

i:: ; Insert Mode
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

+n:: ; Script = CreatedNestedItems.xys (+Insert Mode)
    Send ^+!7
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

r:: ; #172 = Rename current file(s)
    Send {F2}
    SplashImage, %A_ScriptDir%\insert_mode.png, B X0 Y950
    WinSet, TransColor, FFFFFF 100, Vim-Like.ahk
    menu, tray, icon, %A_ScriptDir%\icon_suspended.ico
    insert_mode := True
    return

+t::
    if (A_PriorHotkey == "+t") and (A_TimeSincePriorHotkey < 300)
        {
            ; #806 = Duplicate tab to other pane
            Send ^+!t
            return
        }
    if (A_PriorHotkey == "g") and (A_TimeSincePriorHotkey < 800)
        {
            ; #1019 = Previous tab
            Send ^+{Tab}
            return
        }
        return

t::
    if (A_PriorHotkey == "t") and (A_TimeSincePriorHotkey < 300)
        {
            ; #543 = Duplicate tab to same pane
            Send ^+!z
            return
        }
    if (A_PriorHotkey == "g") and (A_TimeSincePriorHotkey < 800)
        {
            ; #1018 = Next tab
            Send ^{Tab}
            return
        }
    if (A_PriorHotkey == "d") and (A_TimeSincePriorKey < 800)
        {
            ; #351 = Close tab
            Send ^w
            return
        }
        return

y::
    if (A_PriorHotkey == "y") and (A_TimeSincePriorHotkey < 300)
        {
            ; #201 = Copy
            Send ^c
            return
        }
    return

x::
    if (A_PriorHotkey == "x") and (A_TimeSincePriorHotkey < 300)
        {
            ; #200 = Cut
            Send ^x
            return
        }
    return

#If

_insert_status(){
    global insert_mode
    return %insert_mode%
}

_edit_status(list_of_edit_controls){
    ControlGetFocus, focused_control, A
    current_control := InStr(list_of_edit_controls . "|", focused_control . "|") ? focused_control : false
    return current_control
}

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: To not show unwanted items in the file context menu

Post by highend »

Thanks!

I'll take a look at it at the weekend. I'm a Vim user since... 20 years I guess, although I didn't use gVim for a few years (but instead Sublime Text and Visual Studio Code with vim-like extensions). Currently rebuilding my gVim v8.2 setup...
One of my scripts helped you out? Please donate via Paypal

Post Reply