Welcome to %s forums

BrainModular Users Forum

Login Register

Deep Scripts...

Tell us what you'd like Usine to do
Post Reply
Vincent

Unread post by Vincent » 08 Jun 2007, 05:31

Hi.

Since I do now everything with only controllers and the keyboard, and since Usine is the central system of all my audio, I'm thinking about a carzy stuff... :
Making scripts that start or close other standalone apps (like Reason).
Is it possible?
If yes, could you tell me how?

Thanks!

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 08 Jun 2007, 06:17

Hi,

I've had some similar ideas, but I'm quite sure it's not possible as of now.

To be more specific, I was thinking that maybe a script procedure or a module to call OS commands could be useful sometimes.
Bjørn S

Vincent

Unread post by Vincent » 08 Jun 2007, 14:22

Maybe Usine has no access to the shell. But that would be a serious feature.

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 10 Jun 2007, 11:21

hello,
Normally should be easy to implement.
I'll take a look.

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 10 Jun 2007, 20:11

Hey, great, Olivier! Really great!

What kind of OS commands were you talking about, Bjørn?
vincent michel
composer & novelist

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 10 Jun 2007, 20:49

None in particular - just access to the shell, and then it shouldn't be a big problem to create a CMD or BAT file to do what you want if you need to run several commands after each other. Something like the Start/Run option in Windows.
Bjørn S

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 11 Jun 2007, 16:11

bsork wrote:it shouldn't be a big problem to create a CMD or BAT file to do what you want if you need to run several commands after each other.
Exactly. That was my idea too. It's great if Olivier can do that.
vincent michel
composer & novelist

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 11 Jun 2007, 18:16

done, you can enter for example

"notepad.exe"
"C:Program filesSteinbergNuendoNuendo.exe"
"D:cmdlist.bat"

or anything....
next version

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 11 Jun 2007, 20:58

Just wondering...
Will there be something impossible for Usine and Senso?
vincent michel
composer & novelist

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 11 Jun 2007, 22:06

Great! Now I only have to find out how to kill processes so I can replace a Reason-file with another.

...and no, it seems that ""impossible" isn't in Olivier's vocabulary...
Bjørn S

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 11 Jun 2007, 22:46

You can't imagine how it's simple to create a shell command in Usine source code.
Almost, just add a single line in a module template like
winExec(string);
too simple, less that 5 minutes. It's longer to update the manual...
But i'm not sure it will work for your purpose: can we kill a process with a simple shell command?
Let me know.

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 11 Jun 2007, 23:17

senso wrote:It's longer to update the manual...
Yeah. I think that, since you implement all what we're dreaming about, we should help you with the manual. But you're too fast. That's the reason why we do nothing!
vincent michel
composer & novelist

stanlea
Member
Posts: 94
Location: Bordeaux
Contact:

Unread post by stanlea » 13 Jun 2007, 20:08

"format c:" ?
You know my name (look up the number)

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 13 Jun 2007, 20:12

yes if you want!
Usine is so powerful!

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 13 Jun 2007, 21:47

I didn't really think that implementing an OS call was hard - I was thinking more of all the other features that you have added in the short time I've used Usine!

Regarding the kill process thing, one would think that it was easy to find a shell command that did the same as End process in the task manager. But no... The closest thing I've found so far on the net involves various Unix-like shells and commands for Windows. Windows is really lacking in this department - especially if you once used to be quite good in Unix scripts...

When (if...) I've found out how to do this, I'll get back to you. I don't think I will mess to much with this in near future, though.
Bjørn S

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 13 Jun 2007, 21:55

I think it will be hard to find. but we never know, windows is so mysterious sometime.
Anyway, it's possible to create a kill process module in usine.

More interesting, try to get an event when you close the process yourself.

like:
1) open notepad
2) if notepad is closed by user (you have finished to edit) then do something...

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 13 Jun 2007, 23:58

The kill process exists and can be used for sure. I use it trough Visual Basic in different manners. Basically, I create an application object and keep it in an object variable. When I want to kill the process, I set the variable to NOTHING. I even can create instances to capture events. The question is "How to do that when using another language?".
I think anyway it could be a good idea to keep a variable and call it each time one wants to do something (eg: exit). I don't think that events capture could be done another way. Just find the right library... and how to use it.
I prefer my job, can I say it?
vincent michel
composer & novelist

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 14 Jun 2007, 00:04

stanlea wrote:"format c:" ?
Did you know that since a few weeks, hackers use Usine to destroy US Army data bases? It's all quantized and randomly replaced by porn samples.
vincent michel
composer & novelist

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 14 Jun 2007, 00:34

