New Version: Copytags 2.2 (2008-07-18) [MM3]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Maaspuck
Posts: 155
Joined: Thu Dec 28, 2006 4:41 am
Location: Hamburg, Germany

New Update [v1.12]

Post by Maaspuck » Mon Jul 16, 2007 4:34 pm

Hi all,

i've updated my script again. It is just a small but very important update as i solved a lot of problems.

- The WShell call of wait.vbs is no longer needed
- AlbumArt can be added directly without using the FileSystemObject
- The script is much much faster now

The code i used before to include albumart and which didn't work but only for the first file i copied:

Code: Select all

Dim NewPic
Set NewPic = Song.AlbumArt.AddNew
With NewPic
  .PicturePath = PicPath
  .Description = ""
  .ItemType = PicArray(ArrayIndex,2,j)
  .ItemStorage = 0
End With
And this is the code i use now and which is working fine for every song:

Code: Select all

Dim NewPic, NewPic2
Set NewPic2 = Song.AlbumArt
Set NewPic = NewPic2.AddNew
With NewPic
  .PicturePath = PicPath
  .Description = ""
  .ItemType = PicArray(ArrayIndex,2,j)
  .ItemStorage = 0
End With
Is there anybody out there who can explain me why it is important to use 2 objects (NewPic and NewPic2) instead of only one (NewPic)?

But anyway, the script is fantastic fast now and this motivates me to include further improvements.

Regards

Maaspuck

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto » Tue Jul 17, 2007 3:32 am

I can't really explain it, but I knew this was the case. You have to keep the AlbumArt object constant throughout your modifications otherwise it doesn't get saved properly, hence why creating "NewPic2" has solved your problem.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.

Maaspuck
Posts: 155
Joined: Thu Dec 28, 2006 4:41 am
Location: Hamburg, Germany

new version [2.0]

Post by Maaspuck » Sun Jul 22, 2007 10:58 am

Hi all,

i've updated the script again. See the first post in this thread for more details.

Regards

Maaspuck

jsg
Posts: 3
Joined: Tue Jul 24, 2007 4:39 pm

Re: new version [2.0]

Post by jsg » Tue Jul 24, 2007 4:46 pm

Hi Maaspuck,

First of all Thanks for this script.

Drag and drop doesn't work for me, it jumps all over the place when I try to move one song either up or down.

I went over your code, and found that you are using the mousemove event.
I tried to recode using

Sub lstDestination_OLEDragOver(Data, Effect, Button, Shift, x, y, State)
Dim ListView
Set ListView = SDB.Objects("Destination")
Set ListView.Interf.DropHighlight = ListView.Interf.HitTest(x, y)
Set ListView = Nothing
End Sub

But the HitTest is always returning the first or second row, instead of the correct one (This event would determine on which row you want to drop the one you are dragging)

It seems that the x and y coordinates are wrong somehow.
Any ideas?

Maaspuck
Posts: 155
Joined: Thu Dec 28, 2006 4:41 am
Location: Hamburg, Germany

New EventHandler OLEDragOver

Post by Maaspuck » Wed Jul 25, 2007 2:24 pm

Hi jsg,

thx for your comment.

As i really no experience in coding drag and drop events i followed the advice to use the mouseup, mousedown and mousemove events. I encountered only few problems and was very happy that it worked so fine for me. Of course i am a bit disappointed that this code was obviously not as good as i thought. It seems that different computers result in different results when using this script (Maybe any kidn of timing problem again?).
Well, i changed the code a bit and used 'your' OLEDragOver event by adding the following lines:

Code: Select all

	    	.Interf.OLEDragMode = 1
	    	.Interf.OLEDropMode = 1
at the definition part of the right listview control (about line 784 to 800)

Code: Select all

				Script.RegisterEvent .Interf, "OLEDragOver", "OLEDragOverHandler"
