Messenger Plus! Live Forums » Messenger Plus! Live Extension » Scripting » Interface Writer | [release] 2.0 | 07/11/2009

Pages: (6): « First [ 1 ] 2 3 4 5 » Last » Reply 
Interface Writer | [release] 2.0 | 07/11/2009
Author: Message:
whiz
Full Member
***

Avatar
Currently... scripting.

Posts: 160
– / Male / Flag
Joined: Nov 2008
Grin  Interface Writer | [release] 2.0 | 07/11/2009
Features
  • basically, it writes windows for you :P
  • can be saved as an XML file, or a copy/paste compatible source code
  • load existing interfaces and edit them
  • unlimited windows, controls and elements
  • user-friendly - just double-click to add or edit windows or controls
  • full validation of file paths, window IDs and control IDs
  • hide the writer windows temporarily using the hide option

New in this Version
  • added: ability to load existing interface XML files, with validation :D
  • added: element manager
  • changed: complete internal workings (data is stored in one main object now)
  • changed: unnecessary packed resources (removed images already available in Plus!)
  • fixed: save bug that returned "permission denied" - wasn't closing files properly

Screenshot (click to enlarge)
[Image: windowsm.png]

.plsc File Attachment: Interface Writer.plsc (37.44 KB)
This file has been downloaded 12 time(s).

This post was edited on 11-07-2009 at 01:50 PM by whiz.
05-25-2009 02:55 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Contest Winner
Beta Tester
*****


Posts: 6538
Reputation: 104
24 / Male / Flag
Joined: Dec 2002
RE: BETA - Interface Writer 1.0!
FnSaveMethods.js:

function SaveInterface() {}

Javascript code:
var TextFile = FileSO.OpenTextFile(FilePath, 2);

Should be:
Javascript code:
var TextFile = FileSO.OpenTextFile(FilePath, 2, true, -1 /*UNICODE*/);

05-25-2009 03:16 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Elite Member
*****

Avatar
x'; DROP TABLE members;

Posts: 2902
Reputation: 57
21 / Male / Flag
Joined: Aug 2006
RE: BETA - Interface Writer 1.0!
quote:
Originally posted by whiz
Known Issues
no validation of numbers (for example, it will allow "text" as a valid height measurement)
no validation of matching ID's (for example, two controls with the name "EdtTest")

If you need help with these, PM me and I will help ;)
05-25-2009 03:26 PM
Profile E-Mail PM Web Find Quote Report
whiz
Full Member
***

Avatar
Currently... scripting.

Posts: 160
– / Male / Flag
Joined: Nov 2008
RE: Interface Writer | [beta] 1.0
quote:
Originally posted by matty

FnSaveMethods.js:

function SaveInterface() {}

Javascript code:
var TextFile = FileSO.OpenTextFile(FilePath, 2);

Should be:
Javascript code:
var TextFile = FileSO.OpenTextFile(FilePath, 2, true, -1 /*UNICODE*/);



Thanks for that.  I've fixed it, and I'll re-upload it in a moment...



quote:
Originally posted by Spunky
quote:
Originally posted by whiz
Known Issues
no validation of numbers (for example, it will allow "text" as a valid height measurement)
no validation of matching ID's (for example, two controls with the name "EdtTest")

If you need help with these, PM me and I will help ;)

I can probably do the first one, but I'm not sure about the second.  Would something like this work:

Javascript code:
for (var X in WndLstId)
{
    if (!objWnd.GetControlText("EdtId") == WndLstId[X])
    {
        // save code here...
    }
}


EDIT: actually, I've changed my mind.  I don't think I can do the first one either.  ;)

This post was edited on 06-14-2009 at 02:29 PM by whiz.
05-25-2009 03:31 PM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
Beta Tester
*****

Avatar
Script Developer and Helper

Posts: 1475
Reputation: 36
17 / Male / Flag
Joined: Apr 2004
RE: BETA - Interface Writer 1.0!
Those issues aren't that hard to solve! :P
  • Validation of numbers (for example, it will allow "text" as a valid height measurement)
    Javascript code:
    var sFoo = "85.1";
    var nFoo = 1 * sFoo; //Attempt a string to number conversion
    if( isNaN(nFoo) ) nFoo = 0; //Failed, set to some default value or ignore the declaration

  • Validation of matching IDs (for example, two controls with the name "EdtTest")
    Javascript code:
    var sTestId = "BtnTest"; //Control ID to test
    var bIsUniqueId = true; //Boolean to hold the result
     
    for( var i in WndLstId ) { //Loop through the control IDs
        if( WndLstId[i] == sTestId ) { //Check if this control ID matches the test ID
            //We have a match!
            bIsUniqueId = false; //Set the result to false
            break; //End the loop (we know it's not unique now)
        }
    }
    //Now make use of bIsUniqueId for further processing