Hello guys, and thanks for the input. I just did a search that maybe was too obvious to think of, namely take a look at exe-files in the Windows directory. And lo and behold(!) - there they where: Windows' answer to Unix' ps and kill commands: tasklist.exe and taskkill.exe.
Bjørn S

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 14 Jun 2007, 08:01

how to use those commands?

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 14 Jun 2007, 08:36

I'll put in an example-file when I've created it. I'm not very good (=bad) at writing CMD-scripts; compared to Unix the available commands are fewer and the syntax is sooooooo clumsy.
Bjørn S

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 14 Jun 2007, 16:39

Hello
some French help on how to make a killing command:

Code: Select all

TASKKILL [/S système] [/U utilisateur [/P mot_de_passe]]]
         { [/FI filtre] [/PID ID_processus | /IM image] } [/F] [/T]

Description :
    Cet outil de ligne de commande peut être utilisé pour mettre fin à une ou pl
usieurs tâches ou processus.
    Les processus peuvent être supprimés par l'id de processus ou le nom de l'im
age.

Liste des paramètres :
   /S    système         Spécifie le système distant auquel se connecter.

    /U    [domaine]utilisateur  Spécifie le contexte utilisateur sous lequel
                           la commande doit s'exécuter.

   /P      [mot_de_passe]    Spécifie le mot de passe pour le
                           contexte utilisateur donné. Il est demandé s'il est o
mis de la ligne de commande.

    /F                           Force la fin d'exécution
                                    du ou des processus.

   /FI     filtre          Affiche un ensemble de tâches qui correspond
                           au critère spécifié par le filtre.

    /PID     ID_processus       Spécifie la valeur PID du processus qui
                                    doit être arrêté.

    /IM     image          Spécifie le nom d'image du processus
                                    qui doit être arrêté. Le caractère générique
 '*'
                                    permet de spécifier tous les noms d'images.

    /T                  Terminer l'arborescence : arrête le processus spécifié
                           et tous les processus enfant qu'il a démarrés.

    /?                    Affiche cet écran d'aide.


Filtres :
    Nom du filtre   Opérateurs valides          Valeurs valides
    -------------   ------------------          -------------------
    STATUS          eq, ne                      RUNNING | NOT RESPONDING
    IMAGENAME       eq, ne                      Nom d'image
    PID             eq, ne, gt, lt, ge, le      Valeur PID
    SESSION         eq, ne, gt, lt, ge, le      Numéro de session
    CPUTIME         eq, ne, gt, lt, ge, le      Heure valide au format
                                                hh:mm:ss.
                                                hh - heures,
                                                mm - minutes, ss - secondes
    MEMUSAGE        eq, ne, gt, lt, ge, le      Mémoire utilisée, en Ko
    USERNAME        eq, ne                      Nom d'utilisateur [domaine]util
isateur
                                                est le format utilisé
    MODULES         eq, ne                      Nom de DLL
    SERVICES        eq, ne                      Nom de service
    WINDOWTITLE     eq, ne                      Titre de la fenêtre

Remarque : le caractère générique '*' n'est accepté qu'avec les filtres.

Remarque : l'arrêt des processus distants sera toujours forcé,
      que l'option /F soit utilisée ou non.

Exemples :
    TASKKILL /S système /F /IM notepad.exe /T
    TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
    TASKKILL /F /IM notepad.exe /IM mspaint.exe
    TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne sans*"
    TASKKILL /F /FI "USERNAME eq AUTORITE NTSYSTEM" /IM notepad.exe
    TASKKILL /S système /U domaineutilisateur /FI "USERNAME ne NT*" /IM *
    TASKKILL /S système /U utilisateur /P mot_de_passe /FI "IMAGENAME eq note*"
vincent michel
composer & novelist

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 14 Jun 2007, 23:29

Hello, I've been trying to use taskkill in a CMD-file that first kills the existing Reason song file, and then opens a specified, new one. So far with no luck. Aaarrrggghhh! Killing the existing process goes ok, but then the new file won't start. While if Reason isn't running, there's of course an error message from taskkill, but the new file opens.

I don't think I will dig too deep into this matter right now, even though I've taken a look at VBScript (even stumbled across an example of using NOTHING). I guess a quick solution would be to run two different OS calls, possibly with a delay between them.
Bjørn S

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 15 Jun 2007, 00:56

