PDA

View Full Version : Program Help




iWill
Feb 11, 2007, 04:28 PM
Hey guys now usually i hate it when people in this forum come and basically ask someone else to code for them...but i really need some information here that I'm struggling to find anywhere.
I would like to make a "quick launch" app in C++ where basically whenever you type in a keyword the app launches. First of all, is it possible to ask the program to "scan" the program files in order to see the list of programs and under what name they are. Second of all, what is the code that would let me execute the program that is typed in?

Thanks in advance, and again i do apologies for asking this type of favor.



bronxbomber92
Feb 11, 2007, 04:56 PM
Could use Applescript to do this. Or, possibly this: http://appscript.sourceforge.net/objc-appscript.html

Take the name entered, append ".app" to the end of the name, and check in then launch the app via applescript or appscript (mainly the same thing :p)

edit - wrong link, changed.

iWill
Feb 12, 2007, 01:21 PM
Isn't there a way to do this just using C++?

ChrisA
Feb 12, 2007, 01:39 PM
Hey guys now usually i hate it when people in this forum come and basically ask someone else to code for them...but i really need some information here that I'm struggling to find anywhere.
I would like to make a "quick launch" app in C++ where basically whenever you type in a keyword the app launches. First of all, is it possible to ask the program to "scan" the program files in order to see the list of programs and under what name they are. Second of all, what is the code that would let me execute the program that is typed in?

Thanks in advance, and again i do apologies for asking this type of favor.

You mean you want to write a program that does the same thing as the Bash shell where you only have to type in as many characters as are required to uniquely identify the command? If so, then it is easy. Bash uses the "readline" library and so can your program. In fact whenever i write software that accepts typed input from the user I always use readline this allows the user to do "command completion" and use the arrow keys to recall previous command, sear his history and so on, just like in Bash. Readline has a pretty much direct replacement for "getline" in stdio.h

But from you say, why not just use Bash itself?

Yes Bash does "scan" the list of program files. It scans and "remembers" all the executable files inside $PATH environment variable. It's not hard. Of course Bash is Open Source so you can read up and see how it works. Readline provide functions to "remember" the commands, not much you need to write.

What cde will execute the program? Again Bash is open source. But read the man (section 3) pages on "fork", and "exec". Typically the command interpetor calls "fork" and then the child process (created by "fork") calls "exec"


One of the best ways to write you own command interpeter is to get text from the user using readline and then send that to a lex/yacc parser and put some fork/exec calls into the yacc action rules.

GeeYouEye
Feb 12, 2007, 01:51 PM
If this is a Mac app, look into Launch Services.

Mydriasis
Feb 12, 2007, 02:29 PM
I know this is a stupid comment and dosen't help with the problem at hand, but I'd just use the keyboard short cut for spotlight, type in the first few letter, hit the down arrow once, then enter and voila.

GeeYouEye
Feb 12, 2007, 03:30 PM
I know this is a stupid comment and dosen't help with the problem at hand

Under normal circumstances, I'd say "then why post it?", but in this particular case you have stumbled on a truth of programming, namely that you should always ask "what problem am I trying to solve, has it been solved before, and can I use that solution?" Would have been better if you'd actually said that and then suggested your solution, but...

iWill
Feb 12, 2007, 03:59 PM
I know this is a stupid comment and dosen't help with the problem at hand, but I'd just use the keyboard short cut for spotlight, type in the first few letter, hit the down arrow once, then enter and voila.
Yea I know but I've only made programs for 6months now so this is basically to test my capabilities.
And other thing, i know it's pretty dumb on my behalf to have posted this on a mac forum but i knew how you guys were responsive and helpful. This is a program I'm intending to make on windows (without the GUI though, just sticking to C++)