Forum Replies Created

Viewing 25 posts - 76 through 100 (of 103 total)
  • Author
    Posts
  • in reply to: How to include other macros DYNAMICALLY from macros? #22599
    Patrick C
    Participant

    So far I used the Windows Registry «semi-hack ‘solution’», the following is an example:

    In script 1:

    var WshShell = new ActiveXObject( "WScript.Shell" );
    
    WshShell.RegWrite( "HKCU\\_Patrick_custom_\\str1", "ab cd",  "REG_SZ"    );
    WshShell.RegWrite( "HKCU\\_Patrick_custom_\\str2",  "1234",  "REG_SZ"    );
    WshShell.RegWrite( "HKCU\\_Patrick_custom_\\num1",   1234 ,  "REG_DWORD" );
    
     editor.ExecuteMacro( “d:\\script2.jsee”, eeRunFile | eeMacroLangJScript );

    In script 2:

    var WshShell = new ActiveXObject( "WScript.Shell" );
    
    var str1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str1" );
    var str2 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str2" );
    var num1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\num1" );
    
    OutputBar.writeln( "str1     = " + str1                                                                      );
    OutputBar.writeln( "str2 + 1 = " + (str2 + 1)   +  "  // an imported string is not automatically a number"     );
    OutputBar.writeln( "num1 + 1 = " + (num1 + 1)   +  "  // an imported DWORD really is an integer"               );

    Hope this helps

    in reply to: Serious bug regarding macros mapped to shortcuts! #22590
    Patrick C
    Participant

    Now I recall – I had to reassign the macro shortcuts after the bug was fixed.

    In my case this wasn’t too bad an issue as I have a list of my custom shortcut settings. EmEditor isn’t the only program where my custom shortcuts got reset after updating (LibreOffice was another recent one) so over time I learnt – it remains annoying nevertheless.

    in reply to: Serious bug regarding macros mapped to shortcuts! #22588
    Patrick C
    Participant

    Are you using the latest version (17.2.2)?

    As far as I can remember this was one of the early v17.0 perhaps also v17.1 bugs which were fixed with ≈ v17.1 or v17.2.

    I btw just re-tested on v17.2.2 – in my case this error doesn’t occur.

    in reply to: How to include other macros DYNAMICALLY from macros? #22586
    Patrick C
    Participant

    Executing macros is simple:
    editor.ExecuteMacro( “d:\example.jsee”, eeRunFile | eeMacroLangJScript );
    http://www.emeditor.org/en/macro_editor_editor_executemacro.html

    However, I don’t whether or not dynamical includes are possible.

    Patrick C
    Participant
    Patrick C
    Participant

    Just tested and implemented in my save macro – Version 17.2.1 now trims the cursor’s line when using the Delete Spaces at End of Lines command :)
    For large files this is much more efficient than document.selection.Replace( “[ \t]+$”, “”, eeFindReplaceRegExp + eeReplaceAll );
    (tested with a 100 MB file having 2 million lines).

    My save macro now is

    editor.ExecuteCommandByID(4278);         // Delete Spaces at End of Lines command
    editor.ExecuteCommandByID(4099);

    I think this is a good compromise solution.
    Thank you Yutaka!

    Patrick C
    Participant

    Not really as I just used to hit ctrl+s to both trim and save.

    However I’ve just written a macro and assigned ctrl+s to achieve the same effect:

    document.selection.Replace( "[ \t]+$", "", eeFindReplaceRegExp + eeReplaceAll );
    editor.ExecuteCommandByID(4099);

    So if its too much trouble for you, I can stick with the macro as an alternative solution.

    Patrick C
    Participant

    Thank you Yutaka!

    Patrick C
    Participant

    Hello Yutaka,

    Basically I selected with the keyboard (ctrl+F8 for line; shift + end + arrow right for stream)
    Written as macro code this would be:

    to select in line selection mode
    editor.ExecuteCommandByID(4154);

    To select in stream selection mode
    document.selection.StartOfLine(false,eeLineView | eeLineHomeText);
    document.selection.EndOfLine(true,eeLineView);
    document.selection.CharRight(true,1);

    Importance of virtual space
    I now noticed, that a visually (images of the first post #22457) identical selection made in stream selection mode is only different from line selection mode when virtual space is enabled.

    To me it will remain confusing, that BottomPointY – TopPointY covers n+1 lines when only n were selected with CommandID(4154). Nevertheless, I’ll be fine as long as I can count on this (n+1 lines) consistently being the case when the selection’s last character is a new-line character.

    Thanks!
    Patrick

    Patrick C
    Participant

    Ok, figured out one consistency in this:
    If the last character of the selection is a newline character (or the last two are CR+LF), then BottomPointY will be one line below the actual selection.

    With one exception:
    When the last line is empty but line-selected,
    last line empty + line selected
    then the last character of that selection is not a new line character but BottomPointY still is one line beyond the end of the selection.

    Provided future EmEditor versions will continue to have have this BottomPointY behavior, my issue should be solved as I now can simply test whether the last character is new-line or not.

    in reply to: Command ID for “Remove from this (favorite) list” #22452
    Patrick C
    Participant

    Hello Yutaka,

    Thank you for your reply!
    It seems however, that
    editor.ExecuteCommandByID(4465);
    doesn’t really achieve anything.
    Probably this is what you meant with “not available for keyboard shortcut assignment”.

    It would be nice to have something analogous to:

    editor.ExecuteCommandByID (4609 + i); // i is an integer from 0 through 63 (List of Recent Documents command)
    EEID_FILE_MRU_FILE1 through EEID_FILE_MRU_FILE1 + 63 (from 4609 through 4609 + 63)
    Just with removing the file from the list instead of opening the file.

    Best regards,
    Patrick

    Patrick C
    Participant

    hit CTRL+SHIFT+F8 ; let go; then use the arrow up down keys

    See
    http://www.emeditor.org/en/features_box_editing.html

    in reply to: "Macros Toolbar" position problem #22408
    Patrick C
    Participant

    Have you tried dragging the toolbar back with the ↔ cursor?
    drag cursor

    Keeping the EmEditor toolbar locations at bay is tricky. My recommendation is to set your toolbar locations for the window size you usually work with (e.g. maximised on your main screen) and then lock their locations.
    In case you frequently hide and unhide toolbars: Set the locations with all toolbars shown, lock, then hide again.

    Lock by right clicking a toolbar:
    Lock by right clicking a toolbar

    in reply to: "Quick Launch" problems #22400
    Patrick C
    Participant

    This is odd – it works on my machine:
    Windows 10 with EmEditor Professional (64-bit) Version 17.1.2

    Quick launch history

    in reply to: \n is not replaced in 17.1.2 #22399
    Patrick C
    Participant

    I first panicked when I read this, but wasn’t able to reproduce it.

    Filter and replace for example works fine on my Windows 10 machine with EmEditor Professional (64-bit) Version 17.1.2

    Newline escape

    Patrick C
    Participant

    Dear LifeTimer,

    Sorry I wasn’t able to post this earlier, though better late than never…

    How to pass command line arguments using registry values without having to close EmEditor:

    Approach 1: using multiple command line statements

    reg add "HKCU\_Patrick_custom_" /v str1 /t REG_SZ    /f /d "ab cd"
    reg add "HKCU\_Patrick_custom_" /v str2 /t REG_SZ    /f /d "1234"
    reg add "HKCU\_Patrick_custom_" /v num1 /t REG_DWORD /f /d 1234

    Regarding the syntax:
    // /v value name (“variable name”)
    // /t variable type: REG_SZ = string; REG_DWORD = 32-bit integer
    // /f force overwrite already existing value without prompting for Y/N
    // /d data to be written (“assigned to the variable”)

    to visualise the values in the registry:
    Registry

    then call the EmEditor macro
    "c:\Program Files\EmEditor\EmEditor.exe" /mf "d:\tmp\mymacro.jsee

    with the macro code being

    var WshShell = new ActiveXObject( "WScript.Shell" );
    var str1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str1" );
    var str2 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str2" );
    var num1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\num1" );
    alert( str1 );
    alert( str2 + 1 );   // an imported string is not automatically a number
    alert( num1 + 1);    // an imported DWORD really is an integer

    Approach 2: using one single command line statement
    If, and only if it really has to be a one liner:
    reg add "HKCU\_Patrick_custom_" /v str1 /t REG_SZ /f /d "xyz" && "c:\Program Files\EmEditor\EmEditor.exe" /mf "d:\tmp\mymacro.jsee"

    I hope this will be of use for someone.

    Credits:
    https://www.windowscentral.com/how-edit-registry-using-command-prompt-windows-10
    http://www.emeditor.org/en/macro_tutorial_tutorial_regread.html

    Patrick C
    Participant

    Just worked on the same problem today – guess I was lucky

    The command line therefore is
    set myarg=blabla && start "" "c:\Program Files\EmEditor\EmEditor.exe" /mf "d:\tmp\mymacro.jsee

    The macro file code then is

    var she = new ActiveXObject("wscript.shell");
    myarg = she.ExpandEnvironmentStrings("%myarg%");
    alert(myarg);

    There is one important issue though:
    Emeditor must not yet run when calling. Most likely because once running it would only have access to environment variables which existed upon starting EmEditor

    Hope this helps
    Patrick

    PS Credits for those who brought me on the right path:
    https://www.emeditor.com/forums/topic/macro-scripting-importexport-of-filter-settings/
    https://stackoverflow.com/questions/21315708/reading-environment-variables-with-javascript
    https://superuser.com/questions/424001/launch-windows-program-with-custom-environment-variable

    Patrick C
    Participant

    Hello Yutaka,

    explain why

    To be honest: Because I’m lazy.
    I’d like to have a Runs at Events on/off button → 1 mouse click required
    Presently it take 4 mouse clicks to turn an event on and off.

    As I have to do this often, it does make a difference

    Regarding priorities:
    I don’t urgently need this – its more like a “very nice to have” convenience feature.

    Thank you for your great support!
    Patrick

    in reply to: Macro "Runs at Events" doesn't work #22317
    Patrick C
    Participant

    Yutaka’s workaround works on my machine :)

    Thank you!!! Presently I do need this feature quite often.

    in reply to: Macro "Runs at Events" doesn't work #22311
    Patrick C
    Participant

    I also tried downgrading – but at a price. The reason is that Emeditor transfers certain settings from version 16.9.3 to version 17. Those settings cannot be recovered when downgrading – except if you didn’t run “Delete old settings”. In my case I made a mess with my settings (own fault, I didn’t realise at first).

    In any case, if you didn’t run “Delete old settings”, then you can give downgrading a try (at your own risk):
    http://files.emeditor.com/emed64_16.9.3.exe

    in reply to: Languagetool #22298
    Patrick C
    Participant

    Not as far as I can see, though Yutaka could extend the already existing Hunspell interface to optionally use LanguageTool.
    I.e. provided there is sufficient user demand.
    Hunspell so far is sufficient for me, mainly because spell-critical documents tend to be formatted and thus written in MS-Word / LibreOffice Writer or an Email app.

    in reply to: Macro "Runs at Events" doesn't work #22295
    Patrick C
    Participant

    Follow up question for Yutaka:

    How are the macro settings in versions 17+ now accessed from within a macro?

    Before v17 it was
    sMacro1 = editor.GetProfileString(eeRegMacros, “”, “Macro1”, -1);

    Consequently
    https://www.emeditor.com/forums/topic/macro-menu-toggle-runs-at-events-option-for-macros/
    will probably have to be re-written.

    in reply to: Macro "Runs at Events" doesn't work #22290
    Patrick C
    Participant

    Yep – same here, just wanted to post the issue as well ;)
    Macro “Runs at Events” doesn’t work any more on my computer either.

    Patrick C
    Participant

    Hi Dan

    EmEditor Version 15.9.0 didn’t misbehave when opening the file index.md in my case. Perhaps you are on the wrong track.
    Could it be something else: Security software? Network connection?

    Patrick

    in reply to: Is there an option to format code? #20578
    Patrick C
    Participant

    Thank you Stefan!

Viewing 25 posts - 76 through 100 (of 103 total)