Using POM for single instance of an application?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
blobby
Posts: 19
Joined: 06 May 2011 16:38

Using POM for single instance of an application?

Post by blobby »

I have setup a POM entry with:

*.sql>C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe

to launch MS SQL Server Management Studio when doule-clicking on a *.sql file. It works, but creates a new instance of ssms every time. This does not happen in normal Explorer.
Is there any way to make XY use the current instance of an application if there is one?
Thanks

Rick :beer:

highend
Posts: 14955
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Using POM for single instance of an application?

Post by highend »

How does the registry entry for sql files look like?
One of my scripts helped you out? Please donate via Paypal

blobby
Posts: 19
Joined: 06 May 2011 16:38

Re: Using POM for single instance of an application?

Post by blobby »

The registry has:

"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" "%1" /dde
Thanks

Rick :beer:

highend
Posts: 14955
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Using POM for single instance of an application?

Post by highend »

The /dde (dynamic data exchange) is the reason why this works with Windows Explorer. You would have to write a helper application (e.g. in AutoHotkey) that either uses dde or "just" automates MS SQL Server Management Studio by sending the necessary keystrokes to the running instance to open the current selected file.
One of my scripts helped you out? Please donate via Paypal

blobby
Posts: 19
Joined: 06 May 2011 16:38

Re: Using POM for single instance of an application?

Post by blobby »

highend wrote:The /dde (dynamic data exchange) is the reason why this works with Windows Explorer. You would have to write a helper application (e.g. in AutoHotkey) that either uses dde or "just" automates MS SQL Server Management Studio by sending the necessary keystrokes to the running instance to open the current selected file.
Thanks.
I am not familiar with helper applications. I am a coder, so I can write scripts.
Could you just point me in the right direction? The XY help has no entries for "helper application" or AutoHotKey.
Thanks

Rick :beer:

highend
Posts: 14955
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Using POM for single instance of an application?

Post by highend »

This would be such a script (written in AutoHotkey):

Code: Select all

#SingleInstance force
SetTitleMatchMode, 2
SendMode Input

mssmsTitle := "Microsoft SQL Server Management Studio" ; Part of the title name to identify the application
ssmsPath   := "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" ; Path to the application

IfWinNotExist, %mssmsTitle%
{
    Run, %ssmsPath% "%1%"
}
else
{
    WinActivate, %mssmsTitle%
    SendInput ^o
    WinWaitActive, ahk_class #32770
    SendInput {Raw}%1%
    ;Sleep, 250
    SendInput {Enter}
}
Compile it with the AutoHotkey compiler, put the .exe e.g. into D:\Test (or wherever you want) and then your entry for the PFA has to look like this:

Code: Select all

*.sql>::run """D:\Test\<name of the compiled exe>.exe"" ""<pfaitem>""";
With all these quotation marks^^

First doubleclick on a .sql file: Open ssms.exe with that file
Following clicks will reuse the existing window...
One of my scripts helped you out? Please donate via Paypal

blobby
Posts: 19
Joined: 06 May 2011 16:38

Re: Using POM for single instance of an application?

Post by blobby »

highend wrote:This would be such a script (written in AutoHotkey):

Code: Select all

#SingleInstance force
SetTitleMatchMode, 2
SendMode Input

mssmsTitle := "Microsoft SQL Server Management Studio" ; Part of the title name to identify the application
ssmsPath   := "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" ; Path to the application

IfWinNotExist, %mssmsTitle%
{
    Run, %ssmsPath% "%1%"
}
else
{
    WinActivate, %mssmsTitle%
    SendInput ^o
    WinWaitActive, ahk_class #32770
    SendInput {Raw}%1%
    ;Sleep, 250
    SendInput {Enter}
}
Compile it with the AutoHotkey compiler, put the .exe e.g. into D:\Test (or wherever you want) and then your entry for the PFA has to look like this:

Code: Select all

*.sql>::run """D:\Test\<name of the compiled exe>.exe"" ""<pfaitem>""";
With all these quotation marks^^

First doubleclick on a .sql file: Open ssms.exe with that file
Following clicks will reuse the existing window...

Mmmmmm. Got it half working. It uses the current instance, but I can't seem to get it to use the passed file.
My XY code is

