We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I cant figure out what changed... I had this working! I basically have a processing game that is compiled (.exe) and I use a GUI button to launch it from within a second Processing sketch.... I made a minor change of some images in the data folder, recompiled it and now I cant get it to launch through the sketch...
I'm at 1700 lines of code so in order to make this easier I took the pertinent code from sketch 1 and instead of the game, I am just trying to launch a compiled version of the processing Alpha example.... As with my sketch, it launches if I run the Alpha.exe file directly, but will not launch from within my sketch.... can someone please help? I was literally finished today just had to make one tiny little change and now I'm dead in the water again.... I tried running in administrator modes on each executable, I tried adjusting the permissions to full access, I tried calling the 32 bit version from the 64 bit version and vice versa.... nothing will launch it.... the part that launches bala.exe is just a text to speech program... I am only putting it there because it shows that other non processing apps do run using the launch command....
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.event.InputEvent;
import java.awt.Font;
import java.awt.datatransfer.*;
import java.awt.Toolkit;
import g4p_controls.*;
import ddf.minim.*;
Process pKeyboard;
String sentense;
void setup()
{
size(600, 600);
// Sends words to text to speech software and speaks them through the pc speaker
sentense="practice game starting";
String[] params = {
"C:/bala/bala.exe", "-t", sentense
};
launch(params);
// Sends words to text to speech software and speaks them through the pc speaker
pKeyboard =
launch(new String[] {
"C:/ALI_V3/Alphamask/application.windows32/Alphamask.exe"
}
);
}
void draw() {
}
Answers
I am starting to think that there might be a bug in Processing 3... I have earlier versions of my game that were compiled using processing 2... they run when I use the launch command from within a different sketch... the ones that I did minor mods to and recompiled will not launch from within another sketch.... Does this warrant a bug report?
Are you sure that the file names, folder names etc are correct?
Under linux FC, I replaced line 20 with
exec("/export/home/RUNNING_IN_LINUX//PimgDEMO/application.linux64/PimgDEMO");
and it worked. I made sure the -x file flag was one which it is when a file is exported from the Processing IDE.
Kf
Thanks I will try it... I am not a Linux guy so just have a question about where the files to the ping Demo are kept in relation to the main sketch.... is it a full file path? Like in Windows c:/folder/folder/file.exercise? So they can live anywhere?
Not sure what file you are referring to (ping demo). I believe the documentation recommends using the full path.
Kf
Thanks..ping demo was in you path.... I thought you used a test program called that :)
pimgDemo => PImage demo... yes, that is an executable in linux generated by exporting a Processing pde with the same name. Sorry about that, I completely missed your question there. In Linux, exec files don't need to end with the .exe extension.
Kf
It didn't work... got a "could not open...." error This is the sketch I ran
THIS WORKS.... when I can get the file to my compiled sketch then it fails... yet if I navigate to the sketch and run it directly it works fine
I think processing is doing something in the compiling that prevents it from running....
When you got it to work did you compile it with windows3?
Maybe they have a bug that doesn't like windows10 security....
Even trying to run it straight from the console Gives me an error saying it is not recognized as an operable program.... yet it works by double clicking on it....I think it's a bug in the compiler....
I couldn't make it work in Win10. Doing it this way worked:
Kf
That's what I always did when I needed to use launch(), however, that was only in P2 that I needed to do that, P3 wasn't needing it as far as I remember.
It was easy to get to run the executable in Linux. Windows was not. As the PO mention, it could be related to security feature, like some sort of permission. So no idea why it wouldn't work. Having a glimpse to the documentation was fruitless. Using a batch file does the trick and it could be enough for now to answer the question, pending PO's satisfaction.
Kf
Though if it is a security problem, it kind of means that the security is easy to bypass.
That worked! At first it didnt, but just had to change the path to cd C:/ALI_V3/iPILOT_GAMEV3_FINAL/application.windows64 the flipping the slashes and putting one slash up front instead of two did it!!!
Thanks so much for sharing your solution, @fxmech
It is kfrajer's solution, but I'm glad he posted it... I was dead in the water without it!!!
kfrajer, is there a chance your technique could somehow also work for closing the windows onscreen keyboard? I have a second question up on the forum because in Windows 10 the OSK will no longer close using just the taskill command...
launch( new String[] { "taskkill", "/IM", "osk.exe", "/T", "/F" } );
If you know a work around please, please, please share it with me... haven't gotten any replies on this question on the other thread
It seems you need to have admin privileges to run taskkill. From the following site: http://superuser.com/questions/109010/kill-a-process-which-says-access-denied
I tried
wmic process where name='osk.exe' delete
using the .bat file trick in Processing and it worked. Please link your other post to this post so for moderators to close it.Kf
It will work only if the program is run with admin privileges or atleast run by an admin.
@Lord_of_the_Galaxy Are you referring to taskkill? I usually don't mess with security settings in Windows. It would make sense to require privileges. What I don't get is why I am able to run those commands in the command prompt with no issues but when done in processing within a batch file, it doesn't work. It seems like windows blocks commands issued from other programs. However the second trick using wmic worked for me without the need of changing anything in my system regarding security. I would like to say I am the admin of my own machine but Not sure if Windows gives me full admin privileges automatically or if I have to add more privileges... this is the impression I got when reading on the web about the taskkill command.
Kf
Windows OSes for a long time, I guess since Vista, attempts to protect the Administration account by blocking some potential actions, even based from where the action was solicited. >-)
In Unix OSes, the root account can simply do anything. ;;)
If that wmic works even in non-admin account then it may be a security flaw, and a huge one at that, because a hacker may be able to stop the antivirus software that way. Or maybe it only works of windowed tasks.
kfrajer, you are a genius! It worked great! Thank you! didnt even need to run as admin!!!
Here is how I did it in Visual Studio to make a Windows application taking the idea from above. Now I have a launcher app to launch any number of exported Processing sketches. I needed this for live performances to make things easier. It's way easier to make buttons in VS than P3. Processing really should have a built-in way to do this. You can make it so the paths aren't hard-coded but entered in a textbox on browsing with the file explorer dialog then saved on exit so the last entered are reloaded on startup.