Author Topic: Idea collecting thread: Scripting / Macro  (Read 15945 times)

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Idea collecting thread: Scripting / Macro
« on: April 21, 2009, 08:15:26 pm »
Scripting support is coming

To help Alex implementing scripting, i start this thread to collect ideas. (See >here< for the current state of implementing)

This is not to implement as many features as possible right now to have an monster next week,
but to take the change to THINK at all possibilities BEFORE Alex start coding the engine.

Because to add something later if the core work is done
would be much more heavy then letting an room NOW  for implementing things LATER.


I think I would change priorities for 1.50, and scripting and macro recording would come inside (together with plugin support).

For scripting, I was planning to use Windows Active Scripting which has a lot of scripting engines available (in addition to standard Java and VB script). Then, to no introduce just another micro language for macros, idea was to generate primitive script, when you run macro recorder, which for example contains only keystrokes. Something like:
ExecuteCommand(52436);
ExecuteCommand(52437);
ExecuteCommand(52037);

and so on.

First, this is reuse of the exisitng engine, second you can easy extend generated script after that...



the name "Active Scripting" is an marketing product of Microsoft and includes, among others,
WSH (Windows Script Host) as engine where you can script with VBS and many other languages     >Read more...<
« Last Edit: October 07, 2009, 07:23:52 pm by Stefan »
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting thread: Scripting / Macro
« Reply #1 on: April 21, 2009, 08:20:13 pm »
Some first thought:



topic 1
  • Let macro AND scripting share the same keywords and maybe syntax too

     I mean i want to do an quick macro and usse this as basic for an script (like with Excel)
  • Record typing only or mouse&typing

-

topic 2
  • Also there should be no difference in file handling and menu.

     An macro is an script / an script is an macro


topic 3
  •  if possible let's create the macro/script code in an document tab

      instead of providing an separate dialog

topic 4
  • we need the side panel to have an list of available macro commands

      or at least an button to open the help file

topic 5
  •  just store every single macro as single file in HE sub-folder Macros
  •  The file name is taken as macro name in the menu.
  •  The sub-folder of Macros folder could be used to build the menu.
  •  Each macro file has an ID to identify  it for shortcut (ID stored in first line or as last part of file name?)

       f.ex.:  parse script for line like:   #HE.ID#2009.04.23.001
      Or let simple choose the script file to assign an shortcut to?
-


