winexist can't detect %UserProfile% Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vkhu
Posts: 10
Joined: 04 Oct 2018, 00:40

winexist can't detect %UserProfile%

18 Apr 2022, 04:21

I have a script like so

Code: Select all

DetectHiddenWindows, On
DetectHiddenText, On
SetTitleMatchMode, 2

#If !WinExist("%UserProfile%\Dropbox\AutoHotkey Automation Scripts\Look Up Words.ahk")
F3::
Run %UserProfile%\Dropbox\AutoHotkey Automation Scripts\Look Up Words.ahk
Return
#If
Its job is to run in the background, and reload another script called "Look Up Words.ahk" when I press F3, if and only if the script isn't already running. Previously, I always spell out the entire path, such as "C:\Users\<my name>\Dropbox\AutoHotkey Automation Scripts\Look Up Words.ahk," since I've only ever used it on 1 computer, and the script work fine.

But now, I've moved computer, and my user name changed. To future-proof the script against future moves, I've decided to change all the hard path to variable path as such. After the change, the script no longer work!

Curiously enough, the "Run" command works fine. It managed to load out the correct script. It's only the "WinExist" command that's giving me trouble.

Is there a way to fix this? Or do I have to put up with using the hard path :(?
gregster
Posts: 9086
Joined: 30 Sep 2013, 06:48

Re: winexist can't detect %UserProfile%  Topic is solved

18 Apr 2022, 04:23

Functions require expression style syntax:

Code: Select all

#If !WinExist(UserProfile "\Dropbox\AutoHotkey Automation Scripts\Look Up Words.ahk")
vkhu
Posts: 10
Joined: 04 Oct 2018, 00:40

Re: winexist can't detect %UserProfile%

18 Apr 2022, 04:35

gregster wrote:
18 Apr 2022, 04:23
Functions require expression style syntax:

Code: Select all

#If !WinExist(UserProfile "\Dropbox\AutoHotkey Automation Scripts\Look Up Words.ahk")
TYSM!

Just for future reference, how was "Run" able to accept the "%UserProfile%\..." path directly without needing the change like "WinExist"?
gregster
Posts: 9086
Joined: 30 Sep 2013, 06:48

Re: winexist can't detect %UserProfile%

18 Apr 2022, 04:46

Run is a a command, not a function. (Functions are the ones with a parameter list in parentheses)
vkhu
Posts: 10
Joined: 04 Oct 2018, 00:40

Re: winexist can't detect %UserProfile%

18 Apr 2022, 04:55

Thank you for clearing that up!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 179 guests