Author Topic: Watch clipboard for text, and treat it as a search term  (Read 1773 times)

mrbenn

  • Full Member
  • ***
  • Posts: 167
Random thought while going on a tagging binge:

A mode for Musicbee that would watch the clipboard for text, then auto-paste that text into the search box and bring up the result without having to alt-tab > paste or move the cursor.

Each new entry to the clipboard could open a new tab or refresh the search.


I guess this could be a plugin, but I have no knowledge of coding on Windows.

phred

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 9301
-1
I often have MB open and playing music on one monitor and doing other things on the other monitor. And that includes copying to the clipboard. I don't need/want that stuff being pasted into MB's search field.
Download the latest MusicBee v3.5 or 3.6 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
The FAQ
The Wiki
Posting screenshots is here
Searching the forum with Google is  here

Zak

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 2450
I think a better and less obtrusive implementation would be a new command "Search for clipboard text"*.
Yes, that would be an extra keypress, but anything that introduces a new "mode" to a program is generally bad.

Assigning the command to a global hotkey would allow searching even if MusicBee wasn't the active window.

*There's probably a better title...
Bee excellent to each other...

mrbenn

  • Full Member
  • ***
  • Posts: 167
-1
I often have MB open and playing music on one monitor and doing other things on the other monitor. And that includes copying to the clipboard. I don't need/want that stuff being pasted into MB's search field.

Oh for sure. This would be an option for when it was needed, not the default behavior.

zkhcohen

  • Sr. Member
  • ****
  • Posts: 346
This would take me about 10 minutes to make as an add-on. Let me give it a shot ASAP.

mrbenn

  • Full Member
  • ***
  • Posts: 167
This would take me about 10 minutes to make as an add-on. Let me give it a shot ASAP.

Amazing! Thank you!

I used this as an excuse to get back into Python. I'll post about that in the plugins thread.

zkhcohen

  • Sr. Member
  • ****
  • Posts: 346
This would take me about 10 minutes to make as an add-on. Let me give it a shot ASAP.

Amazing! Thank you!

I used this as an excuse to get back into Python. I'll post about that in the plugins thread.

Almost done with this one. On vacation so I can only work on it sporadically. Hopefully I can send it to you later today.

Tony1

  • Jr. Member
  • **
  • Posts: 26
How bout when text is highlighted in the browser and or anywhere on the computer. A "Search In MusicBee" option in the context menu.

mrbenn

  • Full Member
  • ***
  • Posts: 167
I've posted a proof of concept written in Python in the plugins thread.

zkhcohen

  • Sr. Member
  • ****
  • Posts: 346
Here's my proof of concept. Right now it only searches for the exact title of songs - this is because of a shortcoming with the API (or I have no idea how to use that call).

I'm submitting a request to Steven to have this issue resolved. If it is, it should search exactly the same way that the search bar does.


Link:

https://www.mediafire.com/file/ibdm0k2eois6zw0/mb_ClipboardTextSearch.dll/file


Hotkey Example:




There are effectively 2 lines of active code which make this work:

Code
 
public void ReceiveNotification(string sourceFileUrl, NotificationType type)
        {
            switch (type)
            {
                case NotificationType.PluginStartup:
                    
                    mbApiInterface.MB_RegisterCommand("General: Search for Clipboard Text", searchLibrary);

                    break;
            }
        }

      
        private void searchLibrary(object sender, System.EventArgs e)
        {

            if(Clipboard.ContainsText())
            {

                string searchTerm = Clipboard.GetText();

                mbApiInterface.MB_OpenFilterInTab(MetaDataType.TrackTitle, ComparisonType.Is, searchTerm, MetaDataType.TrackTitle, ComparisonType.Is, searchTerm);
                

                
            }
            else
            {

                MessageBox.Show("No text found in Clipboard!");

            }
            
        }
Last Edit: May 20, 2019, 01:49:30 AM by zkhcohen

mrbenn

  • Full Member
  • ***
  • Posts: 167
Grateful for the effort in putting this together. I'll install this and test this weekend.

Thanks

zkhcohen

  • Sr. Member
  • ****
  • Posts: 346
Grateful for the effort in putting this together. I'll install this and test this weekend.

Thanks

Steven added the option to use "Contains".

Please try this version below:

https://www.mediafire.com/file/ibdm0k2eois6zw0/mb_ClipboardTextSearch.dll/file