Welcome to Dream.In.Code
Become a Java Expert!

Join 149,617 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,871 people online right now. Registration is fast and FREE... Join Now!




Getting Data from an independent program

 
Reply to this topicStart new topic

Getting Data from an independent program

Kraiden
18 Sep, 2007 - 11:28 PM
Post #1

New D.I.C Head
*

Joined: 18 Sep, 2007
Posts: 3


My Contributions
Hi there!

I have a problem. I have been asked to write a program that will take info from an independent program and write it to a file. to explain, a window will pop on screen saying something like "Hello <username>" and My program then needs to...

See that this has happened, take the username, and write it to a file.

My problem is this... I have no idea how to a) detect that a program has opened on screen, and cool.gif how to get that user name.

I know this is probably very simple to do, but I, being a n00b programmer, have no idea how! I was hoping that someone here might be able to point me in the right direction.

please help me!
User is offlineProfile CardPM
+Quote Post

goldenthunder
RE: Getting Data From An Independent Program
19 Sep, 2007 - 12:24 AM
Post #2

New D.I.C Head
*

Joined: 18 Sep, 2007
Posts: 13


My Contributions
I guess you cant change the independent programm, can you?

If yes, you could send a TCP-Message (even if it is on the same computer) with the username.
your programm (running in the background) would listen to an arranged port.

If you have no access to the independent programm, I have no idea.
User is offlineProfile CardPM
+Quote Post

Kraiden
RE: Getting Data From An Independent Program
19 Sep, 2007 - 12:30 AM
Post #3

New D.I.C Head
*

Joined: 18 Sep, 2007
Posts: 3


My Contributions
Ye, we have no access to the independent program at all! I was thinking, is there some way to view the windows processes through java? because that would solve the problem of knowing if the independent program is running or not!

User is offlineProfile CardPM
+Quote Post

Programmist
RE: Getting Data From An Independent Program
19 Sep, 2007 - 01:19 AM
Post #4

Four-letter word
Group Icon

Joined: 2 Jan, 2006
Posts: 1,250



Thanked: 11 times
Dream Kudos: 100
Expert In: Java

My Contributions
Even if you checked the Windows processes and knew that the program was running (which would be difficult since most all java programs show up as java.exe) how would you get the user name from it? It would be running in it's own JVM, so you would need to use some sort of IPC method to communicate with the process.

This post has been edited by Programmist: 19 Sep, 2007 - 01:20 AM
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Getting Data From An Independent Program
19 Sep, 2007 - 02:54 AM
Post #5

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
These kind of things are possible with the Windows API. From Java you can access those functions with JNA, but generally this task is much easier to implement in C. Doing it from Java is pointless, just makes the whole thing much more difficult without any reason.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:36AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month