saleguas / context_menu

💻 A Python library to create and deploy cross-platform native context menus. 💻
https://context-menu.readthedocs.io/en/latest/index.html
MIT License
464 stars 25 forks source link

Unable to parse file with spaces in name (Windows 11) #37

Closed NebularNerd closed 7 months ago

NebularNerd commented 7 months ago

I'm testing this script and so far, it seems a nice way to play with custom context menus. However, I'm having trouble getting files to open if they have spaces in the name.

Example with notepad (Foo Two):

if __name__ == '__main__':
    from context_menu import menus

    cm = menus.ContextMenu('Foo menu', type='FILES')
    cm.add_items([
        menus.ContextCommand('Foo One', command='cmd /K echo ?', command_vars=['FILENAME']),
        menus.ContextCommand('Foo Two', command='notepad ?', command_vars=['FILENAME']),
        menus.ContextCommand('Foo Three', python=foo3)
        ])
    cm.compile()

If the file is called d:\1.jpg everything works as expected (It should not looking below), if however, the file is d:\cute kittens.jpg it fails with a file not found error: image

If I use Foo One I get an echo but it shows a trailing " at the end of the filename: image image

NebularNerd commented 7 months ago

Closing as this seems to be a weird issue with Windows Context Menus. I ended up writing a small AutoIt exe to resolve this.