at about line 829 (all other registerevent command should be commented out or deleted) and finally at the end of the code the subroutine itself

Code: Select all

Sub OLEDragOverHandler(Data, Effect, Button, Shift, x, y, State)
	'
	Dim ListView, DragID
	DragID = Int((y-19)/14) + 1
	Set ListView = SDB.Objects("Destination")
	'
	With ListView.Interf
		For i = 1 To .Listitems.Count
			If .Listitems(i).Selected = True Then
				If DragID < i Then
					If i > 1 Then
						Call .Listitems.Add (i-1 , , i-1)
		    		.Listitems(i-1).Subitems(1) = .Listitems(i+1).Subitems(1)
		    		.Listitems(i-1).Subitems(2) = .Listitems(i+1).Subitems(2)
		    		.Listitems(i-1).Subitems(3) = .Listitems(i+1).Subitems(3)
		    		.Listitems.Remove(i+1)
		    		.Listitems(i) = .Listitems(i)+1
		    		.Listitems(i-1).Selected = True
					End If
				ElseIf DragID > i Then
					If i < .ColumnHeaders(1).Tag Then
						Call .Listitems.Add (i , , i)
		    		.Listitems(i).Subitems(1) = .Listitems(i+2).Subitems(1)
		    		.Listitems(i).Subitems(2) = .Listitems(i+2).Subitems(2)
		    		.Listitems(i).Subitems(3) = .Listitems(i+2).Subitems(3)
		    		.Listitems.Remove(i+2)
		    		.Listitems(i+1) = .Listitems(i+1)+1
		    		.Listitems(i+1).Selected = True
					End If
				End If
				Exit For
			End If
		Next 'i
	End With
	'
	Set ListView = Nothing
	'
End Sub
As you may see, the sub is almost the same as the usually used MouseMoveEvent-subroutine. The OleDragOver seems to work perfectly. I hope you have the same result.

Regards

Maaspuck

jsg
Posts: 3
Joined: Tue Jul 24, 2007 4:39 pm

Re: New EventHandler OLEDragOver

Post by jsg » Wed Jul 25, 2007 4:24 pm

Hi Maaspuck,

I was trying to enable multiple selection drag, that is why I changed the Events used :D

The problem lies here

Code: Select all

DragID = Int((y-19)/14) + 1
The thing is that depending on the monitor / resolution and who knows what else the 19 and 14 do change
The recommended way to get the underlying index shoud be

Code: Select all

ListView.Interf.HitTest(x, y)
But the problem here is that I'm getting x and y as pixel values and hittest needs twips.
I solved this with

Code: Select all

Dim TwipsPerPixelX
Dim TwipsPerPixelY
Dim strComputer
Dim objWMIService
Dim colItems
Dim objItem
	
TwipsPerPixelX = 0
TwipsPerPixelY = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
	    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor")
	
For Each objItem in colItems
	i=0
	If objItem.PixelsPerXLogicalInch<>0 Then
		i = 1440 \ objItem.PixelsPerXLogicalInch
	End If
	If i>TwipsPerPixelX Then
		TwipsPerPixelX = i
	End If
	i=0
	If objItem.PixelsPerYLogicalInch<>0 Then
		i = 1440 \ objItem.PixelsPerYLogicalInch
	End If
	If i>TwipsPerPixelY Then
		TwipsPerPixelY = i
	End If
Next

If TwipsPerPixelX=0 Then TwipsPerPixelX=15
If TwipsPerPixelY=0 Then TwipsPerPixelY=15

Set objWMIService = Nothing
Set colItems = Nothing
Set objItem = Nothing
In a global scope (line 32)

and

Code: Select all

Set ListItem = ListView.Interf.HitTest(x * TwipsPerPixelX, y * TwipsPerPixelY)
I even got autoscrolling going on the listview

