0

I frequently copy a file path from a chat program, open the run dialog with Win+r, and paste the path to open the file.

I'm wondering if I can simplify this:

  • To two steps (open the path on the clipboard)
  • Or one step? (treat highlighted text as a path and open in explorer)

The solution should be possible to invoke with a keyboard shortcut while another program has focus (e.g. the chat program where the path is listed)

Is this possible using a batch or powershell script, or would it need to be a small program running in the background?

3
  • 3
    i'm not exactly sure if I understand your question correctly, but if you want to have a hotkey or open a highlighted path immediately, you could use Autohotkey autohotkey.com/board/topic/109850-open-highlighted-filepath
    – SimonS
    Sep 3, 2020 at 15:08
  • Thanks Simon, this is exactly the behavior I'm trying to achieve, but I'd like to do it without 3rd party software so it is more easily portable and shareable.
    – jake
    Sep 3, 2020 at 16:09
  • so i found and edited a script that basically emulates this autohotkey behaviour, but as of right now it can only get single keys (e.g X, Y, F11), but not keycombinations (e.g CTRL + X). I'll read up on that a bit and post it as an answer when I'm finished
    – SimonS
    Sep 4, 2020 at 16:04

2 Answers 2

2

Copying this from the response by @SimonS above just so it shows up as an answer. I'm doing the same thing using Autohotkeys shown in his link so that any text I currently have highlighted is executed using the windows 'Run' command.

"if you want to have a hotkey or open a highlighted path immediately, you could use Autohotkey http://www.autohotkey.com/board/topic/109850-open-highlighted-filepath"

If anyone knows how I can attribute this answer to jake please let me know.

2
  • I think you want to attribute it to @SimonS
    – jake
    Sep 3, 2020 at 16:07
  • Thank you. Updated the text but can't seem to insert a proper link to his comment from my phone.
    – Eric Peery
    Sep 4, 2020 at 17:17
0

I found that a simple powershell command does the trick for the two-step version:

get-clipboard|invoke-item

This works as a shortcut without even requiring a dedicated script file:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass "get-clipboard|invoke-item"

It gets kludgey from there:

  • You can only assign a keyboard shortcut if the shortcut is saved on the desktop
  • You can't use the Win key in shortcuts
  • You can't keep the powershell console from flashing on the screen for a second

But maybe that's the best-case without 3rd party software.

3
  • 1
    But, 'invoke-action' is not a native PowerShell cmdlet/function. So, ether that is a custom function you ginned up or downloaded from elsewhere. I do see though in your actual command, you are using 'Invoke-Item' to achieve your use case. As for only on the desktop, well, you can put it on the taskbar, in position 1-10 (actually 1..9,0), and the use WinKey+ThePositionNumber as your hotkey, without having to create one. Also, you can prevent the flash, but that's a bit more work.
    – postanote
    Sep 3, 2020 at 16:32
  • Indeed, action was a typo for item when I wrote that up. Thanks for the tip on the taskbar shortcuts. Didn't know about those!
    – jake
    Sep 4, 2020 at 15:31
  • No worries. The taskbar thing has been possible since WinXP. ;-} and I've been using it ever since for my regularly used stuff. Since it is WinKey based, no matter what you have on your screen (active or not), WInKey+# is always possible. Well, not in some kiosk mode stuff, but, you know. Just remember to use the numbers across the top of your keyboard, the number pads don't work for this, well, not on any keyboard I've used to date.
    – postanote
    Sep 4, 2020 at 17:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .