Trigger a hotkey from the vbs script

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Trigger a hotkey from the vbs script

Re: Trigger a hotkey from the vbs script

by Peke » Mon Jan 18, 2021 10:06 pm

Hi,
Two scripts because to eliminate need for executing Focus and have direct shortcut to delete track and move to next.

re Error-Handler: My pleasure, it was good to see I am not senile ;)

Re: Trigger a hotkey from the vbs script

by Erwin Hanzl » Mon Jan 18, 2021 8:20 am

Hello Pavle,

thank you for your solution, but why a second script to delete?
With my solution, I only need to press the 'Del' key and I'm on the safe side.

Thank you for the Error-Handler
Best regards, Erwin

Re: Trigger a hotkey from the vbs script

by Peke » Mon Jan 18, 2021 4:03 am

Hi,
Hmmm, that still do not explain why you need focus on Current track when you can just ignore it and use additional script with command to delete track if you do not like it and select next track or use your existing Script to Like track and go to next.

Other approach would be to register On play Event and focus on current playing track. eg. something like this.

Code: Select all

Script.RegisterEvent SDB, "OnPlay", "SDB_OnTrackPlay" 

Dim InEventHandler : InEventHandler = False ' Control variable (shows if event handler is executing)

Sub SDB_OnTrackPlay(TrackList) 
    If InEventHandler Then Exit Sub         ' Prevent executing event handler from within itself
    InEventHandler = True                   ' Event starts --> set control variable

	Dim a
	Set a = CreateObject("WScript.Shell")
	a.SendKeys "{F8}"
End Sub

Re: Trigger a hotkey from the vbs script

by Erwin Hanzl » Mon Jan 18, 2021 2:47 am

Hello Pavle,
Thanks for your answer - but I can't do anything with it.

It is very simple:
Set F8 key: "General: Focus tracklist on currently playing item" assigned.

Code: Select all

Sub PlayNext
  'on error resume next
  If (SDB.Player.isPlaying) And (Not SDB.Player.isStartingPlayback) Then
	SDB.Player.Next

	Dim a
	Set a = CreateObject("WScript.Shell")
	a.SendKeys "{F8}"
   End if
End Sub
And finally, I assign a hot key to this script.
Tools> Options> General ... HOTKEYS
"General: Execut script: PlayNext"

Re: Trigger a hotkey from the vbs script

by Peke » Sun Jan 17, 2021 8:08 pm

Hi,
I guess it would be the best to have two scripts eg. one for like and one for dislike/delete. As soon as you hear tracks is to assigned global variable and you can control it with script no focus needed.

You can use that info to show on screen if you also want to check before you decide and switch to next track.

Re: Trigger a hotkey from the vbs script

by Erwin Hanzl » Sun Jan 17, 2021 6:43 pm

Hello Peke,

Thank you for your efforts.

invoke action in MM and send keyboard event

I have a playlist of songs that have never been played.
1. I double-click the first song and listen to it.
2. If I like the song, I trigger this script and the next song plays - but it has no focus.
3. Now I decide: delete the current song? YES
Not possible because the current song has no focus yet.

I have the HOTKEY for the F8 key:
"General: Focus tracklist on currently playing item" assigned.

Re: Trigger a hotkey from the vbs script

by Peke » Sun Jan 17, 2021 5:49 pm

Hi,
Before I go into more details can you please explain what would be the end result?

eg. Send key to other app, invoke action in MM, send keyboard event?

Trigger a hotkey from the vbs script

by Erwin Hanzl » Sun Jan 17, 2021 2:26 pm

Hello experts,

What EXACT command structure can I use to trigger a HotKey.
I would be grateful to you for a helpful answer.
Thanks

Code: Select all

Sub PlayNext
  on error resume next
  If (SDB.Player.isPlaying) And (Not SDB.Player.isStartingPlayback) Then
	SDB.Player.Next
	'The following song is played and should be marked at the same time.
	SendKeys {F8}   ' ?????????????????????
  End if
End Sub

Top