I'm sure this must be easy, it's just I can't figure it out - any pointers gratefully received:
So, this works as expected:
Runwait "Notepad.exe" ' "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt" '
and this also works as expected:
name := ' "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt" '
Runwait "Notepad.exe" Name
But this DOESN'T work (see code comments for more detail):
Name := FileSelect(,,, "*.txt") ;Selected file = "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt"
Name := " `' `"" . Name . "`" `'"
MsgBox(Name) ;name = ' "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt" '
Runwait "Notepad.exe" Name ;Popup err = "The filename, directory name, or volume label syntax is incorrect." Notepad starts but is empty.
I'd be really grateful for your thoughts.
FileSelect'd filename doesn't work as a param for RunWait
Re: FileSelect'd filename doesn't work as a param for RunWait
i dont understand what ure trying to do adding these quotes all over the place. u probably dont either
top case
works
middle case, same as top case
works
bottom case
womp, womp. get rid of these single-quote+spaces
Name := " `' `"" . Name . "`" `'" should have been Name := " `"" . Name . "`"" or Name := ' "' . Name . '"'
top case
Code: Select all
u write: "Notepad.exe" ' "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt" '
RunWait sees: Notepad.exe⎵"D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt"⎵
middle case, same as top case
Code: Select all
u write: "Notepad.exe" ' "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt" '
RunWait sees: Notepad.exe⎵"D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt"⎵
bottom case
Code: Select all
u write: "Notepad.exe" " `' `""D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt"`" `'"
RunWait sees: Notepad.exe⎵'⎵"D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt"⎵'
Name := " `' `"" . Name . "`" `'" should have been Name := " `"" . Name . "`"" or Name := ' "' . Name . '"'
Re: FileSelect'd filename doesn't work as a param for RunWait
Thanks for the reply.
Yous seem to suggest that
Runwait "Notepad.exe" "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt"
works. Did you try? If I run this, Notepad does not start and microsoft pops up the "you need a new app to open this notepad.exed link" (and yes, is does write it as "notepad.exed" - not sure what that means). So this didn't work.
So, this definitely works for me as expected (ie., the target file is opened in Notepad):
Runwait "Notepad.exe" ' "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt" '
V2 help for Run says "If a parameter contains spaces, it is safest to enclose it in double quotes (even though it may work without them in some cases)." As it didn't work when not surrounded by double quotes I addedd them. But, as explained above, this still doesn't work. Later in the same help section under Remarks it says if running via cmd.exe to enclose any part of the string that has spaces in single quote marks with spaces, as shown in my top case. I have spaces, and tried this without expectation, but it worked! I could find no other combination that makes this work. So, I assumed that this combination of single-quotes, double-quotes and spaces in the parameter string was what I needed in cases 2 and 3.
Update: Inspired by your suggestions, I've just found that this combo also works:
Runwait "Notepad.exe" ' D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt '
And following on from the Update above, it turns out this also works:
Name := " `'" . Name . "`'"
Very many thanks for unlocking what I needed to do here - have been going round and round with this one.
Yous seem to suggest that
Runwait "Notepad.exe" "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt"
works. Did you try? If I run this, Notepad does not start and microsoft pops up the "you need a new app to open this notepad.exed link" (and yes, is does write it as "notepad.exed" - not sure what that means). So this didn't work.
So, this definitely works for me as expected (ie., the target file is opened in Notepad):
Runwait "Notepad.exe" ' "D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt" '
V2 help for Run says "If a parameter contains spaces, it is safest to enclose it in double quotes (even though it may work without them in some cases)." As it didn't work when not surrounded by double quotes I addedd them. But, as explained above, this still doesn't work. Later in the same help section under Remarks it says if running via cmd.exe to enclose any part of the string that has spaces in single quote marks with spaces, as shown in my top case. I have spaces, and tried this without expectation, but it worked! I could find no other combination that makes this work. So, I assumed that this combination of single-quotes, double-quotes and spaces in the parameter string was what I needed in cases 2 and 3.
Update: Inspired by your suggestions, I've just found that this combo also works:
Runwait "Notepad.exe" ' D:\AutoHotKey\My AHK projects\RunXRef+\XRef+ExcludedWordsList.txt '
No, not quite. It introduces the Run parameter as a var, as a step towards the 3rd case (which is what I'm trying to achieve). The net effect should be the same, and indeed it is!middle case, same as top case
This doesn't work for me. Instead throws an AUTOHOTKEY error - "Failed attempt to launch and program or document:"should have been Name := " `"" . Name . "`""
Ah, now this works - Though I must confess I don't know why - I thought we needed double quotes for text and to escape literal chars within those double quotes! I need to read around some more perhaps.should have been Name := ' "' . Name . '"'
And following on from the Update above, it turns out this also works:
Name := " `'" . Name . "`'"
Very many thanks for unlocking what I needed to do here - have been going round and round with this one.