What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help With PlusWnd.GetControlText

Pages: (2): « First [ 1 ] 2 » Last »
Help With PlusWnd.GetControlText
Author: Message:
pedro_cesar
Junior Member
**

Avatar

Posts: 61
35 / Male / –
Joined: Dec 2006
Status: Away
O.P. Help With PlusWnd.GetControlText
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?
06-05-2007 04:39 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Help With PlusWnd.GetControlText
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;
}

This post was edited on 06-05-2007 at 04:53 PM by matty.
06-05-2007 04:45 PM
Profile E-Mail PM Find Quote Report
pedro_cesar
Junior Member
**

Avatar

Posts: 61
35 / Male / –
Joined: Dec 2006
Status: Away
O.P. RE: Help With PlusWnd.GetControlText
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?

This post was edited on 06-06-2007 at 04:03 PM by pedro_cesar.
06-06-2007 04:02 PM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Help With PlusWnd.GetControlText
Add a backslash! :D
code:
dir_path+"\\"+Contact.Email+".png"
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-06-2007 04:11 PM
Profile E-Mail PM Web Find Quote Report
pedro_cesar
Junior Member
**

Avatar

Posts: 61
35 / Male / –
Joined: Dec 2006
Status: Away
O.P. RE: Help With PlusWnd.GetControlText
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"?

This post was edited on 06-06-2007 at 05:23 PM by pedro_cesar.
06-06-2007 05:05 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Help With PlusWnd.GetControlText
Why dont you post all the code you have I will correct it and repost it. Just zip it all up.
06-06-2007 06:16 PM
Profile E-Mail PM Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: RE: Help With PlusWnd.GetControlText
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.
4 8 15 16 23 42
06-06-2007 06:48 PM
Profile E-Mail PM Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
34 / Male / Flag
Joined: Oct 2004
RE: Help With PlusWnd.GetControlText
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).
06-07-2007 01:36 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Help With PlusWnd.GetControlText
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

This post was edited on 06-07-2007 at 12:12 PM by matty.
06-07-2007 02:12 AM
Profile E-Mail PM Find Quote Report
pedro_cesar
Junior Member
**

Avatar

Posts: 61
35 / Male / –
Joined: Dec 2006
Status: Away
O.P. RE: Help With PlusWnd.GetControlText
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
06-07-2007 05:23 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On