0

I have java desktop application.

when user click on the shortcut of the application it create single instance that shown in task bar (Project.exe) but when the user again click then it create another instance but i do not want more then one instance shown in taskbar.

I want the similar behaviour when user click the Teamviewer and Skype application. It create single instance and if it already open then it fore ground to the window (means maximize it.)

But how to maximize the window if the application is already running(means minimize window should be maximize on click the application icon)?

Please provide the solution.

Thanks in advance.

user3337109
  • 79
  • 2
  • 10

2 Answers2

0

look at this: How to implement a single instance Java application?

Community
  • 1
  • 1
  • But how to maximize the window if the application is already running(means minimize window should be maximize on click the application icon)? – user3337109 Sep 17 '14 at 07:21
0

Not possible with simple batch.Here's a jscript/batch hybrid (save it as .bat):

 @if (@x)==(@y) @end /***** jscript comment ******
     @echo off

     cscript //E:JScript //nologo "%~f0" "%~1"
     exit /b 0

 @if (@x)==(@y) @end ******  end comment *********/

 var app_name = WScript.Arguments.Item(0);
 var shell =  WScript.CreateObject("WScript.Shell");
 shell.AppActivate(app_name);
 shell.SendKeys("% x");

The script accepts a single argument - the windows title - which will try to maximize.Eventually you can apply the saved the .bat to the shortcut (in the target field).

Here's how look my test shortcut that starts and maximizes the notepad (the program is started through the cmd.exe):

C:\Windows\System32\cmd.exe /c " start C:\Windows\notepad.exe &   call C:\tests\focuson.bat "Untitled - Notepad""
npocmaka
  • 55,367
  • 18
  • 148
  • 187
  • Thanks for the response. But when i execute bat file it maximize the window and after that i minimize it but again execute it. It does not maximize the window. If i perform any operation of the application then it maximize the window other wise it minimize it. Please let me know is there any need to add this script. – user3337109 Sep 18 '14 at 04:09
  • @user3337109 - try to set the title so close to your application as possible.What the script does is to get the focus to the application and send "alt+space+x" .Check if your application maximazies with this key combination. – npocmaka Sep 18 '14 at 07:55
  • @user3337109 - if everything is ok you can accept the answer :) – npocmaka Sep 18 '14 at 09:29