How to update the DP filename as personal Msg |
Author: |
Message: |
tantiger
New Member
Posts: 6
Joined: Jan 2009
|
O.P. How to update the DP filename as personal Msg
Hi,
I am using the DP change script to show some pictures in a certain folder. I am trying to display the filename as personal message whenever the image is changed.
I tried using Messenger.MyPersonalMessage=fileName; but it shows the full path info, when I tried to use substring,
tmpString=Messenger.MyPersonalMessage.subString(35); //skip first 35 chr
Messenger.MyPersonalMessage=tmpString;
it can only update once when I save the script, then it just leave the message empty and only update when the image is going to change, which is too short to see the name.
What I want to is, if the file name is like D:\My Picture\...\file001.jpg, how can I show file001 only as the personal message when the images are chaning in 10s interval. Can anyone help me for that? Thanks in advance.
|
|
01-18-2009 02:38 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: How to update the DP filename as personal Msg
Best way to do it would be
js code: Messenger.MyPersonalMessage = filename.substring(filename.lastIndexOf('\\')+1);
|
|
01-18-2009 02:59 PM |
|
|
tantiger
New Member
Posts: 6
Joined: Jan 2009
|
O.P. RE: How to update the DP filename as personal Msg
Hi, Matty,
I tried your method, it was suppose to work, but very strange, the name never update as fast as the picture goes. I used the following code to check if the name transferred out:
Messenger.MyDisplayPicture = fileName;
Messenger.MyPersonalMessage=fileName;
tmpString =Messenger.MyPersonalMessage;
tmpString =tmpString.substring(tmpString.lastIndexOf('\\')+1);
tmpString =tmpString.substring(0,tmpString.length-4);
MsgPlus.DisplayToast("",tmpString);
The result is, say, I have file001.jpg to file100.jpg to be displayed, when the imaged changed from 001 to 002, the tmpString can only get the old filename, file001, but the msn personal message can have the correct one but with full path.
I really confused by these codes, maybe it is due to beta version?
|
|
01-18-2009 03:55 PM |
|
|
Danny22
New Member
Posts: 11
Joined: Dec 2008
|
RE: How to update the DP filename as personal Msg
I tried to make a small script for you right now but I am not sure if it's exactly what you're looking for and if it works the same way with your version of WLM.
At least with my version of WLM (8.5), you get the DP file name from the "shell:Local AppData\Microsoft\Messenger\<e-mail>\ObjectStore\UserTile" folder and an example file name could be "dW0VZfrFH4igpqB+aknu+YLVPQc=.dt2" (this is the default chess picture).
This script detects when your DP has changed and will then set your personal message as the file name ("dW0VZfrFH4igpqB+aknu+YLVPQc=" in my example).
I hope you can use it.
code: var prevDpFileName = "";
function OnEvent_Initialize(MessengerStart)
{
oldDpFileName = Messenger.MyDisplayPicture;
MsgPlus.AddTimer("DpChangeTimer", 1000);
}
function OnEvent_Timer(TimerId)
{
switch (TimerId)
{
case "DpChangeTimer":
if (Messenger.MyDisplayPicture != prevDpFileName) // your DP has changed
{
// fire custom event
OnEvent_DpChanged(Messenger.MyDisplayPicture);
prevDpFileName = Messenger.MyDisplayPicture;
}
MsgPlus.AddTimer(TimerId, 1000);
break;
}
}
function OnEvent_DpChanged(NewFileName)
{
var tempFileName = NewFileName;
// extract the file name
tempFileName = tempFileName.substr(tempFileName.lastIndexOf("\\") + 1);
var extPos = tempFileName.lastIndexOf(".");
if (extPos >= 0) // the file name has an extension
{
// remove the extension
tempFileName = tempFileName.substr(0, extPos);
}
// update personal message
Messenger.MyPersonalMessage = tempFileName;
}
This post was edited on 01-18-2009 at 07:19 PM by Danny22.
|
|
01-18-2009 07:16 PM |
|
|
tantiger
New Member
Posts: 6
Joined: Jan 2009
|
O.P. RE: How to update the DP filename as personal Msg
Hi, Danny,
Thanks for your help. Learned something from you code
However, this filename is not I want, I am using DP change script, in that script, there is one sentence to change the DP:
Messenger.MyDisplayPicture = fileName;
What I want is to update the personal message at the same time, but it seems what I tried so far can only update the filename of the previous images, always one image behind. Really strange. I used :
Messenger.MyPersonalMessage=fileName;
tmpString =Messenger.MyPersonalMessage;
tmpString =tmpString.substring(tmpString.lastIndexOf('\\')+1);
tmpString =tmpString.substring(0,tmpString.length-4);
MsgPlus.DisplayToast("",tmpString);
immediately aft that sentence, but it seems fileName is the current new picture, while my tmpString can only have the old filename. I knew this because the last sentence showed the tmpString in toast window and my personal message is showing the correct filename with full path. Really headache, is it due to the personal message change cannot be so quick?
|
|
01-19-2009 02:49 AM |
|
|
Jesus
Scripting Contest Winner
Koffie, my cat ;)
Posts: 623 Reputation: 15
38 / /
Joined: Jul 2005
|
RE: How to update the DP filename as personal Msg
Let me get this straight...
fileName contains the full path to the new image.
you want to set your PSM to the name of the file in fileName
if so, use something along these lines: (can't test atm because I'm on a linux machine, but it should work)
js code: Messenger.MyPersonalMessage=fileName.substring(fileName.lastIndexOf('\\')+1, fileName.lastIndexOf('.'))
edit: lol ('.') turned into a bunny :P
edit2: just saw you tried matty's code (which does the same, except it doesn't remove the extension) and it delayed the PSM change... how long is the delay there?
This post was edited on 01-19-2009 at 03:40 AM by Jesus.
Man is least himself when he is in his own person. Give him a mask and he will tell you the truth. (Oscar Wilde)
|
|
01-19-2009 03:27 AM |
|
|
tantiger
New Member
Posts: 6
Joined: Jan 2009
|
O.P. RE: How to update the DP filename as personal Msg
Hi, Jesus
the fileName in the original code is not a string, so substring method not working directly on it. That's why I first let MyPersonalMessage=fileName, which works fine except it shows the full path info; then I use the tempString to get this info out and remove the path and extension.
My problem is, if I do this way, the tempString always showing the last image's filename instead of the recent one being showed.
Matty's code is showing some names as dW0VZfrFH4igpqB+aknu+YLVPQc=.dt2, which is not what I want to show. I just wondering why it always showing the last image filename instead of the current one:
Messenger.MyPersonalMessage=fileName;
tempString=Messenger.MyPersonalMessage;
After these two codes, tempString is the name of the last image while my messeger's persnal message shows the correct filename (full path).
Hi, Matty, Danny22 and Jesus,
Thank you all for you help. I have figured out how to do that.
Just a force type conversion, let tempSting=String(fileName), then the script is running as what I am expecting
Thanks!
|
|
01-19-2009 08:15 AM |
|
|
Jesus
Scripting Contest Winner
Koffie, my cat ;)
Posts: 623 Reputation: 15
38 / /
Joined: Jul 2005
|
RE: How to update the DP filename as personal Msg
quote: Originally posted by tantiger
the fileName in the original code is not a string, so substring method not working directly on it.
wait...what??
what is it then?
I thought Messenger.MyPersonalMessage had to be set to a string?
Man is least himself when he is in his own person. Give him a mask and he will tell you the truth. (Oscar Wilde)
|
|
01-19-2009 02:12 PM |
|
|
tantiger
New Member
Posts: 6
Joined: Jan 2009
|
O.P. RE: How to update the DP filename as personal Msg
I am also confused by the original scripts, it is from Display Picture Changer, the newest version, I would like to display the picture's filename, too, so my friends knows what that picture is. Then I tried to modify the code and found that line. I tried use that line:
Messenger.MyPersonalMessage=fileName;
Although fileName is not a pure string object, it seems it works fine. But cannot get substring from it.
|
|
01-19-2009 03:04 PM |
|
|
Jesus
Scripting Contest Winner
Koffie, my cat ;)
Posts: 623 Reputation: 15
38 / /
Joined: Jul 2005
|
RE: How to update the DP filename as personal Msg
I just did some research on the web, turns out fileName is a misleading name for the variable.
It's actually a File Object, obtained by enumerating a Folder Object from the FileSystem ActiveX.
Anyway, you can get its filename by using
js code: Messenger.MyPersonalMessage=fileName.Name
I'm not sure wether that includes the extension or not (still on linux), but I think it does. You can remove the extension with the substring method, as fileName.Name should be a string.
Man is least himself when he is in his own person. Give him a mask and he will tell you the truth. (Oscar Wilde)
|
|
01-19-2009 03:46 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|