Hey Bjørn, you don't loose your time!
bsork wrote:While if Reason isn't running, there's of course an error message from taskkill, but the new file opens.
This is the main headaches with "multi-task-thread" stuff... but in fact, that's good news!
While you're testing cmd files, did you consider to check first with the TASKLIST.EXE if Reason is still running or not? I've noticed that it needs some "graphical time" (don't know how to call that) before being able to receive any request or command.
I don't know how to write those *.com files and I cannot help you! but the algorithm could be something like:

Code: Select all

if Reason.exe is present in the tasklist then kill Reason.exe //you've said that it works
wait until reason is not present anymore in the tasklist //in a loop checking this condition
start reason with a new song //you've also said that it works!
I don't like those kind of "waiting loops" since they use a lot of CPU just for waiting something to be done, but while closing Reason files, maybe don't you really need CPU for audio processing... not sure, of course...
Another trick: when launching Reason with a cmd-file, it is possible to do that in the reduced window or, much more quicker, in a hidden one. Perhaps don't you need to see Reason GUI while playing in Usine?
What do you think?
BTW, while debugging this, don't forget to check your Task Manager!
vincent michel
composer & novelist

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 15 Jun 2007, 01:06

BTW(2): it could be useful to write a cmd-file that "un-hides" a Reason hidden window...
vincent michel
composer & novelist

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 15 Jun 2007, 09:28

Hello Vincent,

thanks for the tips. I'm sure you're on to something with the "graphical time" thing. Something like that is the only explanation I can find for the new file not starting. I haven't tried making a loop with tasklist to check whether Reason is running or not - I might try that one out. For that matter, if a little delay is all that's needed, I could do with some silly dummy command that takes a second or so, like DIR.

The way I had thought about using this, CPU doesn't really matter much. I want to start a new Reason file when for example a new workspace is loaded, so I don't have to mess around too much with the PC between songs - maybe even loading a wrong file. I wouldn't even dream about opening new Reason files in the middle of a song.

I suppose you mean minimized to a task bar button when you write hidden(?). I haven't tried that yet, but it's worth a go. If it's at all possible to change the size of a running program with CMD, I don't know.
Bjørn S

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 15 Jun 2007, 13:03

Hi Bjørn.
About the "graphical time", it can be very variable. It depends I think on what happens with the RAM. I think that a check with Taskslist would be more efficient. Sorry, I don't know how to write loops neither checking conditions there...
I really meant hidden. You cannot see if the application is running except in the "Process" tab of the Tasks Manager, and this is the only place to kill it if the cmd-file fails. There is no GUI this way and I think it's much more quicker and lighter. In the command window, type the command name (which one is it, BTW?) followed by a space and "HELP".
vincent michel
composer & novelist

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 15 Jun 2007, 13:51

Hi Vincent,
I can't say I know how to write such a loop, but I'm pretty sure I can find that out without too much hassle.

I didn't know that typical Windows applications could be started without the GUI, but in a way that's what happening when they're running minimized, so it makes sense. However, I can't say I've seen any reference to how that is done when searching through help of various kind.

What command name are you referring to? The involved programs in my tests are cmd.exe and Reason.exe.

As I write this, it struck me that a half-automated way of doing this could be the best: Assuming that I have Usine running, an empty, dummy Reason song, and another "real" song open, I could easily switch to the "real" song and close it with keynoard or mouse, then I load in the new workspace which will open the right new Reason song. I won't open the Reason files directly, but using shortcuts so they can be opened minimized. The reason for having an empty dummy song open, is that the Reason.exe process - as you know - will close down together with the last file. Really annoying habit!
Bjørn S

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 15 Jun 2007, 16:10

Well, Bjørn, it seems that to execute an application in the hidden mode, this parameter is a window parameter. I don't know how to use it in a batch. I'll check. I've downloaded powerbatch.

Keeping one instance of Reason while loading and closing songs in an other one, yes, may be faster if you use Reason in each workspace. I'll have to check on my side...
vincent michel
composer & novelist

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 16 Jun 2007, 12:49

Hi Bjørn,

It does not seem that the TASKLIST can be used to check if Reason is running; I mean, as a function returning any usable value.
Try the START cmd to execute Reason. In the cmd window, type "START /?". It seems to have more control on how you launch your application via the Batch.
There is a "WAIT" parameter that makes the Batch to wait until the application is closed (not tested). You could add a boolean variable in your system that is set to TRUE as long as the batch is waiting.
When this variable is TRUE, TASKKILL can kill the application, so the batch will pursue, set the variable to FALSE, and close itself.
Also, the START command could not be called as long as your variable is TRUE.
What do you think?
Not sure I'm clear... I have no time now to try those crazy stuffs, sorry.
vincent michel
composer & novelist

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 16 Jun 2007, 13:05

bsork wrote:I can't say I know how to write such a loop

Code: Select all

Command 1
Command 2
:HiBjorn
Command 3
Command 4
Command 5
If "%MySystVar%"=="TRUE" Goto HiBjorn
Command 6
Command 7
Where "%MySystVar%" is your system variable. Obviously, if none of the commands 3 to 5 changes this variable to FALSE, you'll have an endless loop. I'm sure you love endless loops!
Note that the labels are not case sensitive and only their 8 firsts characters are read.
vincent michel
composer & novelist


Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests