Page 1 of 1

Opening windows on Frontmost screen (partial solution found)

Posted: Tue Jul 05, 2011 5:58 am
by mpiva
Is there a way to tell a program to open its window on the frontmost public screen? I have AllKeys linking my Calculator button on my multimedia keyboard to the Calculator program. I'd love it if I could push that button and have the Calculator pop-up on whatever screen I happen to be working on, rather than always having to flip back to the Workbench screen.

Re: Opening windows on Frontmost screen

Posted: Tue Jul 05, 2011 7:35 am
by PowerPC
I think this should be possible, because Amidock has an option to do so.

Re: Opening windows on Frontmost screen

Posted: Tue Jul 05, 2011 11:13 am
by afxgroup
Yes it is possible, but are you asking how to do this with your code or how to "force" a window to be pushed on frontmost screen?

Re: Opening windows on Frontmost screen

Posted: Tue Jul 05, 2011 7:41 pm
by mpiva
No, I'm not coding my own calculator, I mean the actual OS4 Calculator program. I know there is a "PUBSCREEN" tooltype. What I was hoping was that there was a special keyword so I could put in something like "PUBSCREEN=FRONTMOST" and have the Calculator open on the frontmost public screen (and I was really hoping that the keyword would work for any program that has the PUBSCREEN tooltype).

Re: Opening windows on Frontmost screen

Posted: Wed Jul 06, 2011 2:19 am
by tonyw
I don't know whether this would work, but it's worth a try. It certainly works in some other applications.

PubScreen=**

Note there are TWO asterisks, DOS absorbs the first one.

Good luck.

Re: Opening windows on Frontmost screen

Posted: Wed Jul 06, 2011 6:03 am
by mpiva
tonyw wrote:I don't know whether this would work, but it's worth a try. It certainly works in some other applications.

PubScreen=**

Note there are TWO asterisks, DOS absorbs the first one.

Good luck.
Thanks for the suggestion but, sadly, it doesn't work. In fact, it stops Calculator from loading at all (on that note, there should really be an error message telling the user why the program didn't load; something like: "Unable to find requested Public Screen")

:?: Any chance of requesting the OS4 developers to add a variable like $Frontmost to the OS that refers to the Frontmost screen? And I'm not just talking about in Calculator, I mean the entire OS. This would be extremely useful as you could put it in tooltypes or shell scripts.

Re: Opening windows on Frontmost screen

Posted: Thu Jul 07, 2011 7:52 am
by tingo
Not that I have AmigaOS 4.x; but doesn't ARexx already have a library / functions for handling public screens?

Re: Opening windows on Frontmost screen

Posted: Fri Jul 15, 2011 7:33 pm
by mpiva
Well, I finally found a way to do this and thought I'd pass the info along incase anyone is interested.

I found a great little program on Aminet (http://aminet.net/util/batch/FrontPubScreen.lha) that helped.

I was really hoping I could do it all with a single command line; I thought there was a way to embed the output of one command into the options of another command, something like "SYS:Utilities/Calculator PUBSCREEN= | FrontPubScreen", but I couldn't figure out anything that worked.

In the end, I created the following script to be executed by AllKeys:

echo "SYS:Utilities/Calculator PUBSCREEN=" >T:FrontCalc NOLINE
FrontPubScreen >>T:FrontCalc
execute T:FrontCalc
delete >NIL: T:FrontCalc

It works fairly well but I still wish there was a more generic way of passing the name of the frontmost public screen to a program's CLI options or tooltypes.

Re: Opening windows on Frontmost screen

Posted: Fri Jul 15, 2011 9:54 pm
by nbache
mpiva wrote: I was really hoping I could do it all with a single command line; I thought there was a way to embed the output of one command into the options of another command, something like "SYS:Utilities/Calculator PUBSCREEN= | FrontPubScreen", but I couldn't figure out anything that worked.
How about using backticks, as in "SYS:Utilities/Calculator PUBSCREEN=`FrontPubScreen`"? It sounds like that would do exactly what you are trying to achieve. I'm assuming "FrontPubScreen" outputs the name of the frontmost public screen? Backticks around a command will run the command in a separate "sub-shell" and cause the backticks and the command between them to be replaced by the command's output.

Best regards,

Niels

Re: Opening windows on Frontmost screen

Posted: Fri Jul 15, 2011 11:46 pm
by mpiva
nbache wrote:How about using backticks, as in "SYS:Utilities/Calculator PUBSCREEN=`FrontPubScreen`"? It sounds like that would do exactly what you are trying to achieve. I'm assuming "FrontPubScreen" outputs the name of the frontmost public screen? Backticks around a command will run the command in a separate "sub-shell" and cause the backticks and the command between them to be replaced by the command's output.

Best regards,

Niels
AWESOME! :D Thanks, that's exactly what I was looking for. I knew there was a way to do that. I clearly remembered doing it in the past but, for the life of me, I couldn't remember how and it was surprisingly difficult to find that little tidbit of information in my AmigaDOS manuals.