... | Plus! Live Script Developer | Plus! Live Beta Tester | Creator of Countdown Live | Co-Developer of Screenshot Sender 5 | ...
[Image: signature.php]

Found my post useful? Rate me!
05-25-2009 04:02 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Elite Member
*****

Avatar
x'; DROP TABLE members;

Posts: 2902
Reputation: 57
21 / Male / Flag
Joined: Aug 2006
RE: BETA - Interface Writer 1.0!
quote:
Originally posted by Matti
Those issues aren't that hard to solve! :P
  • Validation of numbers (for example, it will allow "text" as a valid height measurement)
    Javascript code:
    var sFoo = "85.1";
    var nFoo = 1 * sFoo; //Attempt a string to number conversion
    if( isNaN(nFoo) ) nFoo = 0; //Failed, set to some default value or ignore the declaration

  • Validation of matching IDs (for example, two controls with the name "EdtTest")
    Javascript code:
    var sTestId = "BtnTest"; //Control ID to test
    var bIsUniqueId = true; //Boolean to hold the result
     
    for( var i in WndLstId ) { //Loop through the control IDs
        if( WndLstId[i] == sTestId ) { //Check if this control ID matches the test ID
            //We have a match!
            bIsUniqueId = false; //Set the result to false
            break; //End the loop (we know it's not unique now)
        }
    }
    //Now make use of bIsUniqueId for further processing




Has already sent a PM, but both solutions are very similar to mine so I feel a bit better now :D
05-25-2009 04:07 PM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
Beta Tester
*****

Avatar
Script Developer and Helper

Posts: 1475
Reputation: 36
17 / Male / Flag
Joined: Apr 2004
RE: BETA - Interface Writer 1.0!
quote:
Originally posted by Spunky
Has already sent a PM, but both solutions are very similar to mine so I feel a bit better now :D
Hah, great minds think alike! :D
... | Plus! Live Script Developer | Plus! Live Beta Tester | Creator of Countdown Live | Co-Developer of Screenshot Sender 5 | ...
[Image: signature.php]

Found my post useful? Rate me!
05-25-2009 04:11 PM
Profile E-Mail PM Web Find Quote Report
whiz
Full Member
***

Avatar
Currently... scripting.

Posts: 160
– / Male / Flag
Joined: Nov 2008
RE: Interface Writer | [beta] 1.0
The "Add Window/Control" validators work fine, but the "Change Window/Control" validators don't seem to recognise if the ID matches another window/control's ID - even though those bits use the same validation method...

Javascript code:
// works fine :)
function OnWndWriterAddWndEvent_EditTextChanged(objWnd, strControlId)
{
    if (objWnd.GetControlText("EdtId") == "" || objWnd.GetControlText("EdtTitle") == "" || objWnd.GetControlText("EdtWidth") == "" || objWnd.GetControlText("EdtHeight") == "")
    {
        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
    }
    else
    {
        if (isNaN (objWnd.GetControlText("EdtWidth") * 1) == true || isNaN (objWnd.GetControlText("EdtHeight")) == true)
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
        }
        else
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 1);
            for (var X in WndLstId)
            {
                if (WndLstId.length > 0 && objWnd.GetControlText("EdtId") == WndLstId[X])
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
                }
                else
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 1);
                }
            }
        }
    }
}
 
// gets it wrong :(
function OnWndWriterChangeWndEvent_EditTextChanged(objWnd, strControlId)
{
    if (objWnd.GetControlText("EdtId") == "" || objWnd.GetControlText("EdtTitle") == "" || objWnd.GetControlText("EdtWidth") == "" || objWnd.GetControlText("EdtHeight") == "")
    {
        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
    }
    else
    {
        if (isNaN (objWnd.GetControlText("EdtWidth") * 1) == true || isNaN (objWnd.GetControlText("EdtHeight")) == true)
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
        }
        else
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
            for (var X in WndLstId)
            {
                if (WndLstId.length > 1 && objWnd.GetControlText("EdtId") == WndLstId[X])
                {
                    if (objWnd.GetControlText("EdtId") == WndLstId[WndLstTStSel])
                    {
                        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
                    }
                    else
                    {
                        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
                    }
                }
                else
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
                }
            }
        }
    }
}
 
