Open with Photoshop

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Plavo
Posts: 2
Joined: 21 Mar 2023, 05:08

Open with Photoshop

Post by Plavo » 21 Mar 2023, 05:44

I have Windows 11, am new to AutoHotkey and struggling to find a solution in V2 that is available in the V1 forum.

The goal is to open a highlighted file in File Explorer in Photoshop with a shortcut so I don't have to right-click and select "Open with" every time I need to perform this sequence.

One solution in the V1 can be found here: https://www.autohotkey.com/board/topic/77384-shortcut-to-open-highlighted-file-with-a-specific-program/.

I'm trying to copy the file path and then run it in Photoshop, but I'm stuck. This is all I've been able to come up with. Help?

Code: Select all

!p::
{
    Send "^+c"
    ClipWait [1, 1]
    Run 'Photoshop.exe "%clipboard%"'
}
[Mod edit: [code][/code] tags added.]

Thanks in advance for helping a newb.

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Open with Photoshop

Post by mikeyww » 21 Mar 2023, 08:46

Welcome to this AutoHotkey forum!

Maybe something like this.

Code: Select all

#Requires AutoHotkey v2.0
app := A_WinDir '\System32\notepad.exe'                       ; Update as needed
app := A_ProgramFiles '\Adobe\Acrobat DC\Acrobat\Acrobat.exe' ; Etc.

!p:: {  ; ALT-P = Open selected files
 For each, item in getSelected() {
  Run app ' "' item '"'
  Sleep 200
 }
}

getSelected() { ; https://www.autohotkey.com/boards/viewtopic.php?style=17&t=60403#p255256 by teadrinker
 ; https://www.autohotkey.com/boards/viewtopic.php?p=509080#p509080
 hwnd := WinExist('A'), selection := []
 If WinGetClass() ~= '(Cabinet|Explore)WClass'
  For window in ComObject('Shell.Application').Windows {
   Try window.hwnd
   Catch
    Return
   If window.hwnd = hwnd
    For item in window.document.SelectedItems
     selection.Push(item.path)
  }
 Return selection
}

Plavo
Posts: 2
Joined: 21 Mar 2023, 05:08

Re: Open with Photoshop

Post by Plavo » 21 Mar 2023, 18:00

This worked perfect! Thanks for your help @mikeyww. I appreciate it.

Post Reply

Return to “Ask for Help (v2)”