views:

156

answers:

1

I don't know if this is even possible, but how can I bind some key combination to a (C#)program, so that when that keyboard shortcut is pressed with some file selected in windows explorer, it calls specific function with path of that file as a parameter.

Or can I assign some keyboard shortcut so that windows explorer opens selected file in my program(that way I could pass the path to already running instance)

thanks

A: 

You could modify your program to run as a shell extension which would add an item for your program to the right-click menu in windows explorer, but apparently coding shell extensions in C# is a bad idea.

As an alternative, with a little work AutoHotkey can do this. Here's a sample script that renames the selected file in Windows Explorer when a certain keyboard combination is pressed. You could modify it to run your C# program and pass the selected filename.

BenV
Thanks!I altough came up with a simpler method already. When global hotkey is pressed, I emulate CTRL+C shortcut, that way I get paths of the selected files to clipboard, and after that I can read them from there. The are few problems though, but I think I can overcome those somehow(file gets copied multiple times(and the function runs more than once), maybe that can be solved with timer or something...)
Juha