Code: Select all

*.sql>::run """F:\Rix\SQL stuff\Utils\exessms.exe"" ""<curitem>""";
Which brings up the current instance of ssms, but then prompts for the file to open, as if it didn't get the passed file name.
Thanks

Rick :beer:

highend
Posts: 14955
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Using POM for single instance of an application?

Post by highend »

<pfaitem> not <curitem>. Apart from that: Show a screenshot...
One of my scripts helped you out? Please donate via Paypal

blobby
Posts: 19
Joined: 06 May 2011 16:38

Re: Using POM for single instance of an application?

Post by blobby »

highend wrote:<pfaitem> not <curitem>. Apart from that: Show a screenshot...
I did try <pfaitem> but it gave the same result. I cannot find any mention of pfaitem in the XY help.
This is my XY PFA settings:
XY_PFA.jpg
and this is what happens when I double-click and .sql file:
MSSMS.jpg
It's obviously not getting the passed file.
To see the attached files, you need to log into the forum.
Thanks

Rick :beer:

highend
Posts: 14955
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Using POM for single instance of an application?

Post by highend »

You're not on Windows 7, right?

Execute AU3_Spy.exe from your AutoHotkey folder, make that open file requester window from your SQL Management Studio the active window and then capture a screenshot. I just need the content of the AHK spy window.

My guess:
The ahk_class is not #32770

Btw, <pfaitem> is under Advanced Topics - Variables ->
XYplorer Native Variables --> Scripting with Portable File Associations only
---> <pfaitem> the item (full path) the opening application or script in a Portable File
One of my scripts helped you out? Please donate via Paypal

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Using POM for single instance of an application?

Post by Stefan »

blobby wrote: I cannot find any mention of pfaitem in the XY help.

:idea: Hint: this var is relatively new, so be sure to have a recent XYplorer version.

Code: Select all

Change Log 
v12.30.0102 - 2013-04-13 21:27

+ New temporary variable <pfaitem>, resolves to the item (full path)
      the opening application or script in a PFA (Portable File
      Association) is associated with. In such a script called via PFA
      <pfaitem> can be used. After the PFA is processed the variable is
      reset to nothing.

 

blobby
Posts: 19
Joined: 06 May 2011 16:38

Re: Using POM for single instance of an application?

Post by blobby »

highend wrote:You're not on Windows 7, right?
Wrong. I am on Windows 7(64 bit). Does that make a difference?

highend wrote: Btw, <pfaitem> is under Advanced Topics - Variables ->
XYplorer Native Variables --> Scripting with Portable File Associations only
---> <pfaitem> the item (full path) the opening application or script in a Portable File
I cannot find this in my help file. I am using version 12.30.0200. So it should be there?
Thanks

Rick :beer:

blobby
Posts: 19
Joined: 06 May 2011 16:38

Re: Using POM for single instance of an application?

Post by blobby »

Stefan wrote:
blobby wrote: I cannot find any mention of pfaitem in the XY help.

:idea: Hint: this var is relatively new, so be sure to have a recent XYplorer version.

Code: Select all

Change Log 
v12.30.0102 - 2013-04-13 21:27

+ New temporary variable <pfaitem>, resolves to the item (full path)
      the opening application or script in a PFA (Portable File
      Association) is associated with. In such a script called via PFA
      <pfaitem> can be used. After the PFA is processed the variable is
      reset to nothing.
Thanks for the tip, but I am using 12.30.0200 and it is definitely not in the help file.
If it's not in the help file, does that indicate that it's not implemented in my version?


 
Thanks

Rick :beer:

highend
Posts: 14955
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Using POM for single instance of an application?

Post by highend »

Regardless if you have it or not (why don't you just update to the latest beta?), even <curitem> would work (but not if you'd try it with multiple selected entries).

What about the screenshot of the AU3_Spy.exe entries?
One of my scripts helped you out? Please donate via Paypal

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Using POM for single instance of an application?

Post by Stefan »

blobby wrote:Thanks for the tip, but I am using 12.30.0200 and it is definitely not in the help file.
If it's not in the help file, does that indicate that it's not implemented in my version?
No. Writing help is just boring and so the help is sometimes updated a few days later then releasing the code itself.






 

Post Reply