3

I would like to select some files on my desktop and then using python script(that will be launched by keyboard combinatoion pressing) get path of all selected files.

I know how to trigger the script by key combination press ,but I have a problem with files path

Any help will be appreciated

  • 2
    Can you please clarify how you invoke the script, what you want to do with the paths and what you've tried so far? – Cu3PO42 Jan 18 '14 at 18:57
  • import pyHook import pythoncom def OnKeyboardEvent(event): if event.Ascii == 25: content hm = pyHook.HookManager() hm.KeyDown = OnKeyboardEvent hm.HookKeyboard() while True: pythoncom.PumpMessages() – user3210523 Jan 18 '14 at 20:21
  • @user3210523, you should edit that code into the question. – shuttle87 Jan 26 '14 at 22:01

1 Answers1

1

I understand pyHook just reads the low level keyboard events. What you want to do is not possible with your approach. You need to get the Windows Explorer to actually tell you the paths you want to know, it needs to invoke the script itself. For this you need shell extension. You can use pywin32 to create them in Python. Here's the documentation to get you started.

Cu3PO42
  • 1,403
  • 1
  • 11
  • 19