// works fine :)
function OnWndWriterAddControlEvent_EditTextChanged(objWnd, strControlId)
{
    if (objWnd.GetControlText("EdtId") == "" || objWnd.GetControlText("EdtLeft") == "" || objWnd.GetControlText("EdtDown") == "" || objWnd.GetControlText("EdtWidth") == "" || objWnd.GetControlText("EdtHeight") == "" || objWnd.Combo_GetCurSel("CmbType") == -1 || objWnd.Combo_GetCurSel("CmbType") == 0)
    {
        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
    }
    else
    {
        if (isNaN (objWnd.GetControlText("EdtLeft") * 1) == true || isNaN (objWnd.GetControlText("EdtDown") * 1) == true || isNaN (objWnd.GetControlText("EdtWidth") * 1) == true || isNaN (objWnd.GetControlText("EdtHeight")) == true)
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
        }
        else
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 1);
            for (var X in WndCtrlId[WndLstTStSel])
            {
                if (WndCtrlId[WndLstTStSel].length > 0 && objWnd.GetControlText("EdtId") == WndCtrlId[WndLstTStSel][X])
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
                }
                else
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 1);
                }
            }
        }
    }
}
 
// works fine :)
function OnWndWriterAddControlEvent_ComboSelChanged(objWnd, strControlId)
{
    if (objWnd.GetControlText("EdtId") == "" || objWnd.GetControlText("EdtLeft") == "" || objWnd.GetControlText("EdtDown") == "" || objWnd.GetControlText("EdtWidth") == "" || objWnd.GetControlText("EdtHeight") == "" || objWnd.Combo_GetCurSel("CmbType") == -1 || objWnd.Combo_GetCurSel("CmbType") == 0)
    {
        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
    }
    else
    {
        if (isNaN (objWnd.GetControlText("EdtLeft") * 1) == true || isNaN (objWnd.GetControlText("EdtDown") * 1) == true || isNaN (objWnd.GetControlText("EdtWidth") * 1) == true || isNaN (objWnd.GetControlText("EdtHeight")) == true)
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
        }
        else
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 1);
            for (var X in WndCtrlId[WndLstTStSel])
            {
                if (WndCtrlId[WndLstTStSel].length > 0 && objWnd.GetControlText("EdtId") == WndCtrlId[WndLstTStSel][X])
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
                }
                else
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 1);
                }
            }
        }
    }
}
 
// gets it wrong :(
function OnWndWriterChangeControlEvent_EditTextChanged(objWnd, strControlId)
{
    if (objWnd.GetControlText("EdtId") == "" || objWnd.GetControlText("EdtLeft") == "" || objWnd.GetControlText("EdtDown") == "" || objWnd.GetControlText("EdtWidth") == "" || objWnd.GetControlText("EdtHeight") == "" || objWnd.Combo_GetCurSel("CmbType") == -1 || objWnd.Combo_GetCurSel("CmbType") == 0)
    {
        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
    }
    else
    {
        if (isNaN (objWnd.GetControlText("EdtLeft") * 1) == true || isNaN (objWnd.GetControlText("EdtDown") * 1) == true || isNaN (objWnd.GetControlText("EdtWidth") * 1) == true || isNaN (objWnd.GetControlText("EdtHeight")) == true)
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
        }
        else
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
            for (var X in WndCtrlId[WndLstTStSel])
            {
                if (WndCtrlId[WndLstTStSel].length > 1 && objWnd.GetControlText("EdtId") == WndCtrlId[WndLstTStSel][X])
                {
                    if (objWnd.GetControlText("EdtId") == WndCtrlId[WndLstTStSel][WndCtrlTStSel])
                    {
                        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
                    }
                    else
                    {
                        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
                    }
                }
                else
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
                }
            }
        }
    }
}
 
// gets it wrong :(
function OnWndWriterChangeControlEvent_ComboSelChanged(objWnd, strControlId)
{
    if (objWnd.GetControlText("EdtId") == "" || objWnd.GetControlText("EdtLeft") == "" || objWnd.GetControlText("EdtDown") == "" || objWnd.GetControlText("EdtWidth") == "" || objWnd.GetControlText("EdtHeight") == "" || objWnd.Combo_GetCurSel("CmbType") == -1 || objWnd.Combo_GetCurSel("CmbType") == 0)
    {
        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
    }
    else
    {
        if (isNaN (objWnd.GetControlText("EdtLeft") * 1) == true || isNaN (objWnd.GetControlText("EdtDown") * 1) == true || isNaN (objWnd.GetControlText("EdtWidth") * 1) == true || isNaN (objWnd.GetControlText("EdtHeight")) == true)
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
        }
        else
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
            for (var X in WndCtrlId[WndLstTStSel])
            {
                if (WndCtrlId[WndLstTStSel].length > 1 && objWnd.GetControlText("EdtId") == WndCtrlId[WndLstTStSel][X])
                {
                    if (objWnd.GetControlText("EdtId") == WndCtrlId[WndLstTStSel][WndCtrlTStSel])
                    {
                        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
                    }
                    else
                    {
                        Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 0);
                    }
                }
                else
                {
                    Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), 1);
                }
            }
        }
    }
}
 


