How can you extract the full path of the photo visible in photo gallery? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
colt
Posts: 180
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

How can you extract the full path of the photo visible in photo gallery?

14 May 2018, 17:05

I am having trouble finding a way to extract the full path of the image that is shown in photo gallery. Windows spy only shows the filename and extension. This is a good start but does not help if there are multiple images with the same name in different folders. Additionally, I tried looking at the command line arguments used to launch photo gallery using the following code

Code: Select all

for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
    processes .= process.Name "  -  " process.ExecutablePath "  -  " process.CommandLine "`n"
MsgBox % processes
but the relevant output was
WLXPhotoGallery.exe - C:\Program Files (x86)\Windows Live\Photo Gallery\WLXPhotoGallery.exe - "C:\Program Files (x86)\Windows Live\Photo Gallery\WLXPhotoGallery.exe" /PhotoViewerComServer {00F30F64-AC33-42F5-8FD1-5DC2D3FDE06C} -Embedding
As far as I can tell this does not give any useful information.

As a worst case scenario I could send alt+enter to popup the properties pane and get the full path from the security tab.
Any ideas on an alternative?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How can you extract the full path of the photo visible in photo gallery?  Topic is solved

14 May 2018, 17:33

This is what I use on Windows 7 (using the clipboard). Cheers.

Code: Select all

#IfWinActive ahk_class Photo_Lightweight_Viewer ;windows photo viewer / windows live photo gallery
^p:: ;windows photo viewer - get file path
Clipboard := ""
SendInput, ^c
ClipWait, 3
vPath := Clipboard
;MsgBox, % vPath
return
#IfWinActive
Btw command-line arguments usually only contain the path of the *first* file to be opened (the user may have since opened a different file).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
colt
Posts: 180
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: How can you extract the full path of the photo visible in photo gallery?

14 May 2018, 17:48

That is a dirty trick. Would have never tried that.
Btw command-line arguments usually only contain the path of the *first* file to be opened (the user may have since opened a different file).
Good point. I was hoping I could get the path of at least the starting folder and then make some heavy assumptions with the rest of my script.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How can you extract the full path of the photo visible in photo gallery?

14 May 2018, 18:05

- Yeah, it's always unfortunate when you have to use the clipboard or temporarily show a dialog, but it's great to at least have something.
- It's curious programs that ultimately omit the path from the command-line arguments. I suppose that they open secondary processes, but they must transmit that information *somehow*.
- I tested, and it's not too bad to get paths from multiple open windows.

Code: Select all

q:: ;windows photo viewer - get file paths
WinGet, vWinList, List, ahk_class Photo_Lightweight_Viewer
vOutput := ""
Loop, % vWinList
{
	hWnd := vWinList%A_Index%
	Clipboard := ""
	ControlSend,, ^c, % "ahk_id " hWnd
	ClipWait, 3
	vPath := Clipboard
	vOutput .= vPath "`r`n"
}
;Clipboard := vOutput
MsgBox, % vOutput
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Albireo, DaveT1, HeroOfKvatch, HiSoKa, James_9090, mad3d, mikeyww, songdg, ToJaRedi and 66 guests