WinExist Doesn't Work For Different Drive Letters

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zhotkey
Posts: 14
Joined: 21 Jun 2017, 08:22

WinExist Doesn't Work For Different Drive Letters

22 Sep 2020, 18:00

Hello,

I have a script that brings up a folder on my MP3 SD Drive but it opens multiple windows instead of an existing window if that window is open. It looks like WinExist doesn't recognize the window. If I run Window Spy it shows:

Code: Select all

  M:\Podcastsd
  ahk_class CabinetWClass
  ahk_exe explorer.exe
  ahk_pid 21500
This logic works as expected for the C: drive but not my M: drive?

Code: Select all

#^!m::
SetTitleMatchMode,3
IfWinExist, "M:\Podcastsd"
{
WinActivate "M:\Podcastsd"
}
else
{
Run, EXPLORER.EXE /e`, "M:\Podcastsd"
}
return
[Mod edit: [code][/code] tags added.]
User avatar
boiler
Posts: 16972
Joined: 21 Dec 2014, 02:44

Re: WinExist Doesn't Work For Different Drive Letters

22 Sep 2020, 18:16

These lines should not include quotation marks:

Code: Select all

IfWinExist, "M:\Podcastsd"
    WinActivate "M:\Podcastsd"
They use command/legacy syntax. Alternatively, you could force expression syntax:

Code: Select all

IfWinExist, % "M:\Podcastsd"
    WinActivate, %  "M:\Podcastsd"
See the documentation on expression vs. legacy syntax.
Last edited by boiler on 22 Sep 2020, 18:26, edited 1 time in total.
User avatar
JoeWinograd
Posts: 2200
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: WinExist Doesn't Work For Different Drive Letters

22 Sep 2020, 18:26

zhotkey wrote:This logic works as expected for the C: drive
I'm certain that is not true. It will not work (whether C: drive or M: drive or any drive) with the quote marks in there. Regards, Joe
zhotkey
Posts: 14
Joined: 21 Jun 2017, 08:22

Re: WinExist Doesn't Work For Different Drive Letters

22 Sep 2020, 21:12

You are correct, I only had the double quotes on the run line, thanks again!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Billykid, haomingchen1998, matt101, Oblomov228 and 256 guests