Can you test this sub to see if it highlights and scrolls for you? (It won't rearange the items yet)

Code: Select all

Sub lstDestination_OLEDragOver(Data, Effect, Button, Shift, x, y, State)
	Dim ListView
	Dim ListItem
	Dim i, j
	
	Set ListView = SDB.Objects("Destination")
	ListView.Interf.MousePointer = 14
	Set ListItem = ListView.Interf.HitTest(x * TwipsPerPixelX, y * TwipsPerPixelY)
	
	j=0
	If Not (IsNull(ListView.Interf.DropHighlight) Or IsEmpty(ListView.Interf.DropHighlight) Or ListView.Interf.DropHighlight Is Nothing) Then
		j = ListView.Interf.DropHighlight.Index
	End If

	i=0
	If ListItem Is Nothing Then
		i=j
	ElseIf Not (IsNull(ListItem) Or IsEmpty(ListItem)) Then
		i = ListItem.Index
	End If
	
	
	If y >= ListView.Common.ClientHeight Then
		If j<ListView.Interf.ListItems.Count Then
			ListView.Interf.ListItems(j+1).EnsureVisible
			Set ListView.Interf.DropHighlight = ListView.Interf.ListItems(j+1)
		End If
	ElseIf x<>0 And y<10 Then
		If j>1 Then
			ListView.Interf.ListItems(j-1).EnsureVisible
			Set ListView.Interf.DropHighlight = ListView.Interf.ListItems(j-1)
		End If
	ElseIf i=0 Or j=0 Or i<>j Then
		Set ListView.Interf.DropHighlight = ListItem
	End If
	
	Set ListItem = Nothing
	Set ListView = Nothing
End Sub
So far so good, but I cannot get the OLEDragDrop event to fire :( :(

Code: Select all

Script.RegisterEvent .Interf, "OLEDragDrop","lstDestination_OLEDragDrop"

Private Sub lstDestination_OLEDragDrop(Data, Effect, Button, Shift, x, y)
	SDB.MessageBox "In DragDrop",mtInformation,Array(mbOk)
End Sub
Gives an error on media monkey
Also I do beleive that some method to send a track to the bottom or first part of the list would be very usefull

jsg
Posts: 3
Joined: Tue Jul 24, 2007 4:39 pm

Re: New EventHandler OLEDragOver

Post by jsg » Thu Jul 26, 2007 12:02 pm

Hi Maaspuck,

Ok I have multiselect drag and drop working :D

Code: Select all

Script.RegisterEvent .Interf, "OLEDragDrop","lstDestination_OLEDragDrop"

Private Sub lstDestination_OLEDragDrop(Data, Effect, Button, Shift, x, y)
	SDB.MessageBox "In DragDrop",mtInformation,Array(mbOk)
End Sub
That code was not working because it was private :oops:

How do I send you the modifications? Through a post or pm or an email?
I hope you find them usefull

Maaspuck
Posts: 155
Joined: Thu Dec 28, 2006 4:41 am
Location: Hamburg, Germany

drag and drop

Post by Maaspuck » Fri Jul 27, 2007 3:28 pm

Hi jsg,

as i already said, i changed to OLEDragOver event to use drag and drop. You can see my subroutine below.

Code: Select all

Sub OLEDragOverHandler(Data, Effect, Button, Shift, x, y, State)
	'
	Dim ListView, DragID, Selected
	Set ListView = SDB.Objects("Destination")
	Set Selected = ListView.Interf.SelectedItem
	i = Selected.Index
	DragID = Int((y - 19) / 14) + ListView.Interf.GetFirstVisible
	'
	With ListView.Interf
		If DragID < i Then
			If i > 1 Then
				Call .Listitems.Add (i-1 , , i-1)
    		.Listitems(i-1).Subitems(1) = .Listitems(i+1).Subitems(1)
    		.Listitems(i-1).Subitems(2) = .Listitems(i+1).Subitems(2)
    		.Listitems(i-1).Subitems(3) = .Listitems(i+1).Subitems(3)
    		.Listitems.Remove(i+1)
    		.Listitems(i) = .Listitems(i)+1
    		.Listitems(i-1).Selected = True
    		.ListItems(i-1).EnsureVisible
			End If
		ElseIf DragID > i Then
			If i < .ColumnHeaders(1).Tag Then
				Call .Listitems.Add (i , , i)
    		.Listitems(i).Subitems(1) = .Listitems(i+2).Subitems(1)
    		.Listitems(i).Subitems(2) = .Listitems(i+2).Subitems(2)
    		.Listitems(i).Subitems(3) = .Listitems(i+2).Subitems(3)
    		.Listitems.Remove(i+2)
    		.Listitems(i+1) = .Listitems(i+1)+1
    		.Listitems(i+1).Selected = True
    		.ListItems(i+1).EnsureVisible
			End If
		End If
	End With
	'
	Set ListView = Nothing
	Set Selected = Nothing
	'
End Sub
As you may see i still use the calculation of the ListView.Index:

Code: Select all

DragID = Int((y - 19) / 14) + ListView.Interf.GetFirstVisible
I only added the addition of the 'ListView.Interf.GetFirstVisible' in order to support longer file lists which are longer than the number of visible items. I tested this with many different screen resolutions and MediaMonkey skins and it always worked perfectly. Unfortunately i can't reproduce the problems you described concerning twips and pixels. Maybe you can describe the problems you encountered in more detail?

MultiSelection:
Including drag and drop functions together with multi selection seems to be a bigger task as i think i must include a small array with all selected items then (or can this be done automatically somehow?) in order to be able to change their position while dragging is used. Furthermore, this array has to be saved anywhere as the information will be lost when the sub is called again. At the moment i think this is not so important. I personally use the reorganizing functions only with a small set of songs which could be done in single selection mode.

But anyway thanks a lot for your ideas and keep on posting in order to share ideas and coding asmples/tricks.

Regards

Maaspuck

Maaspuck
Posts: 155
Joined: Thu Dec 28, 2006 4:41 am
Location: Hamburg, Germany

New download link

Post by Maaspuck » Fri May 16, 2008 2:47 pm

Hi all,

after quite a while of silence i detected that the download link to my CopyTags script wasn't active anymore. Now i updated the link and hope it will stay a while. Please have a look at the first post in this thread for a description and the download link.

BTW: Glad to hear that some of you use this script. So if you have ideas for improvements, please don't hesitate to post them here. I hope there is some time to update the script in the near future.

Best regards

Maaspuck

gege
Posts: 861
Joined: Tue Sep 05, 2006 2:10 pm
Location: Brazil

Re: New download link

Post by gege » Fri May 16, 2008 7:48 pm

Maaspuck wrote:So if you have ideas for improvements...
I do:
1) Host it in a decent site ;-) I use googlepages to host my LyricsViewer. I think it's much better than any Single-click host... BTW, TurboShare didn't like me because I use AdBlock Plus. I had to disable it in order to download the file...

2) Add support to Custom 4 and 5 fields.

