User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Help with writing and running scripts
13 posts Page 1 of 1

if you use Firefox you might be familiar with the CTRL+1, CTRL+2 etc to activate the first, second etc tab.

In UE 14 I had made a AHK (Autohotkey) script to do exactly the same, but in UE15 the script broke and it is not longer possible (to my knowledge) to do in AHK due the changes in UE15.

I wonder if there is a script that does the same as with Firefox. If you have more than two files open it is a great timesaver to be able to jump to the first 1 (first file) or 5th one. It saves you the hassles of mutiple ctrl-(shift)-tabbing.

Or I'm missing some "hidden" feature that already makes this possible?

Thanks in advance! (I have no knowledge of UE scripting)
If you want to activate a document directly with a hotkey, you can do this by writing scripts and assign the hotkeys to the scripts. The script code is quite simple. Here is the example for activating document 3.

if( UltraEdit.document.length >= 3 ) UltraEdit.document[2].setActive();

You need 10 scripts each having just 1 line.
Best regards from Austria
Thanks, it works but not too well. You must release the CTRL key before you can switch to another document. So CTRL-1-3-5 to switch between 1 3 and 5 is not possible (without releasing CTRL). Should be standard feature IMHO (configurable).
You know, UE is way older than FF. So, "standard feature" is ... As Mofi pointed out, you can configure it through the script interface. I am however also not a fan of having to press a key-modifier again after executing a script to type f.ex a " (you get a 2 (swe keyboard layout) if not pressing shift again as opposed to keeping shift pressed). Guess that depends on how the keyboard buffer is handled. That's another discussion tho.

Personally I have absolutely no use for the feature. I always have way more than ten files open so I don't use the tabs (I prefer the file view, tho I wouldn't mind being able to tweak it and remove the other tabs in there which I never use (i.e. Project, Explorer and Lists)). I unfortunately have to have the tabs hidden away as otherwise the script property UltraEdit.document.length is borked. That'll be fixed tho so I can finally get rid of them completely =)
@danny: other application have this feature too but I mentioned FF just to illustrate it. Besides Google Chrome and IE7 and IE8 (probably opera?) use the same ctrl-0-9

I don't like the file listing window at all but find the tabs useful, especially with CTRL-0-9 (or any shortcut you like for that matter)

Edit: I've been using UE since version 4 or something, a number of my requests are now default functions of UE so just wait and see about this one :-)
The reason you have to release the Ctrl key between script executions is because the Cancel dialog steals the focus of the keyboard and 'cancels' the Ctrl key press.

I have requested that IDM add an option similar to what is available for macros to suppress the cancel dialog and allow multiple ctrl presses. Please send in a report for yourself, too.
Good idea roland. I never really thought about that as the script is so fast the dialog doesn't even show for me (used for snippets).
Good news for all users of scripts with assigned hotkeys.

With UltraEdit v17.10.0.1015 it is possible to execute a script several times by hotkey by just pressing the keys and hold them for repeated execution respectively hold Ctrl / Shift / Alt permanently and pressing just the additional key to execute the script once on every key press of the additional key.
Good news indeed, just tried it and it works. What a joy.
In UE up to (included) using the .setActive() script command makes UE lose track of the caret in the document that is activated (text insertion point) but keeps the focus on the previously active document. Adding a .messageBox to the script helps but of course it stall the script execution and you have to dismiss the message box. IDM confirmed the bug and are working on it - a working script looks like this
Code: Select all
if( UltraEdit.document.length >= 1 ) UltraEdit.document[0].setActive();
UltraEdit.messageBox("Swapped tabs","UltraEdit");
This is my version!

Create as many file as shortcuts:

File ue_WindowSelectDoc_1.js:
Code: Select all
// include ue_WindowSelectDoc.js
WindowSelectDoc(0); // ctrl+1

File ue_WindowSelectDoc_2.js:
Code: Select all
// include ue_WindowSelectDoc.js
WindowSelectDoc(1); // ctrl+2


File ue_WindowSelectDoc_9.js:
Code: Select all
// include ue_WindowSelectDoc.js
WindowSelectDoc(9); // ctrl+0

Here is ue_WindowSelectDoc.js:
Code: Select all
function WindowSelectDoc(iIdx)

    if(iIdx == UltraEdit.activeDocumentIdx) // you already are on the document
        return 1;

    if(iIdx < UltraEdit.document.length)
        UltraEdit.document[iIdx].setActive(); // activate the document
    {   // if you select a document greater than opened, iIdx means start counting from right to left
        // so 9 select the most right document, 8 select the penultimate, so on.
        iIdx -= 9;
        UltraEdit.document[UltraEdit.document.length - 1 + iIdx].setActive();

    UltraEdit.messageBox("",""); // remove when IDM fix the bug of focus with setActive()
I'm not sure when exactly but with UE version the UltraEdit.messageBox... no longer seems to be required as the caret is now focused on/in the correct document after switching to it with a script.
Indeed, this issue is fixed with UE v22.20. I could reproduce the input focus issue (active file after script finished) with UE v22.10.0.12, but not anymore with UE v22.20.0.30 (first public version for Windows XP), v22.20.0.34, v22.20.0.36 and v22.20.0.37. Thanks hugov for letting us know about this fix.
Best regards from Austria
13 posts Page 1 of 1