This post was edited on 06-14-2009 at 02:30 PM by whiz.
05-25-2009 05:15 PM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
Beta Tester
*****

Avatar
Script Developer and Helper

Posts: 1475
Reputation: 36
17 / Male / Flag
Joined: Apr 2004
RE: BETA - Interface Writer 1.0!
Well, you're not implementing our sample code properly. :P
You shouldn't re-enable the control when one item in the loop doesn't match the ID to test simply because you won't have all used IDs matching that one ID, you have to check whether there is at least one match.
Javascript code:
        if (isNaN (objWnd.GetControlText("EdtLeft") * 1) == true || isNaN (objWnd.GetControlText("EdtDown") * 1) == true || isNaN (objWnd.GetControlText("EdtWidth") * 1) == true || isNaN (objWnd.GetControlText("EdtHeight")) == true)
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
        }
        else
        {
            var bCanChange = true;            var sEdtId = objWnd.GetControlText("EdtId");            for (var X in WndLstId)
            {
                if (WndLstId.length > 1 && sEdtId == WndLstId[X] && X == WndLstTStSel)                    {
                        bCanChange = false;                        break;                    }
                }
            }
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), bCanChange);        }

As you can see, you don't need an else-block anywhere, you simply check three things:
  1. Check whether there are IDs in the array.
  2. Check whether the currently chosen test ID matches the key name of the current item in the loop.
  3. Check whether this item is currently being edited.
When these three conditions are fulfilled for one item in the loop, we can say that the chosen ID is not unique and thus bCanChange has to be set to false in order to disable the edit button.
When these conditions are never fulfilled, bCanChange will never change from its original value (true) and the button will be enabled.

Oh, on a side note: try to store some of the GetControlText calls in a variable inside your functions when you use them very often. It's good practice to take off the load of the API to get the control text every time and simply retrieve the value from a variable - the control text won't change anyway while executing the event function (and you don't want it to change either).
... | Plus! Live Script Developer | Plus! Live Beta Tester | Creator of Countdown Live | Co-Developer of Screenshot Sender 5 | ...
[Image: signature.php]

Found my post useful? Rate me!
05-25-2009 05:41 PM
Profile E-Mail PM Web Find Quote Report
vaccination
Posting Freak
*****

Avatar

Posts: 2452
Reputation: 43
17 / Male / –
Joined: Apr 2005
RE: BETA - Interface Writer 1.0!
...so no one's noticed that it fails at the first hurdle yet?

Script fails to create xml files.

code:
<-- Start file creation. -->
> Attempting to create file "C:\Users\vaccination\Desktop\Windows.xml"...
Error: Object expected (code: -2146823281)
       File: WndWriterCreateFile.js. Line: 70.
Function OnWndWriterCreateFileEvent_CtrlClicked returned an error. Code: -2147352567

Line 70 =
JScript code:
else if (FileC(objWnd.GetControlText("EdtPath") + "\\" + objWnd.GetControlText("EdtName") + ".xml", true))


..FileC doesn't exist...

----

Also, might want to read the corect folder from the registry, or at least use MsgPlus.ScriptFilesPath instead of just assuming it's "\Program Files\Plus!.." because it isn't always, for instance, on x64 machines.

There's a lot of other improvements you could make too, for instance instead of writing the xml to a text file and manually adding all the nodes with TextFile.WriteLine like you are, try using the XML DOM instead.

You should also include a preview feature to make the script actually useful, and should be relatively easy to add in.

Oh and you've used a few Plus! resources in your script - such as imgfind, imgsave, imgcode etc - and still included the files in the package, you could just call the resources directly from Plus!.

This post was edited on 05-25-2009 at 05:42 PM by vaccination.
[Image: jumbled.png]
05-25-2009 05:41 PM
Profile PM Web Find Quote Report
Pages: (6): « First [ 1 ] 2 3 4 5 » Last »
« Next Oldest Return to Top Next Newest »
Reply 


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