General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Help with exec statement in Macro Language
Posted by: JamesD
Date: September 04, 2007 09:04PM

Is there any documentation on how to use the exec statement in the Macro Language? I have used it to call WSscript but that is a special case and does not seem to work for other programs. I need to call "sounder.exe" which is in my user macro folder and pass it one argument which is the name of a wave file. I can obtain the path info and put into a variable, but for now I just need to get sounder.exe to start.

The following line does not work.
exec("C:\\Program Files\\k-meleon\\Profiles\\default\\ae3wngxv.slt\\macros\\sounder.exe \""C:\\Program Files\\k-meleon\\Profiles\\default\\ae3wngxv.slt\\macros\\chimes.wav"\"");

The command line entry looks like this. > sounder.exe chimes.wav

Options: ReplyQuote
Re: Help with exec statement in Macro Language
Posted by: JamesD
Date: September 04, 2007 10:01PM

More information -- This statement works.

exec("C:\\Program Files\\k-meleon\\Profiles\\default\\ae3wngxv.slt\\macros\\sounder.exe");

Sounder says only relative paths supported. What is a relative path? What is the working directory when KM is running?

Options: ReplyQuote
Re: Help with exec statement in Macro Language
Posted by: kko
Date: September 04, 2007 10:56PM

Quote
JamesD
The following line does not work.
exec("C:\\Program Files\\k-meleon\\Profiles\\default\\ae3wngxv.slt\\macros\\sounder.exe \""C:\\Program Files\\k-meleon\\Profiles\\default\\ae3wngxv.slt\\macros\\chimes.wav"\"");

This can indeed not work. You made several mistakes with the quotes.
1) The argument for the exec statement goes into double quotes i.e. it begins with " and ends with ".
2) Any part of the command line (i.e. the program's path and any parameters) that does or can contain white spaces should go into additional double quotes (\", quotes inside quotes have to be escaped). But, in case of doubt, this depends on the program you want to execute.

These rules applied:

exec("\"C:\\Program Files\\k-meleon\\Profiles\\default\\ae3wngxv.slt\\macros\\sounder.exe\" \"C:\\Program Files\\k-meleon\\Profiles\\default\\ae3wngxv.slt\\macros\\chimes.wav\"");

To locate the user macro folder we've the getfolder() method:

exec("\"".getfolder(UserMacroFolder)."\\sounder.exe\" \"".getfolder(UserMacroFolder)."\\chimes.wav\"");


Quote
JamesD
Sounder says only relative paths supported. What is a relative path? What is the working directory when KM is running?

A relative path is taken relative to the current (or working) directory. When nothing else is specified, the working directory of an application is the directory that contains the application's executable. So, the working directory of sounder.exe should be the directory where sounder.exe is located.

When chimes.wav is located in the same directory as sounder.exe, the path of chimes.wav relative to sounder.exe is chimes.wav:

exec("\"".getfolder(UserMacroFolder)."\\sounder.exe\" chimes.wav");

(I don't want to confuse you with parent and subdirectories winking smiley

Options: ReplyQuote
Re: Help with exec statement in Macro Language
Posted by: JamesD
Date: September 04, 2007 11:32PM

@ kko

Many thanks, It seems so easy when you do it, but I get confused about the " and the \" when together. Your statement works great. I can now have chimes when the onload happens. I am still looking at code to see if there is anything to key from when a download completes. Not everything is reported to the Macro Language.

exec("\"".getfolder(UserMacroFolder)."\\sounder.exe\" chimes.wav");

Again, thank you for your help.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.