Determine programmatically if an AIR app was launched from the command line? - apache-flex

Is it possible to determine programmatically whether an AIR app was launched from the command line or via double-click on the application icon?
I want to be able to do something like:
`if (e.launchedFromCLI) { foo(); }`

Try listening to NativeApplication INVOKE event, it is the only place I know where you can find such info.
Seems that you can not distinguish CMD launch from icon launch - unless you pass some arguments in CMD.
http://help.adobe.com/en_US/AIR/1.5/jslr/flash/desktop/NativeApplication.html#event:invoke

Related

Is there any console tool to save some commands as bookmarks or buttons?

I work often with ssh and command line scripts. I would like not to type the name of the command with arguments again and again and also to call my scripts by clicking a button.
Is there any console application that does that?
My guess is that I should fork a console tool (like konsole) and then add buttons that can be associated with commands I want to use often.
Then the better option is creating a desktop launcher , like the following as target.
Assuming you are having a gnome desktop.
Execute the following command,
gnome-desktop-item-edit --create-new ~/Desktop
This will launch a window ,which will prompt for a command name , command ,and comments.
Fill it as per your needs,
Eg: name : MyCommand_to_start_apache
command : httpd -f /my/custom/httpd.conf
That's it , if you want more fun give a try for gnome-panel or gnome-tweak-tool.
Another great tool is AutoKey

How to call an app that expects stdin input from QtGui?

I'm using Ubuntu and Qt Creator 4
I have a .cpp program in the executable form (say abc.out) that I wish to run when I press a button. It contains a number of cin and cout, so I want it to run on a "terminal" (on Ubuntu) so that I am able to input and output values to it. How can I do that?
I've tried system() and
also,
QProcess p1;
p1.start(./abc.out);
Using QProcess, my executable runs but stops at the first cout. It runs on the application output screen in Qt Creator and not on terminal.
For example:
I see on application output:
enter name:
When I type the value and press enter here, it doesn't accept the value, but moves to the next line and allows me to type further.
I want to run this abc.out file on the terminal. Any ideas would be really helpful.
Do you mean Qt Creator 2.4? In any case, on the Projects tab, you should find the Run settings section and from there you can find a "Run in terminal" checkbox. You could also use a Custom Executable option and type there: gnome-terminal --command ./abc.out The exact details can vary a bit as I'm using Qt Creator 2.5.
This should work when launching from Qt Creator, but when you use your app outside the IDE, you need to launch it from terminal and not by double clicking the executable. To fix this, I can think of two ways:
Launch a terminal window from QtGui (something like QProcess::execute("gnome-terminal --command ./abc.out"); ), though the problem is different systems have different terminal names.
Provide a Qt input/text box yourself as part of your GUI which then forwards the user input to the executable (something like myqprocess.write(input_asked_from_user_by_QtGui); ). Here you probably need to know what information to ask the user beforehand. If you want to display the cout output of the started process, you can use the read method and friends of the QProcess.
From your question I assume that you are writing an application that launches other applications using QProcess. Thats fine, but if your subprocess is waiting for data from the standard input it will wait forever since you did not provide any data. The stdin of your parent application cannot be automatically guided to the subprocess. Imagine you are starting two processes from your main app. To which child process should the input go?
If you want to communicate with child processes, you must use the QIODevice methods of QProcess and send/read data from/to that application.
The only sensible solution is to launch the target application in a terminal. Whether your own code provides the terminal window or you reuse an existing terminal application is up to you.

Pydev - startup

Maybe I got simple questions so I googled it but I can't find answer.
I am using Pydev/Eclipse and I want to run the script within Console.
First I want to modify the startup of the session - it means some modules are loaded during start (math, numpy, scipy, etc...).
Where/how can I modify Pydev Console startup?
Secondly, I execute the script using righ-click on script file and "Run as -> Python Run" then it's executed within console and terminated. So I want to stay within Console and to be interactive and not be terminated.
How can I get such feature?
Thank you!
Best regards,
Peter
The startup configuration can be found in the PyDev preferences menu. The preferences can be found in the upper menubar under 'Window'.
Window -> Preferences -> PyDev -> Interactive Console
There you will find a big text input field with a label 'Initial interpreter commands'. Often it is allready in use and imports sys only to print the name and version number of the starting console.
The only solution I am aware of for staying connected with your script is to set a breakpoint at the end and start your script in debug mode. But maybe there is another way. To do so just double click at the left corner of the editor window with your script opened. A green dot will appear marking a breakpoint. Now right click an choose 'Debug As'. Your script will run till the line is reached where you have set the breakpoint.
Hope I could help.
I think that what you want is the interactive console. See: http://pydev.org/manual_adv_interactive_console.html
You can configure the initial commands in the preferences page.

Consoles and Tabs

When I start the tomcat server from console using the startup.bat script, a new command window opens which is filled with java logging statements.
I use Console2 which leverages tabs for each open console window. Is it possible to let the java system create a new tab within console2 instead of just opening a new command window?
This has nothing to do with java, its merely down to the way the catalina.bat is called from startup.bat
catalina.bat can be called with either a "start" argument or a "run" argument.
run Start Catalina in the current window
start Start Catalina in a separate window
So open startup.bat, scroll to the bottom you should see
"%EXECUTABLE%" start %CMD_LINE_ARGS%
change that to
"%EXECUTABLE%" run %CMD_LINE_ARGS%
exit
I add an exit after to close the calling window.
Unless Console2 hooks any APIs that create console windows – no. And that's also highly unlikely that they do or even can. Console2 does nothing more than hook up input and output of console windows. What the programs in those do is beyond what it's interested in.

How to launch qt application with the command window in minimized state, without any flicker?

I am working on VS2005 sp2, with qt3.3.7. I have set the linkers>system>subsystem to Console (/SUBSYSTEM:CONSOLE) as I need the command window to check runtime status of my project at runtime.
I want to launch my application with the command window minimized. The problem is, whenever my application launches, the command window comes in maximize state.
If I minimize this window using :
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_MINIMIZE );
still I get a flicker, ie for a split second the command window opens and then minimizes.
How can I launch my qt application with the command window in minimized state, without any flicker?
The only thing I can think of is launching your own console process using CreateProcess() with startupInfo.wShowWindow=SW_SHOWMINIMIZED, and startupInfo.dwFlags |= STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; setting startupInfo.hStdOutput to a handle you can use for output. I've tried launching cmd.exe like this, and while I can get it to start minimized, I haven't managed to write to it. I don't have any more time to play with it tonight, if you manage it I'd like to see the solution!

Resources