3) Fix this error, which occurs when I press "Edit tags to be copied..." button:

Code: Select all

Error #5 - Microsoft VBScript runtime error
Invalid procedure call or argument: 'Mid'
File: "C:\Program Files\MediaMonkey3\Scripts\Auto\CopyTags.vbs", Line: 1100, Column: 2
Oh, thanks for the quick response!

Cheers

Maaspuck
Posts: 155
Joined: Thu Dec 28, 2006 4:41 am
Location: Hamburg, Germany

Post by Maaspuck » Sat May 17, 2008 1:19 am

Hi gege,

1) yep, i also dislike all these 1-click hoster with all the ads. I searched a while and found drop.io, which looks much more professional. So i gave it a try and updated the link.

2) will work on that

3) This error sounds strange as 'mid' is a vbscript statement and thus should work on every computer. I have to think about this...

Regards

Maaspuck

Maaspuck
Posts: 155
Joined: Thu Dec 28, 2006 4:41 am
Location: Hamburg, Germany

Update

Post by Maaspuck » Sat May 17, 2008 5:06 am

Hi gege and all,

you now are able to download version 2.1 of the script.

@gege
This version is also rather old so i guess you still get the error you described before, but probably in another line. Could you please test this version and tell whether you still get this error. It would be nice if you can post the CopyTags-section of the MediaMonkey.ini file here. It should look like this:

