HippoEDIT homepage Welcome, Guest. Please login or register.
September 07, 2010, 08:18:23 am
Home Help Search Login Register

+  HippoEDIT - Programmers text editor
|-+  General Category
| |-+  Scripting, Scripts and Macros (Moderators: alex, Stefan)
| | |-+  Idea collecting thread: Scripting / Macro
« previous next »
Pages: 1 [2] 3 Print
Author Topic: Idea collecting thread: Scripting / Macro  (Read 4691 times)
Arthur
Hero Member
*****

Karma: +1/-0
Offline Offline

Gender: Male
Posts: 597


He who is ashamed of asking is afraid of learning.


View Profile WWW
« Reply #15 on: April 28, 2009, 08:58:41 pm »

Just FYI:

EmEditor Professional 9.00 is coming soon!

... One of the new features of EmEditor v9.00 is dynamic snippets  Shocked. The Snippets plug-in was significantly improved to support dynamic snippets including macros, shell code, placeholders, regular expressions to transform, and other features. The default snippets tree contains many useful snippets; some of them are imported from the TextMate repository. Please see our new screencast showing how the new Snippets plug-in works!
Logged
JJK
Full Member
***

Karma: +2/-0
Offline Offline

Posts: 145



View Profile
« Reply #16 on: May 03, 2009, 09:22:55 pm »

1) EmEditor has also a nice macro system, it seems to me.
2) I like VBA system.




I am sorry JJK, i modify your post by accident  :'(
Stefan
« Last Edit: May 03, 2009, 09:50:14 pm by Stefan » Logged
Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #17 on: May 03, 2009, 09:49:50 pm »

Thanks for contribution JJ.

> 1) EmEditor has also a nice macro system, it seems to me.
What is the good on EmEditor macro support? Which part did you like to see in HE too?
The only advantage i see is:
- record activities to other apps too
- record mouse movement too
- run as event


> 2) I like VBA system.
Fine.
What do you mean by saying this? 
(You know that VBA is an brother of VBS and VBS is part of active scripting which Alex want to use as scripting engine?)
Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #18 on: June 04, 2009, 09:46:31 pm »

Collection of some needed script commands, not complete and not well thought, just some brainstorming

Set HE = HEobject()


HE.ActiveTab = CurrentTab
sel = HE.ActiveTab.GetCurrentSelection

HE.ActiveTab.Set = CurrentTab +1
HE.ActiveTab.WriteText(sel)


HE.Tabs.TotalTabsCount
HE.ActiveTab.set = HE.Tabs.Tab(1)
For x = 1 To TotalTabsCount...



