I am having a weird problem with AutoHotkey that I've never had before. I'm using AutoHotkey v2, and am trying to use a simple hotkey to launch the SCSS "watch" function while working on a website. I installed the SCSS/SASS gem using Ruby on Windows 10, and it is supposed to install to the PATH. It appears to have done that, because if I manually open a CMD or CMDer window and type "SCSS -v" it outputs the version just fine. Same goes with running commands using SCSS.
However, launching command prompt using AutoHotkey isn't detecting that SCSS path at all.
Code: Select all
Run A_ComSpec ' /k "scss --watch C:\Users\User\Desktop\coding\website\public\scss/:C:\Users\User\Desktop\coding\website\public\css/" '
Is there some difference between the CMD that AutoHotkey runs via A_ComSpec? I even tried having it first change directories to "C:\Windows\System32" which is what the normal CMD defaults to when it first opens, but it didn't make a difference.
Hopefully I explained this okay, feel free to ask for clarification if needed, and I'll do my best to answer. I've never had this problem before, I even tried reinstalling Ruby and SCSS but it didn't make a difference.
--Edit--
I should mention that AutoHotkey works fine with other environment variables, such as "light-server" which was installed via NPM. It seems to be some weird problem with Ruby and gems or something, but I could be wrong.
--Edit #2--
It seems to be a problem with command prompt being launched from any other program, and not from Explorer directly. I launched CMD from Everything (https://www.voidtools.com/) and it also wasn't able to detect SCSS. But if I launch CMD directly from Explorer (either navigating to C:\Windows\System32 or by searching in the start menu) it works just fine. If anyone knows a workaround for that, please let me know! However, this doesn't seem to be a problem with AutoHotkey specifically.
--Edit #3, basically solved--
So I ended up "fixing" this by having AutoHotkey set the temporary environment variable, then running the same code as before. Here is the final code:
Code: Select all
#If WinActive("ahk_exe sublime_text.exe")
XButton2::
EnvSet("PATH","C:\_ruby\bin")
Run A_ComSpec ' /k "scss --watch C:\Users\User\Desktop\coding\website\public\scss/:C:\Users\User\Desktop\coding\website\public\css/"'
Return