topic 6
to run an script there could be differnet ways
  • run from menu /context menu
  • execute by shortcut
  • execute last used/recorded macro  with an default shortcut (every time the same,

   without the need to save macro first)
  • execute by run file... (open file dialog with HE's macro folder)
  • execute current opened script
  • as tool and as tools argument
  • execute as code template
  • run as event (cursor move, char or word inserted, new file, new tab, tab closed,

     on save, on HE start or end,...)
-

topic 7
Macro menu
  • record/stop macro
  • Execute last recorded/used macro one time (Alt+F5)
  • Manage macro  > like tools dialog  

    (list of macros ,order, set shortcut, rename, open for edit, new, execute, on event,  debug,...)
    (run macro one time ,  
      n times,
      Till end of file
      on selection only
      every second till ESC
       on current tab, chose an tab,  on all open tab, %OpenFilesInteractive%,
       on folder with file type xyz, on folderS )
  • Last used ten macros

    0:  macro 1
    1:  macro2
    2:  macro3
    3:  ...

I must say NP++ have this thingy fine implemented:
* Start Rec
* Stop Rec
* Execute current (and add an shortcut)
* Execute Multiple Times... (current or select an macro) (n-times, till EOF, i would add "for selection" too)
* Save current recorded

Above all i like the part to save the macro afterwards,... if i want to only.
I don't like the MS W0rd way...  to enter an macro name each time you recored one... even you need it one time only.
To enter/save an macro only if you really want to store it is nicer i think.... (depends how you will work/your habit of course)

An idea could be to prompt the user - after he selected to stop the recording - to save the macro.
If the user press cancel the macro is not saved but stored as current/temporary macro.


topic 8
Debugging
  • For an start there could be an option to enable debugging

      which could open an new tab with some standard output , inclusive vars and there current content.
  • Later there could be an option to execute macro step-by-step, line-by-line

-


topic 9
Build-in an break event ,
perhaps by pressing shortcut key or click an button,
or maybe by providing an timer that each script chancel after n minutes, if enabled,
to help users having made an infinity loop  by mistake :D


topic 10
Let us store vars in HE config to have them even after HE restart.

F.ex.:  
g_VarCounter = g_VarCounter + i

Next time i would use this var i want to read the last amount.

or f.ex.
g_VarLastUsedDoc = "c:\report_log_2.txt"
-


topic 11  23.04
Parse the script containing folder for valid script-file-extensions ONLY
and don't try to load extensions like txt or bak or such.
So we can disable files and have examples or not yet finished scripts or docus in this folder.
(i know other editors who give error messages because of un-valid scripts (which are not scripts after all) and we had to store such files in an other folder was was not handy (IMHO oc) )



topic 12  23.04
Maybe each script should have an meta line for an description which could be used later to show in an tool tip.
f.ex.
#HE.Description#"Scirpt to find and delete lines longer then 64 chars"

Script meta tags
<script comment sign>#HE.ID#2009.04.23.001#/#
<script comment sign>#HE.ToolTip#"Script to sort numbers (First select some lines)"#/#
<script comment sign>#HE.MenuName#"Sort script 3"#/#
<script comment sign>#HE.Description#"Script to sort numbers, version 3"#/#
---


topic 13  24.04
- option to include other scripts
#HE.include#"..\VBSfunc\sort.vbs"#/#

- option to call other scrips by relative path
IF True Then
  HE.call .\1.vbs
Else
  HE.call .\2.vbs, wait
End If
---


.
-
« Last Edit: September 27, 2009, 12:51:31 am by Stefan »

Offline Arthur

  • Registered User
  • Hero Member
  • *
  • Posts: 653
  • Karma: +1/-0
  • He who is ashamed of asking is afraid of learning.
    • View Profile
    • My Blog
Re: Idea collecting thread: Scripting / Macro
« Reply #2 on: April 21, 2009, 08:26:09 pm »
IMHO, the road-map is:

1) Add a new folder called HEScripts, perhaps the scripts need extension .hes;
2) Phase one - macro recording of basic commands, e.g. menu items (cut+paste, move, type, etc.);
3) Ability to save user scripts under a new menu item called Macros; I think users of this forum can publish and exchange scripts;
4) A quick-jump to edit the macros, I wish they would be VBScript based (easy to extend, most people are familiar and there is a ton of examples).
5) Phase two - interface with the OS e.g. for writing to a file, opening URLs, publishing to Blog, Twitter, Identica, buy Alex a present [kidding]  ;)etc.

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2181
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Idea collecting thread: Scripting / Macro
« Reply #3 on: April 22, 2009, 10:19:46 pm »
Hello Stefan,

thanks a lot for your help!

If you would like to help, let keep you second post as base for specification, and modify it based on feedback you would collect.

And some feedback form my side (this what I see now, maybe later would be some other points):
  • topics 1 - 3, accepted
  • prerequisite for topic 4 - plugin infrustucture, as minimum can be done simple completion, based on some syntax schema with list of HE methods
  • topic 5, from my point of view, is no detailed checked. Maybe it looks like correct solution from first look, but now think: you need and ID, where to save shortcut, if you need some other properties, script files can be written in different programming languages, so you need special handling for storing something inside of script (it should be done as comment to not be recognized by engine). So, what I want to say. You any way need external storage, so the correct way, and similar to the rest would be handling of the scripts as special tools (with another properties), and reuse already existing managment. Then you can assign script for special synatx or for all, have shortcut, toolbar, menu etc. All parameters would be stored in user files, and independent from script, if you share the script, any user can have his own id for script (which is script path), can organize as he like in tree structure etc.
  • topics 6 - accepted
  • topics 7:
    Quote
    Manage macro  > like tools dialog 
        (list of macros ,order, set shortcut, rename, open for edit, new, execute, on event,  debug,...)
        (run macro one time ,  n times,
           on current tab, chose an tab,  on all open tab, %OpenFilesInteractive%,
           on folder with file type xyz, on folderS )
    This is non needed if macros are scripts, and scripts handled as tools. Tools management used.

    Quote
    Last used ten macros
    I do not think that user would have so many macros that he would have a problem to find them. this can be solved using submenu and moving manually most frequently used scripts on top. But this can be checked later.
  • topics 8, debugging is good. But you coud not debug yourself. So, it can be only possible to debug script running in another instance of HE. maybe. But this can be verified later.
  • topics 9, Maybe. But you always have possibility to stop infinate loop - Ctrl+Alt+Del ;)
  • topics 10, Do not know is this possible or not to automatically initialize variables in script. But definitly can be possible to query HE application for it
  • In addition should be taken into account that script can be in any language: javascript, vbscript, lua, perl, python etc. There are a lot of alternative engines for Active Scripting
  • Also would be good if you would collect best examples of implementation in other editors, that we can check wat is possible where, UI solutions etc. Maybe screenshots ;)
  • And of course these are really huge requirements for first version. So priorities should be set.