HE.ActiveTab.set(#"path\open tab filename"#)



PosX = HE.ActiveTab.GetCurrentCaretPosX
PosY = HE.ActiveTab.GetCurrentCaretPosY
HE.ActiveTab.SetCurrentCaretPosX(PosX)
HE.ActiveTab.SetCurrentCaretPosY(PosY)

SetCaretPos(x,y)
GetCaretPos(x,y)


CaretUp(1)
CaretDown(10)
CaretLeft(SOL)
CaretRight(EOL)




For i = 1 To TotalLinesCount - PosX

    cont = HE.ActiveTab.Line(.).Get.Content
    IF cont > 0
   
   or
    check = Find(cont,"word")
     IF check then




Line12 = HE.ActiveTab.Line(12).Get.Content
HE.ActiveTab.Line(12).Set.Content = RegExReplace(Line12,"yes","no")



sel = GetCurrentSelection
  VBS.RegExReplace(sel,sel,"A,a")
SetCurrentSelection(sel)
WriteText(sel)




HE.Tabs.New(L|R,n,true)

HE.ActiveTab.Close, true
HE.Tabs.Close, true

LoadFile(#"path\file"#)
SaveFile
SaveFileAs
SaveFileAs(#"path\file"#)
SaveAll
SaveAllAs_AskForName


HE.ActiveTab.AppendText(result)
HE.Tabs.Tab(3).AppendText("string")
HE.Tabs.Tab(x).AppendText(#E:\snippet\a,txt#)


HE.ActiveTab.FilePath
HE.ActiveTab.FileName



HE.ActiveTab.State.Get   dirty|saved   1|0
      IF HE.ActiveTab.State = dirty Then SaveFile


HE.ActiveTab.State.set RO | RW 


SetClipboardText
GetClipboardText




HE.ActiveTab.Selection.Mode.set line|column|stream
SMode = HE.ActiveTab.Selection.Mode.get

HE.ActiveTab.Selection.Start
HE.ActiveTab.Selection.End

HE.ActiveTab.Selection.StartPosOfSelection
HE.ActiveTab.Selection.LenOfSelection

HE.ActiveTab.Selection.Reset
HE.ActiveTab.Selection.Restore
HE.ActiveTab.Selection.Lock


Goto EOL | EOF | TOF | BOF

HE.Editor.Command(edit.find)
HE.Editor.Command(print)
HE.Editor.Command(reload)
« Last Edit: June 05, 2009, 10:28:26 pm by Stefan » Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #19 on: September 08, 2009, 02:02:25 pm »

Just idea for later:


1) if possible let us use the status bar for script messages:

HE.Status ("ASCII of char on the right: " & Asc(HE.Char(right)) )


or
Do While HE.CountAllChars < 99
   HE.Status ("Current typed chars: " & HE.CountAllChars)
   WScript.sleep 5000
Loop
   HE.Status ("Stop it,  limit reached")


or
HE.Status ("Backup script startet")

If HE.Selection ="" Then
   HE.Status ("Error, please select some text first.")
Else
   HE.Status ("Selection detected, ...")

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

2.) let the script engine "hear" to some buttons, like Ctrl+Shift+Alt+F1 ...F9, Strg+ESC or like that.
So we can use in side an script
IF HE.KeyPress.detected(Strg+ESC) then ...

IF this feature is used in an script  this shortcuts should be blocked for the rest of HE (if used somewhere) and only deliver to the script.
Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #20 on: September 12, 2009, 05:31:06 pm »

Thanks for the info Alex, looks good.

Did we relay need HE-own alert, answer and sleep ?  They are already build in WSH-scripting languages.
Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #21 on: September 12, 2009, 05:45:37 pm »

What i had need often was an gui to get several input
from user at once, without prompted him with many InputBox'es.

XYplorer has an nice script command: HTML

You can display an HTML page with XYplorer.
Inside of this page you can get f.ex. links and forms.
The action of this objects are redirected to XY
and stored somehow separated in an var to work with further in the script.

Code:
varUserOpt = html(<html><body><form method="get" action="HE:">
  Name: <input type=text name="name" size=40 maxlength=80><br>
  <input type=radio name="delAll" value="Yes"> [...])

MsgBox varUserOpt  ====> name=Stefan;delAll=No

Code:
varUserOpt = html('<html><body>
<a href="HE:one">Load One</a>
<a href="HE:two">Load Two</a></body></html>');

MsgBox "User clicked on link  " & varUserOpt    ======> User clicked on link two
If varUserOpt = "two" Then
Else

Since it's an real HTML page you can use all formating options like colors, big and small text
and also have an lot of room for longly descriptions.


http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=3943
« Last Edit: September 12, 2009, 05:54:59 pm by Stefan » Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
alex
Developer
Global Moderator
Hero Member
*****

Karma: +19/-2
Offline Offline

Gender: Male
Posts: 1334



View Profile WWW
« Reply #22 on: September 12, 2009, 09:00:01 pm »

Hi Stefan,

About HTML dialog. The idea is good, but I would delay this feature. because it is more generic feature request then scripting request. Because handling of such HTML dialogs in HE should be implemented first.

About alert/confirm/sleep. Do not mix Windows Scripting and Window Scripting Host. WSH is an COM object that implements IActiveScriptHost interface, and WSH itself implements alert/confirm/sleep. HE would not use WSH, it would be host itself. So, this functionality should be reimplemented by every host. I would check this once more, but from my first test, these methods, functions were not available.
Of course you can access them by dynamically creating WSH:
Code:
WshShell = new ActiveXObject( "WScript.Shell" );
n = WshShell.Popup( "Continue?", 0, "Test", 3 );

Best regards,
Alex.
Logged

Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #23 on: September 12, 2009, 09:47:15 pm »

>would be host itself
Ah, i see.
Didn't know that you have to go that far, thinking you could use an already existing host like WSH or iE, sorry.

Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #24 on: September 12, 2009, 09:55:25 pm »

I don't know if you have to take care of supporting different languages
or if this HE.host would be open for all WSH-scripting languages, but...

...If it not to much i would suggest to support Python too
since Python has good text manipulation support in an easy way already build-in.
Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
alex
Developer
Global Moderator
Hero Member
*****

Karma: +19/-2
Offline Offline

Gender: Male
Posts: 1334



View Profile WWW
« Reply #25 on: September 12, 2009, 10:33:49 pm »

for supporting events and debugger in the future better to implement ScriptingHost based on HE. Also such way give more control on script execution.

For host there is no difference in which language script written. Every script engine (JavaScript, VP, Python, Perl etc) is homogeneous and provide same interface. This is power of Active Scripting. Here is VERY good FAQ about it, I am also reading. Maybe it can give you better insight about what is possible.
Logged

Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #26 on: September 26, 2009, 11:48:54 pm »

(i will edit THIS post and delete all but this first two lines - to clean up. The following text is copied to the post linked below too)
I edited my post: http://forum.hippoedit.com/index.php/topic,340.msg1432.html#msg1432

on
topic 7
Macro menu


I added:
    (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 )



"every second till ESC" is a little playing, but interesting i think:
Execute an macro and watch what happens.... macro is executed one time every second...
... if i see it is enough - or i see it wents wrong - i will press ESC to stop the macro.
(could be f.ex. 5 sec or like that too,  best set by ini parameter)

"n times"  i want to execute an macro and let it run 1 or 5 or n times in a row.

"Till end of file"  i want to execute an macro from current position till EOF is reached.

"on selection only" i want that the macro is working on the selected text only.


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

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.
« Last Edit: September 27, 2009, 12:53:50 am by Stefan » Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
alex
Developer
Global Moderator
Hero Member
*****

Karma: +19/-2
Offline Offline

Gender: Male
Posts: 1334



View Profile WWW
« Reply #27 on: September 27, 2009, 12:20:02 pm »

Hi Stefan,

The idea about temporary macro is good. I would do it.
Have seen similar way for everything in Intype. Fex, if you change untitled project it does not ask you for save, even on exit, but stores it in workspace until you would close it or save under some name. Same can be done for macro (I mean not only create sunc temporary macro, but also saved between sessions).

About different ways for executing of macro. Single, and multiple times is OK. Re-executing, stop by shortcut (but I think this should be Ctrl+Break, but not Esc as it done now for tools, to keep consistence) also fine.
Till End of Line, on Selection Only, every Second I do not like. Every second, can be easy achieved by inserting Sleep into macro code, if somebody want it. Because I do not see real scenario for everybody. Just to keep all simple. And also it does not fit to other options you suggested (or just do it as check box).
About Till End of Line, on Selection Only. And if macro has nothing to do with processing of files or selections? As Find in files with parameters or execute some external command? This would only add confusion for selecting. That can be done by scripting.

From my current design, script can have two built in callbacks:
  • __he_init() - would be call once per first script initialization at first session.
  • __he_main(String arguments, String initiat_dir) - entrance to script, to avoid placing execution code in global scope. Which called by HE after processing global scope. In such way you can get arguments into script in same way as it done for tools. And also tools options/management dialog would be reused. So you can get selection, cursor position etc. Of course in addition in normal methods calls for editor objects.
Logged

Stefan
Administrator
Hero Member
*****

Karma: +6/-0
Offline Offline

Posts: 684



View Profile
« Reply #28 on: September 27, 2009, 01:02:07 pm »


>About different ways for executing of macro.
>Single, and multiple times is OK. Re-executing, stop by shortcut (but I think this should be Ctrl+Break,
Yes ok, ESC was my first thought only, i am fine with what ever you chose here.



>Every second, can be easy achieved by inserting Sleep into macro code, if somebody want it.
I was not thinking about tweaking an macro afterwards by edit the code.
Just record and execute it with my suggested option. I see i am thinking not far enough, sorry.
So ok too. If one needs this he can modify the macro or use scripting. Fine.



>About Till End of Line, on Selection Only.
>And if macro has nothing to do with processing of files or selections?
Then the user shouldn't use this!
Maybe then "execute n times"  would also not fit for this issue?


Till EOF (oh! did i really wrote "Till End of Line"? ... sorry i meant "Till End of File"),
Till EOF is really needed!
Or should i really every time counting like (totalLines - currentLine = exectueTimes) ?


And execute on selected text is needed too, at least nifty, as i showed in my example.



>As Find in files with parameters or execute some external command?
Why should providing the selected text to an external program from an macro not be able? Cheesy



>This would only add confusion for selecting.
I can't see why cropping my freedom to do things 'the way i want' would not add confusion Cheesy




>That can be done by scripting.
Since to use an Macro is much more simpler then writing an script
i would really suggest thinking about implementing this option(s).

I imaging i would use an powerful macro-tool more often then writing/editing an script.
It would be more easy and quicker that way.

No, I even thinking about "executing till bookmark x"  or "executing till anchor"  Grin
Logged

Stefan, HippoEDIT beta tester  (HippoEDIT News On Twitter: http://twitter.com/hippoedit/)
alex
Developer
Global Moderator
Hero Member
*****

Karma: +19/-2
Offline Offline

Gender: Male
Posts: 1334



View Profile WWW
« Reply #29 on: September 27, 2009, 01:35:28 pm »

And if macro does not change cursor position or how to find out that it is now over bookmark?
And then to describe user why my macro which moves mouse or opens files does not work till end of file? or how can I get it working?
I just do not want to have such unclear options which are not fitting to all scenarios.
And execute n time fit to all. You can open file or move mouse n times.

Let do simple Single and n Times execute and then discuss based on existing functionality.
Logged

Pages: 1 [2] 3 Print 
« previous next »
Jump to:  


Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC