[quake3-bugzilla] [Bug 4520] New: /sysexec, execute an external program

bugzilla-daemon at icculus.org bugzilla-daemon at icculus.org
Fri Jan 29 18:34:28 EST 2010


           Summary: /sysexec, execute an external program
           Product: ioquake3
           Version: SVN HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: Misc
        AssignedTo: zakk at icculus.org
        ReportedBy: arxeio at gmail.com
         QAContact: quake3-bugzilla at icculus.org

The reason I wanted it was to change winamp songs with a bind:P

e.g. this plugin http://membres.multimania.fr/clamp/


/bind x sysexec clamp /next <--------goes next winamp song

with clamp in the path or using its full path.

The way this works on Windows is with some acrobatics using CreateProcess() to
avoid the new program stealing focus (especially for changing songs with
CLamp). For non-Windows it assumes system() will be enough by letting the user
using some userland magic to avoid such stealing of focus. It is generally a
raw method - especially on non-WIN32 - that may need proper care on what is
being fed to it. e.g. Winamp (initial launching) or even ioq3 itself (a new
one) will steal focus from it by force even if they are instructed not to. This
can be considered 'normal'. On non-windows it may require a shell method that
exits right after execution since system() itself halts the program until exit.
Theoretically, even windows can be left requiring a userland program doing any
focusing/unfocusing business but it allowed some handholding. 

void Com_Sysexec_f (void) {
    int     num, i;
    char     cmd[1024];
    #ifdef WIN32 
    char errormsg[1024];
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) ); //up to here carbon copy microsoft's example
    si.dwFlags = STARTF_USESHOWWINDOW; //needed to use the next one
    si.wShowWindow = SW_SHOWNOACTIVATE; //needed to *not activate, i.e. not

    num = Cmd_Argc();
    if (num < 2) {
        Com_Printf ("sysexec [command and parameters] : run an external system
command/program with its parameters, it can be in the path or be entered in
full path\n");

    cmd[0] = 0; //required to start with a null string
    for (i = 1; i < num; i++) {
        strcat (cmd, Cmd_Argv(i));
        if (i != (num-1))
            strcat (cmd, " ");
    Com_Printf("Issuing external command: %s\n",cmd);
    #ifdef WIN32
    if(!CreateProcess( NULL,cmd,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi )) {
        Com_Printf("Issuing of %s failed, error: %s.\n",cmd, errormsg);
            if (GetLastError() == 2)
                Com_Printf("a command can be in the path or full path can be

//in an 'init':

Cmd_AddCommand( "sysexec", Com_Sysexec_f );

Configure bugmail: http://bugzilla.icculus.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the quake3-bugzilla mailing list