runTool() does not set Focus to active Document

Help with writing and running scripts

runTool() does not set Focus to active Document

Postby sarnold_688 » Sat Nov 03, 2007 1:41 pm

I have an external script that writes to the outputWindow. I copy that, process the output, write to activeDocument.

After it runs, I seem to still be in the "Script List" (this is how I envoked it by dbl-clicking it).
If I use the popup "Run", it works fine.
If I envoke it in the Scripting Menu, it works fine.
It just seems that dbl-clicking in there is my problem.

How can I set focus back to the ActiveDocument?
User avatar
sarnold_688
Newbie
 
Posts: 4
Joined: Thu Nov 01, 2007 11:00 pm

Re: runTool() does not set Focus to active Document

Postby Mofi » Sat Nov 03, 2007 3:04 pm

What about using this simply code:

Code: Select all
// Remember the current active file before real start of the script.
var CurrentFileIndex = getActiveDocumentIndex();

// Your script code.

// Make the file before script execution again the active file.
if (CurrentFileIndex >= 0 && CurrentFileIndex < UltraEdit.document.length) UltraEdit.document[CurrentFileIndex].setActive();


Here is the code for the function getActiveDocumentIndex.

I hope this works because I have not tested it. If it does not set the focus to the edit window, write an email to IDM support.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4064
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: runTool() does not set Focus to active Document

Postby sarnold_688 » Sat Nov 03, 2007 3:14 pm

Tried it out, but it still does not return focus back to the document.
I tried "setActive()", but no luck.
I think its just the way that "double-clicking" on the "Script List" keeps the focus and I do not see a way to "CTRL-TAB" back to the active one.

For now, I'll just note that this is a problem (for double-click). but the other ways I mentioned all work ok.

thanks.
User avatar
sarnold_688
Newbie
 
Posts: 4
Joined: Thu Nov 01, 2007 11:00 pm


Return to Scripts

cron