Just want to add that I am not expert in scripting at all, so I have very brief knowledge about what can be possible and what is needed. So your help is really valuable.

Offline Arthur

  • Registered User
  • Hero Member
  • *
  • Posts: 653
  • Karma: +1/-0
  • He who is ashamed of asking is afraid of learning.
    • View Profile
    • My Blog
Re: Idea collecting thread: Scripting / Macro
« Reply #4 on: April 23, 2009, 04:32:42 am »
I personally like how the macros are done in MS Office products (VBA Functions), also I am thinking most people will be familiar with this concept.
In VB you can already do things as sending keys to simulate buttons pressed, work with the file system via FSO, the script gets controlled via WScript e.g. to display messages, abort execution etc. Normally if IE is installed all of the above is immediately available.
« Last Edit: April 23, 2009, 04:41:16 am by Arthur »

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting thread: Scripting / Macro
« Reply #5 on: April 23, 2009, 07:36:37 am »
Hi Arthur,

the name "Active Scripting" is an marketing product of Microsoft
and includes among others WSH (Windows Script Host) as engine where you can script with VBS    >Read more...<

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting thread: Scripting / Macro
« Reply #6 on: April 23, 2009, 07:49:14 am »
    ...let keep you second post as base for specification, and modify it based on feedback you would collect.
    of course

    Quote
    • topics 10, Do not know is this possible or not to automatically initialize variables in script.
    I don't mean automatically,  i just meant give us the option to store vars for to reuse after HE restart.
    HE.StoreVar(intCount)
    myCounter = HE.LoadVar(intCount)
    EDIT: changed my mind,  this could be done whit script commands via  FSO. anyway.
             (i think this feature wish came from time using proprietary scripting languages which had no "FSO" at all :D )


    Quote
    • Also would be good if you would collect best examples of implementation in other editors,
      that we can check what is possible where, UI solutions etc. Maybe screenshots ;)
    of course, already half way done

    Quote
    • And of course these are really huge requirements for first version. So priorities should be set.
    So hear coders! What should be first?[/list]
    « Last Edit: April 23, 2009, 08:15:48 am by Stefan »

    Offline Arthur

    • Registered User
    • Hero Member
    • *
    • Posts: 653
    • Karma: +1/-0
    • He who is ashamed of asking is afraid of learning.
      • View Profile
      • My Blog
    Re: Idea collecting thread: Scripting / Macro
    « Reply #7 on: April 23, 2009, 02:59:40 pm »
    A simplistic macro engine is a good start IMHO, then let's see what the user community is saying.

    Offline Stefan

    • Administrator
    • Hero Member
    • *****
    • Posts: 775
    • Karma: +6/-0
      • View Profile
    Re: Idea collecting thread: Scripting / Macro
    « Reply #8 on: April 23, 2009, 03:56:04 pm »
    Hi Arthur,

    A simplistic macro engine is a good start IMHO, then let's see what the user community is saying.

    What is  "simplistic"  in your opinions?   

    (besides  i  imaging this what you mean is called just  "simple")
    What is  a "simple macro engine"  in your opinions?   
    I mean what do you expect  exactly at first step of implementation?

    Offline Arthur

    • Registered User
    • Hero Member
    • *
    • Posts: 653
    • Karma: +1/-0
    • He who is ashamed of asking is afraid of learning.
      • View Profile
      • My Blog
    Re: Idea collecting thread: Scripting / Macro
    « Reply #9 on: April 23, 2009, 05:24:10 pm »
    Under "simplistic" I meant the ability to execute previously recorded

    a) keystrokes;
    b) cursor movements;
    c) menu commands (Ctl-Copy/Paste, Find/Replace, etc.)

    I hope I am not asking for too much.
    The way it is done in MS Office products I think is optimal, but may not necessarily has to be as complete in HippoEdit, just let's start right the first time thinking about future expansion.

    allen

    • Guest
    Re: Idea collecting thread: Scripting / Macro
    « Reply #10 on: April 25, 2009, 03:12:50 pm »
    A simplistic macro engine, to me, is the ability to record mouse/keyboard action then replay it. Maybe even save it in a format that is sufficiently readable to open and manually tweak. That's something that should be present, most editors do support this.

    The two applications that stand out in my mind as well done Macro implementations are XYPlorer (file manager) and Boxer (text editor).  Full access to all built in commands/features and the ability to work with them programatically via their scripting language.

    Alex's Active Scripting approach sounds good -- built in support for multiple scripting languages to make the user comfortable and Alex doesn't have to write the actual scripting language himself.

    Offline Stefan

    • Administrator
    • Hero Member
    • *****
    • Posts: 775
    • Karma: +6/-0
      • View Profile
    Re: Idea collecting thread: Scripting / Macro
    « Reply #11 on: April 27, 2009, 07:35:29 pm »
    Yes, Boxer has an good macro/scripting support IMHO.

    ++ = i think this is good
    -- = i think there is room for improvement

    -----------------------------------------------------------------------------------

    ++ There is F5 shortcut always for the recent macro
    -- there is no "run n times" option

    ++ You can save "Key recording" (i would call it macro)  and  use this as basic for Macros (i would call it scripting)

    -- There is an extra dialog which is always in front (modal),
    -- that means you can't test your script before you have close this dialog.
    -- So you have to open this dialog - modify your script - close the dialog - test your script - open the dialog -......... :-(

    ++ But in this dialog you have an list of all macros (2)
    ++ An list, sorted into several categories, with all commands including short description (3)
    ++ Also there is an integrated debugging tool (4), where you can execute step-by-step and view the contents of variables

    -- There is an limited support to add an shortcut to an macro (because you have to rename the macro file
    -- and add one number from 1 till 50 at the end, then you can choose f.ex. "Run Macro 23" and add then an shortcut)


    -- the macro syntax is an c-style
    -- there are no further (self-created) sub-menus  for the "Tools > Run Macros" sub-menu (1),
    so you have to scroll your hundred macros up-and-down

    __
    « Last Edit: April 27, 2009, 07:39:38 pm by Stefan »

    Offline Stefan

    • Administrator
    • Hero Member
    • *****
    • Posts: 775
    • Karma: +6/-0
      • View Profile
    Re: Idea collecting thread: Scripting / Macro
    « Reply #12 on: April 27, 2009, 08:03:14 pm »
    PSPad have an simple macro/scripting support IMHO.
    PSPad use WSH with VBS + JS too.


    ++ = i think this is good
    -- = i think there is room for improvement

    ----------------------------------------------

    + PSPad has an keystroke and menu-use only recording (no mouse recording) (1)
    + PSPad has an default Key F5 to execute last macro
    + you can chose to execute an macro n-times
    --+ you can use macro recording as basic for an script, but you have to modify the syntax

    + For PSPad scripts you just write an script and save it in an folder where PSPad will find it (2)
    + The shortcut you would add directly inside the script ("Ctrl+Alt+F")
    + also the menu item name (/ Replace",), including sub-menu, ("Multiline Search / ) is written to the script itself


    Sub Init
      addMenuItem "Multiline Search / Replace", "", "phReplace", "Ctrl+Alt+F"
    End Sub

    ---------------

    + For 'code templates' (but not for macros) there is an nice feature to build dialogs on your one (3)

    Would be nice to have something like this to build our own dialog boxes.


    Code: [Select]
    %control%[email protected] caption,text,default,options,delimiter,dialog_type 
     
     %control% The name used in the clip body.
     @x    Type of control. One of 
        @-- = Separator 
        @C = Combo box 
        @D = Date dialog 
        @E = Text box 
       @F = Font selection dialog 
       @K = Checkbox 
       @L = Colour picker dialog 
       @O = File Open dialog 
       @P = Picture selection dialog 
       @S = Directory selection dialog 
       @T = Topstyle 
     
         See below for further details. 
     
     caption     This text will appear as a label for the control in the dialog. 
     text          Optional fixed text that will be inserted into your file immediately the value you enter in to the control. 
     default     The default value. This value will be used if you don't enter a value of your own in to the control. (optional) 
     options     Depends on the control used, see below (optional). 
     delimiter   These optional Characters will be inserted around value entered into the control (optional).

     dialog_type   Only used when @x = @O (optional). One of:   
          A = Absolute path and slash type, or   
          R = Relative path and slash type   
      If this value is blank then and the file being edited is an HTML file then the path returned
    by the control will be relative to the file's path and the path delimiters will be slashes (/).
    Otherwise the path returned will be absolute and will use backslashes (\). 


    -----------
    « Last Edit: April 27, 2009, 08:23:16 pm by Stefan »

    Offline Stefan

    • Administrator
    • Hero Member
    • *****
    • Posts: 775
    • Karma: +6/-0
      • View Profile
    Re: Idea collecting thread: Scripting / Macro
    « Reply #13 on: April 27, 2009, 08:37:38 pm »
    possible road map ?


    Basics - Macros:
    - default key (F5) to start/stop recording
    - record cursor movement and menu actions
    - default key (F6)  to execute last macro
    - save macro
    - load macro to execute with default key
    - option to set multiplier (run n-times)
    - maybe menu with last used ten macros


    Next Step - Scripting
    - provide editor related commands to use with WSH scripting
    - same options as for macros above



    Next:
    - scripting menu like tools menu
    - own shortcuts for each  script
    - execute current open script  (need to chose tab to execute to)
    - provide scripting commands with description in side panel


    Next:
    - provide own dialog boxes  instead of MsgBox/InputBox
    - execute script to multiple files

    Advantage:
    - debuging, step-by-step, content of vars
    - write help file
    - run on events


    ___ still thinking about this  ::)
    « Last Edit: May 04, 2009, 07:57:09 am by Stefan »

    Offline alex

    • Developer
    • Global Moderator
    • Hero Member
    • *****
    • Posts: 2181
    • Karma: +37/-3
      • View Profile
      • HippoEDIT
    Re: Idea collecting thread: Scripting / Macro
    « Reply #14 on: April 28, 2009, 12:17:36 am »
    Hi Stefan,

    thanks a lot for very good review, comparison and finding pros and cons.

    Still I think defining of names or shortcuts from script itself bad idea ;)

    Thanks also for priority list (road map). I need to know what is needed more (as I thought debugger is not a most important, Uh.. :) ).

    Would use your post as a spec. Maybe would start to do something (in 1.50) in several weeks. First, need to find all bugs reported after Bits du Jour and do updates on web site. This is already long time in a queue.

    Thanks a lot for your help!

    Best regards,
    Alex.


     

    Related Topics

      Subject / Started by Replies Last post
    7 Replies
    7267 Views
    Last post July 26, 2009, 10:40:08 pm
    by alex
    15 Replies
    11221 Views
    Last post April 21, 2009, 11:27:55 am
    by Stefan
    18 Replies
    8635 Views
    Last post June 17, 2016, 11:09:59 pm
    by alex
    1 Replies
    1621 Views
    Last post October 25, 2009, 11:05:59 pm
    by alex
    0 Replies
    2137 Views
    Last post February 29, 2012, 09:56:26 pm
    by alex