Code: Select all

[CopyPasteTags]
OptBackUpFiles=0
OptAskBeforeWritingTags=0
OptShowFileWindow=1
OptDelImages=1
OptInformationMessage=0
TagPreset1=011101110000001000000010000000000001100000000001100000010001;SameAlbum;1
TagPreset2=010000000000000000000000000000000000000000000000000000000000;AlbumArtOnly;1
TagPreset3=011101110100111111110010010110110011111110011001111000011101;AllTags;1
TagPreset4=000001110100111111110010010110110011111110011001111000011101;Same Song;1
TagPreset5=001101110100111111110010010110110011111110011001111000011101;<slot 5 empty>;0
TagPreset6=001101110100111111110010010110110011111110011001111000011101;<slot 6 empty>;1
TagPreset7=001101110100111111110010010110110011111110011001111000011101;<slot 7 empty>;1
TagPreset8=001101110100111111110010010110110011111110011001111000011101;<slot 8 empty>;0
TagPreset9=001101110100111111110010010110110011111110011001111000011101;<slot 9 empty>;0
TagPreset10=001101110100111111110010010110110011111110011001111000011101;<slot 10 empty>;0
TagPreset11=001101110100111111110010010110110011111110011001111000011101;<slot 11 empty>;0
TagPreset12=001101110100111111110010010110110011111110011001111000011101;<slot 12 empty>;0
TagPreset13=001101110100111111110010010110110011111110011001111000011101;<slot 13 empty>;0
TagPreset14=001101110100111111110010010110110011111110011001111000011101;<slot 14 empty>;0
TagPreset15=001101110100111111110010010110110011111110011001111000011101;<slot 15 empty>;0
TagPreset16=001101110100111111110010010110110011111110011001111000011101;<slot 16 empty>;0
TagPreset17=001101110100111111110010010110110011111110011001111000011101;<slot 17 empty>;0
TagPreset18=001101110100111111110010010110110011111110011001111000011101;<slot 18 empty>;0
TagPreset19=001101110100111111110010010110110011111110011001111000011101;<slot 19 empty>;0
TagPreset20=000000000000000000000000000000000000000000000000000000000000;<slot 20 empty>;1
TagPreset0=010000000000000000000000000000000000000000000000000000000000;AlbumArtOnly;1
Regards

Maaspuck

gege
Posts: 861
Joined: Tue Sep 05, 2006 2:10 pm
Location: Brazil

Post by gege » Sun May 18, 2008 10:44 am

Maaspuck,
I downloaded version 2.1 and tested it. Same "Mid" error.
Then, I opened MediaMonkey.ini, deleted [CopyPasteTags] Section and I started MM again. No problem this time.

Unfortunately, I forgot to save the old [CopyPasteTags] section :oops: and thus I can't show you how it looked like...

But the problem is solved now, at least.

Maaspuck
Posts: 155
Joined: Thu Dec 28, 2006 4:41 am
Location: Hamburg, Germany

Post by Maaspuck » Sun May 18, 2008 12:29 pm

glad to hear that it works now...

Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny » Fri May 23, 2008 4:48 am

Nice script. But I couldn't import the BPM-values because there was a datatype problem...

Edit: And the tracknumber changed from '01' to '1', '02' to '2', etc.

Edit: And I think the Album and the Album Artist got changed.
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design

Post Reply