Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One invoke another one but cant active it

 
endswel shui
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One invoke another one but cant active it

There is a case, using one java app (name app1) to invoke the other one (name app2),
app2 is hide, cant see it in the desktop, but can see it in the system tray.
now if I want to use app1 to invoke app2 and active it to show in the desktop,
I cant do it.

 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean that you'd like to open something from the system tray, I doubt that you'll be able to do it using pure Java. As far as I know, Java can't interact with the operating system on that level.
 
endswel shui
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, just app2
I can using the exe4j ( the one instane properties) to pakcage app2
and using the image_name or pid find it,
but cant make the app2 show in the desktop if app2 is in the system tray
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the other application is not part of the same JVM you definitely have to use JNI (or JNA) for this.
 
endswel shui
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Since the other application is not part of the same JVM you definitely have to use JNI (or JNA) for this.


hi Rob Spoor
but how, do you have some experience (like code, etc.) to share.

how to handle the handle?
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To go through all the windows, you need native function "EnumWindows".
To go through all the processes, you first need to make a snapshot using "CreateToolhelp32Snapshot, then call "Process32First" once followed by "Process32Next" for all the remaining processes.

Check out Microsoft's MSDN site for more information and some examples.
 
endswel shui
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:To go through all the windows, you need native function "EnumWindows".
To go through all the processes, you first need to make a snapshot using "CreateToolhelp32Snapshot, then call "Process32First" once followed by "Process32Next" for all the remaining processes.

Check out Microsoft's MSDN site for more information and some examples.


hi, Rob
Thank you for your answer, I follow it and implement the result what I want,

there is another issue,

for the app2, when it is activated from the system tray by the app1.
How could I hide the system tray, (because if the app2 shows itself in the desktop, it's system tray will be hide)
I try using the ShowWindow and FindWindow in the jpa under the User32, but FindWindow cant find it. --!
so, is there any method to solve this?
 
endswel shui
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
endswel shui wrote:
Rob Spoor wrote:To go through all the windows, you need native function "EnumWindows".
To go through all the processes, you first need to make a snapshot using "CreateToolhelp32Snapshot, then call "Process32First" once followed by "Process32Next" for all the remaining processes.

Check out Microsoft's MSDN site for more information and some examples.


hi, Rob
Thank you for your answer, I follow it and implement the result what I want,

there is another issue,

for the app2, when it is activated from the system tray by the app1.
How could I hide the system tray, (because if the app2 shows itself in the desktop, it's system tray will be hide)
I try using the ShowWindow and FindWindow in the jpa under the User32, but FindWindow cant find it. --!
so, is there any method to solve this?



I fail of this icon hide
I find the reason maybe to change the Shell_NotifyIcon()
but it is not very easy to write using jna. I dont know why, maybe some loss.
--!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic