Dynamic way to find a program and run it Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
haomingchen1998
Posts: 174
Joined: 20 Feb 2023, 16:37

Dynamic way to find a program and run it

Post by haomingchen1998 » 24 Apr 2024, 20:08

Hi, my end goal is to run a program like this

Code: Select all

Run, "C:\Program Files\VEGAS\VEGAS Pro 20.0\vegas200.exe"
I'm just wondering if there are ways to take it a step further where I can search within a specific drive, say like C drive. Assuming this vegas200.exe file is located somewhere in C drive, and you want to launch that program. I've went through some post on the forum, and it seems like they require the folder window to be active to do the search, is there a way to search for a specific .exe file and run it without requiring a window to be active? Thanks!

My inital idea looks something like this:

Code: Select all

; define a function that return a path to the file
FilePathFinder(file_name, extension, search_from_path) {
}

; then the function can be used like so:
VegasPath := FilePathFinder(vegas200, exe, "C:\")
Run, VegasPath
This code is intended so if I do move the file to another place, I wouldn't need to modify my autohotkey code every time which is super annoying. Any ideas would be greatly appreciated!

User avatar
boiler
Posts: 17126
Joined: 21 Dec 2014, 02:44

Re: Dynamic way to find a program and run it  Topic is solved

Post by boiler » 24 Apr 2024, 20:29

haomingchen1998 wrote: I've went through some post on the forum, and it seems like they require the folder window to be active to do the search, is there a way to search for a specific .exe file and run it without requiring a window to be active?
I don’t know what you saw that made you think a folder window had to be active. You don’t need any folder windows open at all. Just perform a recursive file loop search:

Code: Select all

loop, Files, C:\vegas200.exe, FR
{
	VegasPath := A_LoopFileFullPath
	break
}
Run, % """" VegasPath """"

haomingchen1998
Posts: 174
Joined: 20 Feb 2023, 16:37

Re: Dynamic way to find a program and run it

Post by haomingchen1998 » 24 Apr 2024, 20:52

boiler wrote:
24 Apr 2024, 20:29
haomingchen1998 wrote: I've went through some post on the forum, and it seems like they require the folder window to be active to do the search, is there a way to search for a specific .exe file and run it without requiring a window to be active?
I don’t know what you saw that made you think a folder window had to be active. You don’t need any folder windows open at all. Just perform a recursive file loop search:

Code: Select all

loop, Files, C:\vegas200.exe, FR
{
	VegasPath := A_LoopFileFullPath
	break
}
Run, % """" VegasPath """"
This makes so much more sense, thanks a lot!

Post Reply

Return to “Ask for Help (v1)”