[Solved] Shell command and focus

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Locked
Refdoc
Posts: 7
Joined: Wed Jun 09, 2010 5:02 pm

[Solved] Shell command and focus

Post by Refdoc »

I have written a OpenOffice Basic macro which works just fine but for one problem:

I call an external programme via the Shell function. The external programme opens a small window but this window remains hidden under all other windows. Which is a nuisance.

Code: Select all

 Shell("external.exe",1,DocURL)
I understand that the number following the command is the parameter governing level of focus and "hiddeness". But various experiment ("1", "2", "10" etc) have not brought any success. The window always remains hidden under all the other windows open.

There appears to be something odd about the toolkit used by the programme I am dealing with - it is not normal Windows system toolkit nor anything else I recognise. I am not sure if this plays a role. Also, the programme has a number of separate windows and toolbars floating about, the one I am concerned about is called second in line: A toolbar appears, floating above all else and then the window I need appears (but, as i said, hidden underneath).

Many thanks for all advice and suggestions
Last edited by robleyd on Tue Jul 25, 2023 1:29 am, edited 1 time in total.
Reason: Tagged [Solved]. Add green tick
Openoffice 3.1 on WinXp and OpenOffice 3.2 on Jaunty
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Shell command and focus

Post by Charlie Young »

Hard to tell what will work correctly in some cases, but you could try going through the API:

Code: Select all

Sub RunShell
	Dim SysShell 
	
	SysShell = createUNOService("com.sun.star.system.SystemShellExecute")
	SysShell.Execute("external.exe",DocURL,0)
End Sub
Apache OpenOffice 4.1.1
Windows XP
Refdoc
Posts: 7
Joined: Wed Jun 09, 2010 5:02 pm

Re: Shell command and focus

Post by Refdoc »

Many thanks. Will try this out when I am back in the office on Monday.
Openoffice 3.1 on WinXp and OpenOffice 3.2 on Jaunty
pete_porner
Posts: 5
Joined: Fri Feb 10, 2023 8:37 pm

Re: Shell command and focus

Post by pete_porner »

That works.
openoffice 2.4 on ubuntu 9.04
Locked