Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #10952
    Stefan
    Participant

     
    For my scripts I always have the wish to be able
    to create better dialogs then alert and input ;-)

    One way could be to utilize http protocol to show
    a web page and get back the inserted results and clicked options.

    I have seen that this works well with another application.
    (XYplorer file manager, credits to Donald)

    Here is how it goes, maybe that would be a nifty idea for EmEditor too?

    The key trick here is the EmEditor own ‘EEM:’ protocol:

    OR

    Link One

    The new command would be something like this:
    editor.htmldialog(html code, [width=720], [height=500], [caption=EmEditor]);

    An macro would looks like:


    Result = htmldialog(
    '<HTML>
    <BODY>
    <FORM method="GET" action="EEM:">
    <a href="EEM: LinkOne">Link One</a><BR>
    <TEXTAREA name="FormResult" rows=15 cols=75>textareacontent</TEXTAREA><BR>
    <INPUT type="radio" name="myOption" value="1"> Option 1
    First name: <input type="text" name="fname" size="6" Value="John">
    <INPUT type="submit" name="Submit" value="OK" >
    </FORM>
    </BODY>
    </HTML>'
    ,"700", "530", "myWindowsTitle"
    );

    Explanation:

    This will show a normal web page with HTML code we have created above.
    The user can fill out the form as with any web page.
    All elements are provided: text area, check boxes, radio buttons, links, buttons,…

    Get the results:

    IF you press the [Close]-button of the dialog
    instead of the [Submit]-button of the form or on an link,
    then the result of HTML() is empty/nothing:

    IF an link is clicked jump to an sub:
    IF (Result == “LinkOne”) { LinkOnePressed();}

    IF Submit is clicked we get the form results back:
    Result is something like ‘?option=value&option=value&option=value’
    Here e.g. ‘FormResult=textareacontent&myOption=1&fname=John&Submit=OK’

    Process the results:

    Next we add code to the macro to split Result into parts at the ‘&’ sign:
    Res1 = “FormResult=textareacontent”
    Res2 = “myOption=1”
    Res3 = “fname=John”
    Res4 = “Submit=OK”

    Then we add code to split those parts into smaller parts at the ‘=’ sign:
    Res1a = “FormResult”
    Res1b = “textareacontent”
    Res2a = “myOption”
    Res2b = “1”

    Now do what you want with this results:
    alert( “Content of the textarea is: ” +Res1b + “nOption is: ” + Res2b + “nFirst name: ” +Res3b );

    .

    #11044
    Stefan
    Participant

    Hi Yutaka,

    have you think about a way to implement
    such GUI-features to the macro language?

    Mostly I need the possibility to show
    a dialog with a few check boxes, radio buttons
    and input/edit fields. Maybe drop-down list too.

    Then I want to get back what the user has entered/selected
    and work on that information to further execute my code.

    I have seen that possibility in some ways already
    and if you need some ideas/inspirations please let my know.

    But please be more communicative and talk with your usership
    to let them know what you think and if the suggestion have
    a change to get implemented or not.

    It’s not that nice to have monologues mostly ;-)

    Join the chat.

    Thank You
    Stefan

     

    #11045
    Yutaka Emura
    Keymaster

    Hello,

    I am very sorry for late responses.

    I don’t want to add too many features because they might make EmEditor bloated, and it will become harder to maintain in the future.

    I heard you can add dialog boxes using COM object such as SeraphyScriptDialog http://sourceforge.jp/projects/seraphyscrtools/ There might be other similar COM objects.

    However, I will think about adding more GUI interfaces.

    Thanks!

    #11048
    Stefan
    Participant

    Yutaka wrote:
    Hello,

    I am very sorry for late responses.

    Thanks for feedback.

    Yutaka wrote:

    I heard you can add dialog boxes using COM object
    such as SeraphyScriptDialog

    That functions are exactly what I have searched for for years.

    Many thanks for that link.
    I have never found something like that.

    Unfortunately it seams some parts are hard coded in japanisch language ( see browse folder button and the path delimiter Y )

    Also since I have to register the com object it is not fully portable. But I guess that de-/registering can be done by a script too.

    Only it is not that nifty to share script with others if they have to register a dll first. Also they need admin rights.

    And I have not found any help in english language till now.

    I have to experiment a bit with that.

    Thank you much!

    .

    #11057
    Stefan
    Participant

    Basically it works!

    #language = "VBScript"
    set obj = CreateObject("SeraphyScriptDialog")
    set frm = obj.CreateForm()
    frm.FormTitle = "Modify Lines"
    i1 = frm.DefineLabel("For every line")
    i2 = frm.DefineEdit("Prefix Lines: ")
    i4 = frm.DefineEdit("Append Lines: ")
    i12 = frm.DefineButton("OK;CANCEL")
    'OK= return code 3
    'Cancel = return code 4
    ret = 0
    do
    ret = frm.ExecuteForm()
    loop while(ret = 0)
    if(ret=3) Then
    '//Insert in front of selected lines
    Leader = frm.Value(i2)
    document.selection.Replace "^",Leader, eeReplaceSelOnly or eeReplaceAll or eeFindReplaceRegExp
    '//Insert to the end of selected lines
    Trailer = frm.Value(i4)
    document.selection.Replace "$",Trailer, eeReplaceSelOnly or eeReplaceAll or eeFindReplaceRegExp
    end if

    Note:
    SeraphyScriptDialog.dll
    or
    SeraphyScriptDialogx64.dll
    have to be reistered as COM before.

    Works on Win7 64-bit for me.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.