Page 1 of 2
Using POM for single instance of an application?
Posted: 03 Jul 2013 11:55
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?
Re: Using POM for single instance of an application?
Posted: 03 Jul 2013 12:05
by highend
How does the registry entry for sql files look like?
Re: Using POM for single instance of an application?
Posted: 03 Jul 2013 13:00
by blobby
The registry has:
"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" "%1" /dde
Re: Using POM for single instance of an application?
Posted: 04 Jul 2013 06:42
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.
Re: Using POM for single instance of an application?
Posted: 04 Jul 2013 11:08
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.
Re: Using POM for single instance of an application?
Posted: 04 Jul 2013 14:25
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...
Re: Using POM for single instance of an application?
Posted: 04 Jul 2013 16:27
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.
Re: Using POM for single instance of an application?
Posted: 04 Jul 2013 17:10
by highend
<pfaitem> not <curitem>. Apart from that: Show a screenshot...
Re: Using POM for single instance of an application?
Posted: 04 Jul 2013 18:20
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.
Re: Using POM for single instance of an application?
Posted: 04 Jul 2013 18:42
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
Re: Using POM for single instance of an application?
Posted: 04 Jul 2013 23:07
by Stefan
blobby wrote: I cannot find any mention of pfaitem in the XY help.

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.
Re: Using POM for single instance of an application?
Posted: 05 Jul 2013 12:08
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?
Re: Using POM for single instance of an application?
Posted: 05 Jul 2013 12:10
by blobby
Stefan wrote:blobby wrote: I cannot find any mention of pfaitem in the XY help.

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?
Re: Using POM for single instance of an application?
Posted: 05 Jul 2013 12:32
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?
Re: Using POM for single instance of an application?
Posted: 05 Jul 2013 16:29
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.