Reputation: 145
I'm trying to launch Spotify, if it's not running, by pressing the Play/Pause button on the keyboard.
I have this.
Media_Play_Pause::
Process, Exist, spotify.exe
if ErrorLevel
{
Send {Media_Play_Pause}
}
else
{
Run, Spotify
}
return
This works, but since my ahk is ran as admin, Spotify also runs as admin. Why is this bad? because elevated Spotify doesn't show the media control buttons in the taskbar preview, and it creates a new icon on the taskbar separate from the pinned Spotify icon.
Is there any way to run Spotify as normal user and not as admin?
Upvotes: 4
Views: 747
Reputation: 6489
Get Shell to run the program for you.
Here's one implementation, and here's an other.
Don't have any opinions for which would be better, both seem to work for me.
Usage of either of the functions in your script would be:
Media_Play_Pause::
Process, Exist, spotify.exe
if (ErrorLevel)
SendInput, {Media_Play_Pause}
else
ShellRun("Spotify") ; I don't have Spofify, so I didn't try using this short name for it. If it doesn't work, try to specify the full path of the exe
return
; copy paste the function here
Upvotes: 3
Reputation: 2344
You are looking for RunAs
For example:
RunAs, UserName, UserPassword
Run, Spotify
Should run the Spotify as the User you have specified, which you could specify to be your own user profile [you need to replace UserName and UserPassword with the correct credentials in order for this to work]
If you are unsure of what your user name is, you can list all of them by using the net user
command in command prompt.
Here is what your code would look like with this change:
Media_Play_Pause::
Process, Exist, spotify.exe
if ErrorLevel
{
Send {Media_Play_Pause}
}
else
{
RunAs, UserName, UserPassword ;Change these to be the correct values!
Run, Spotify
}
return
Upvotes: 0