Author Topic: why does the console window from shell() not close until the macro has finished?  (Read 6293 times)

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0

Does anyone know why the console window from shell() does not close until the entire macro has finished?
It's not really a problem, but it may confuse the users of the macro.


thanks

Graeme

  • Senior Community Member
  • Posts: 2425
  • Hero Points: 322
Not exactly sure what you're doing but this is how I used the shell cmd - I recall I had to experiment a little.  Here I'm firing up a .exe that uses a Win API call to "open" an item (folder, file, URL etc).  Dunno if this helps.

Code: [Select]
static void open_external_item(_str item)
{
   _str cfg = strip(_config_path(),'t',FILESEP);
   _str file = strip(item,'t',FILESEP);

   // 'Q' option is needed to avoid command shell window in Win XP
   // To run a batch file instead of .exe, the 'Q' option must not be used
   //shell('"' :+ _config_path() :+ 'gp1.bat" ' :+
     //          '"' p_active_form.FilenameEditbox.p_text '" ' :+ '"'_config_path() '"', 'PA');
   shell('"' :+ _config_path() :+ 'listman_open_external.exe" ' :+
               '"' file '" ' :+ '"' cfg '"', 'QPA');

}

Graeme

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Not exactly sure what you're doing but this is how I used the shell cmd - I recall I had to experiment a little.  Here I'm firing up a .exe that uses a Win API call to "open" an item (folder, file, URL etc).  Dunno if this helps.

I'm basically invoking a python script using    rc = shell(commandStr, "PW", "cmd");

Even after I press a key, to close the window, the console window is visible until the Slick Macro finishes executing. Not a serious problem, but it may bother the end users. At the point I press enter, the Python script has already finished executing.


Kohei

  • Senior Community Member
  • Posts: 192
  • Hero Points: 25
What interpreter exe are you invoking to run your python script?  I remember, on Windows (sorry I'm exclusively on Linux these days), there are two python interpreters - python.exe and pythonw.exe.  The former always creates a console window when a script runs, while the latter does not create one.  Do you happen to be calling python.exe to run your script?

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
What interpreter exe are you invoking to run your python script?  I remember, on Windows (sorry I'm exclusively on Linux these days), there are two python interpreters - python.exe and pythonw.exe.  The former always creates a console window when a script runs, while the latter does not create one.  Do you happen to be calling python.exe to run your script?

python.exe

>>Do you happen to be calling python.exe to run your script?
yes

Changing the .py to pyw works without opening a console.