Shoutbox

Help With PlusWnd.GetControlText - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Help With PlusWnd.GetControlText (/showthread.php?tid=75083)

Help With PlusWnd.GetControlText by pedro_cesar on 06-05-2007 at 04:39 PM

I have this -piece- of XMl code:

code:
<Control xsi:type="EditControl" Id="pathEdit">
<Position Left="10" Top="30" Width="230"/>
</Control>

<Control xsi:type="ButtonControl" Id="StealBTN">
<Position Left="100" Top="50" Width="50"/>               
<Caption>Steal</Caption>
</Control>


And this -piece- of JScript code:
code:
function stealDP (dir_path) {
    for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext())
        { var Contact = e.item();
        if (Contact.DisplayPicture != "") {
        var oFSO = new ActiveXObject("Scripting.FileSystemObject");
        oFSO.CopyFile(Contact.DisplayPicture,dir_path+Contact.Email+".png");
        }
    } MsgBox("Successfully Stolen!");
}


///////////Using The Script/////////////

function OnWndTestEvent_CtrlClicked(PlusWnd, ControlId) {
   
    if(ControlId == "StealBTN") {
        dir_path = PlusWnd.GetControlText("pathEdit");
        stealDP (dir_path) }


but I dunno where the pics are being saved, 'cause they don't go to the path I type in "pathEdit" neither to the script's directory :S

How do I pass correctly what was typed in "pathEdit" to a variable so later I can use that in the StealDp function?
RE: Help With PlusWnd.GetControlText by matty on 06-05-2007 at 04:45 PM

quote:
Originally posted by pedro_cesar
I have this -piece- of XMl code:

code:
<Control xsi:type="EditControl" Id="pathEdit">
<Position Left="10" Top="30" Width="230"/>
</Control>

<Control xsi:type="ButtonControl" Id="StealBTN">
<Position Left="100" Top="50" Width="50"/>               
<Caption>Steal</Caption>
</Control>


Can you post the rest of the XML? Did you change the Window ID? If so then you need to correct your OnWindowIdEvent_CtrlClicked()


quote:
Originally posted by pedro_cesar
And this -piece- of JScript code:
code:
function stealDP (dir_path) {
    for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext())
        { var Contact = e.item();
        if (Contact.DisplayPicture != "") {
        var oFSO = new ActiveXObject("Scripting.FileSystemObject");
        oFSO.CopyFile(Contact.DisplayPicture,dir_path+Contact.Email+".png");
        }
    } MsgBox("Successfully Stolen!");
}


Just making your routine better
code:
function stealDP(path){
    for (var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()){
        if (e.item().DisplayPicture !== ''){
            Interop.Call('user32', 'CopyFileW', e.item().DisplayPicture, path + '\\' + e.item().Email + '.png', false);
        }
    }
}

quote:
Originally posted by pedro_cesar
How do I pass correctly what was typed in "pathEdit" to a variable so later I can use that in the StealDp function?
Make a global variable

code:
var this_is_a_global_variable;
function _this_is_a_function(){
    var this_is_a_local_variable;
}

RE: Help With PlusWnd.GetControlText by pedro_cesar on 06-06-2007 at 04:02 PM

I've been testing the script and I know where the problem is: The dir_path variable is taking the path ok, but at this line the script takes it the wrong way:

oFSO.CopyFile(Contact.DisplayPicture,dir_path+Contact.Email+".png");

Let's assume I typed: C:\Fotos
1.- dir_path stores it correctly
2.- the pictures go to C:\ and the name starts with "Fotos", so it doesn't take "Fotos" as part of the path.

How can I correct this?


RE: Help With PlusWnd.GetControlText by Matti on 06-06-2007 at 04:11 PM

Add a backslash! :D

code:
dir_path+"\\"+Contact.Email+".png"

RE: Help With PlusWnd.GetControlText by pedro_cesar on 06-06-2007 at 05:05 PM

It doesn't work and this is the error:

code:
Función llamada: OnWndTestEvent_CtrlClicked
Error: Ruta de acceso no encontrada (código: -2146828212).
       Fichero: Window Test.js. Línea: 24.
La función OnWndTestEvent_CtrlClicked devolvió un error. Código: -2147352567


Is something like:
code:
Function Called: OnWndTestEvent_CtrlClicked
Error: Path not found (código: -2146828212).
File: Window Test.js. Línea: 24.
funtion OnWndTestEvent_CtrlClicked returned an error. Code: -2147352567


I know the error is about the path not existing.

How can I create a directory from "run"?
RE: Help With PlusWnd.GetControlText by matty on 06-06-2007 at 06:16 PM

Why dont you post all the code you have I will correct it and repost it. Just zip it all up.


RE: RE: Help With PlusWnd.GetControlText by vikke on 06-06-2007 at 06:48 PM

You can use the FileSystemObject, as you call oFSO in order to create files/folders. Here you can find documentation for FSO:
http://www.tutorial-web.com/asp/fso/

But if you want to do this from "run", use the windows program called MD, which stands for make directory, but that would just do you a lot of problems (CurrentDirectory etc!).

quote:
Originally posted by Matty
Why dont you post all the code you have I will correct it and repost it. Just zip it all up.

Because he wants to learn.
RE: Help With PlusWnd.GetControlText by Volv on 06-07-2007 at 01:36 AM

The problem is that you can't copy the file to a directory which doesn't exist. You either have to create the directory through the script as vikke suggested or create it manually - creating manually is a decent method and saves effort if the directory is in the actual script's directory (ie. it will be included with the script package).


RE: Help With PlusWnd.GetControlText by matty on 06-07-2007 at 02:12 AM

Just use the API MakeSureDirectoryPathExists from the imagehlp.dll library.

It accepts one parameter, the path. The path has to have a trailing \ to be successful. This function will create any directories needed.

Example:

code:
Interop.Call('imagehlp.dll', 'MakeSureDirectoryPathExists', 'C:\\this\\is\\a\\path\\to\\be\\created\\');


http://msdn2.microsoft.com/en-us/library/ms680352.aspx
RE: Help With PlusWnd.GetControlText by pedro_cesar on 06-07-2007 at 05:23 PM

Thanks vikke for that great link, I'm getting my hands on it now, I hope it helps with what I need, yet I found so usefull I put it in my favorites :D


RE: Help With PlusWnd.GetControlText by saralk on 06-07-2007 at 08:25 PM

not to rain on your parade, but isn't there a DP stealer built into plus already?


RE: Help With PlusWnd.GetControlText by Volv on 06-08-2007 at 01:57 AM

quote:
Originally posted by saralk
not to rain on your parade, but isn't there a DP stealer built into plus already?
Umm... no?
But there have been quite a few released scripts which have DP-stealing capabilities (found in the Mockers and Content Stealing category of the scripts database).
RE: Help With PlusWnd.GetControlText by pedro_cesar on 06-09-2007 at 11:51 AM

The Cex Clone 1.0 on the Mockers and Content Stealing is mine, and I'm trying to make it better, that's why I'm posting all this.


RE: RE: Help With PlusWnd.GetControlText by vikke on 06-09-2007 at 12:51 PM

quote:
Originally posted by saralk
not to rain on your parade, but isn't there a DP stealer built into plus already?

There is a feature which enables you to save contacts DP into a png whereever you want on the harddrive.
To do this, in your conversation, goto Plus!->Contact Information, then click Save "Display Picture".
RE: Help With PlusWnd.GetControlText by pedro_cesar on 06-10-2007 at 09:50 PM

I, for example. woud have to do that for 450 times. The Script is for all -loaded- Dps on your contact list. Besides the script does other things too.