Page 1 of 2
Open selected file in same instance/window of SPEK
Posted: Thu Jul 20, 2017 7:54 am
by Fram
Hi guys! I'm really struggling with this. Maybe someone could help me
I want to open files using this sript in the same instance of Spek (same window) (
http://spek.cc/)
At this moment it will open in another window every time. The only way is to drag and drop in the same window.
This is the script:
Code: Select all
' A simple script that shows how to open a selected track in another application.
' In this case it is Spek (expected to be in C:\Program Files (x86)\Spek\spek.exe).
Const SpekPath = "C:\Program Files (x86)\Spek\spek.exe"
Sub OpenInSpek
' Define variables
Dim WShell, Command, NPSong
' Get list of selected tracks from MediaMonkey
Set NPSong = SDB.Player.CurrentSong
' Prepare WScript.Shell object, which can be used for execution of applications
Set WShell = CreateObject("WScript.Shell")
If Not NPSong is Nothing Then
Command = Chr(34) & SpekPath & Chr(34) & " " & Chr(34) & NPSong.Path & Chr(34)
End If
' And execute the command
WShell.Run Command, 1, 0
End Sub
Re: Open selected file in same instance/window of SPEK
Posted: Thu Jul 27, 2017 11:46 am
by Peke
I do not see that spek detect already started and it should be made within app at least for windows
VBS is Limited in process detection. See
Code: Select all
Function IsProcessRunning( strComputer, strProcess )
Dim Process, strObject
IsProcessRunning = False
strObject = "winmgmts://" & strComputer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
IsProcessRunning = True
Exit Function
End If
Next
End Function
Re: Open selected file in same instance/window of SPEK
Posted: Thu Sep 21, 2017 5:33 am
by Fram
You are right! That's also what I was thinking about.
I'm curious if I can make this script to work like this: if i select a track, that track to automatically open in Spek (even if I select it by a simple click or directional (up&down) arrows).
At this moment it will open the selected track only when i press a keyboard shortcut (Ctrl+S for eg.)
You can help me with this or I have to create another post with this issue ?
Re: Open selected file in same instance/window of SPEK
Posted: Fri Sep 22, 2017 6:24 pm
by Peke
Hi,
From what i tried you should close/terminate existing process and start new one
SPEK limitation
See more info at
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Re: Open selected file in same instance/window of SPEK
Posted: Wed Sep 27, 2017 4:25 am
by Fram
i found something on internet about how to run only one instance of an application here:
https://stackoverflow.com/questions/419 ... pplication , but i have difficulties to implement this for SPEK release here :
https://github.com/withmorten/spek/releases
You seem to be more experienced with programming than I do. (I have not coded for about 4 years now: D). Maybe you want to try or help me with this code. Thank you
Re: Open selected file in same instance/window of SPEK
Posted: Wed Sep 27, 2017 7:58 pm
by Peke
Hi,
I would not bother with SPEK itself, but rather just control when to start and when to Close it and start new one.
here is the code for notepad:
Code: Select all
dim S, X
Sub LaunchNotepad()
Set S = CreateObject("WScript.Shell")
Set X = S.Exec("Notepad.exe")
End Sub
Sub QuitNotepad()
If X.Status = 0 Then X.Terminate()
Set X = Nothing
Set S = Nothing
End Sub
Call LaunchNotepad
WScript.Sleep 10000
Call QuitNotepad
Try to use
http://www.mediamonkey.com/wiki/index.p ... n::Objects in your script to save X, S or see
https://msdn.microsoft.com/en-us/librar ... 90%29.aspx to set X, S as VAR that will be passed on next Script start. There are few scripts that already do that.
Also you can use parameters also
https://msdn.microsoft.com/en-us/subscr ... 84%29.aspx
Re: Open selected file in same instance/window of SPEK
Posted: Thu Sep 28, 2017 5:45 am
by Fram
Thanks a lot Peke!
I really appreciate the help given but the information presented is too much for me at this moment. Maybe i will return someday when i'll have more time to digest all this information.
Re: Open selected file in same instance/window of SPEK
Posted: Thu Sep 28, 2017 8:37 am
by Peke
Hi,
OK, it seams to me fairly simple to change and add as 90% of code you already have here and should work after Copy/Paste and little modification., I also agree when all thrown at once it looks like complicated
Re: Open selected file in same instance/window of SPEK
Posted: Thu Sep 28, 2017 10:25 am
by Peke
Hi,
As I thought it it was easy
Here is your script
http://www.happymonkeying.com/plugin.php?q=300107
Only thing is that it was not meant for me to make it
Re: Open selected file in same instance/window of SPEK
Posted: Tue Oct 03, 2017 7:01 am
by Fram
Thank you Peke!!
i got an error at running the script: Error #424 - Microsoft VBScript runtime error. Object required: '[string: "SPEK"]'. File: "C:\Users\...\Local\Temp'MediaMonkey\install.vbs", Line:5, Column:4." & "Error: SPEK not installed".
Re: Open selected file in same instance/window of SPEK
Posted: Tue Oct 03, 2017 10:57 am
by Peke
Updated
Sorry
Note: I installed SPEK in c:\SPEK change path in runspek.vbs
Re: Open selected file in same instance/window of SPEK
Posted: Wed Oct 04, 2017 2:45 pm
by popsmike
Peke wrote:Updated
Sorry
Note: I installed SPEK in c:\SPEK change path in runspek.vbs
I addressed it slightly different as i'm using it as a portable install.
I Extracted the
Spek folder into my
plugins folder then addressed in
runspek.vbs as "Plugins\Spek\Spek.exe"
Re: Open selected file in same instance/window of SPEK
Posted: Wed Oct 04, 2017 5:46 pm
by Peke
Hi,
So all is OK now. From my tests MMIP installs on portable also.
Are you satisfied with performance?
Re: Open selected file in same instance/window of SPEK
Posted: Thu Oct 05, 2017 12:09 am
by Fram
The script run perfectly now, you made a really good job
. Thank you again!
Now I'm wondering if it can be made to keep the original position and size of the window.
Re: Open selected file in same instance/window of SPEK
Posted: Thu Oct 05, 2017 8:08 am
by Peke
No unfortunately, that is controlled by SPEk and Windows.