%UserInput% only seems to work whenever it doesn't contain a double quote (").
Whenever %UserInput% contains a double quote ("), the PHP CLI script I'm calling through the AutoHotKey Run command ends up seeing the test input as separate arguments, because AutoHotKey just doesn't escape it.
The test input is:
test1 " test2
I have tried these, and 5 trillion other versions:
Run %ComSpec% /c "php "C:\a path\to my\test.php" "--query=%UserInput%" "--skip-multiples""
Run %ComSpec% /c "php "C:\a path\to my\test.php" --query="%UserInput%" "--skip-multiples""
Run %ComSpec% /c "php "C:\a path\to my\test.php" "--query="%UserInput%"" "--skip-multiples""
Run %ComSpec% /c "php "C:\a path\to my\test.php" --query=""%UserInput%"" "--skip-multiples""
Run %ComSpec% /c "php "C:\a path\to my\test.php" "--query=""%UserInput%""" "--skip-multiples""
Run %ComSpec% /c php "C:\a path\to my\test.php" --query=%UserInput% --skip-multiples
Run %ComSpec% /c php "C:\a path\to my\test.php" "--query=%UserInput%" --skip-multiples
Absolutely nothing works. Running this in cmd.exe (not involving AutoHotKey in any way) works, so it's not a problem on my end:
%ComSpec% /c "php "C:\a path\to my\test.php" "--query=test \" test" "--skip-multiples""
Notice how I have manually added a \ before the " inside the query string? Yeah... AutoHotKey doesn't do that. I've read the manual for countless hours now and it doesn't say a word about this -- just "use double double quotes", which clearly doesn't work.
All of the AutoHotKey Run commands above result in the PHP CLI script seeing "test1" and "test2" as separate arguments due to the double quote character in the middle. It's supposed to receive it as a single string.
Again, I can run the above cmd.exe command and it works, but when I run the exact same (or countless variations) through AutoHotKey, it breaks. Because AHK doesn't do the escaping. How do I make it do so?
(If the user input happens to not contain any " character, it works.)
(If anyone is confused by %ComSpec%, that just means cmd.exe.)