Author Topic: Two instances of OSD.ShowText ?  (Read 537 times)

0 Members and 1 Guest are viewing this topic.

monkee

  • $upporter
  • Jr. Member
  • *****
  • Posts: 32
  • Karma: 4
    • View Profile
Two instances of OSD.ShowText ?
« on: May 10, 2017, 11:44:27 PM »
Hi, is it possible to have two instances of OSD.ShowText appear at the same time?  In my experiments, I couldn't do so.  Also, if that is possible, can I set a different text color for each instance??  I need to do both of these things for my latest project :)

If neither of the above are possible, can I at least make the OSD.DisplayText show a second line? 
Code: [Select]
<p>,<br> do not work.

Thanks in advance!!

*edit* also is it possible to move the text display horizontally?  I can move it vertically but not horizontally.
« Last Edit: May 11, 2017, 12:10:29 AM by monkee »



jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7266
  • Karma: 107
    • View Profile
    • www.voxcommando.net
Re: Two instances of OSD.ShowText ?
« Reply #1 on: May 11, 2017, 09:00:33 AM »
is it possible to have two instances of OSD.ShowText appear at the same time?
No it is not possible.  The OSD windows are a delicate thing.  They are created only once and then hidden so that they can be brought back and shown in front of all other windows but without stealing focus and interfering with whatever other programs you have running.

can I set a different text color for each instance??  I need to do both of these things for my latest project :)
No because there is only one instance.

If neither of the above are possible, can I at least make the OSD.DisplayText show a second line? 
Code: [Select]
<p>,<br> do not work.
Yes, there are two ways to do this.  Paragraph and break tags do not work because the OSD is using a text box, not HTML.

You can add a line of text using the action : OSD.AddText  http://voxcommando.com/mediawiki/index.php?title=Actions#AddText
That should have been very easy to discover on your own just using the action selection tree or by looking at the wiki.

Another option is to use the variable {CR} in place of <BR>
(http://voxcommando.com/mediawiki/index.php?title=Logical_Command_Builder#System_Variables).

*edit* also is it possible to move the text display horizontally?  I can move it vertically but not horizontally.

No, it will always be centered and the width adjusts automatically based on the text displayed.
« Last Edit: May 11, 2017, 09:05:35 AM by nime5ter »
If you do not wish to receive email notifications from the forum please UNSUBSCRIBE and do NOT mark them as SPAM.

Getting Support

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7266
  • Karma: 107
    • View Profile
    • www.voxcommando.net
Re: Two instances of OSD.ShowText ?
« Reply #2 on: May 11, 2017, 09:08:34 AM »
If you want to get fancy with OSD there is a way to do it using RoboBrowser (and I'm sure other solutions could be found too), although you may find that the RoboB window does interfere with your other running programs to some extent by stealing focus, or it may fail to appear in front of other windows in some cases.

The inspiration comes from the following post: http://voxcommando.com/forum/index.php?topic=2047.0

Here is XML for a group to get you started.  There are two commands.  The first creates a RoboBrowser, positions it, hides the frame etc.  Then it navigates to an html page (we need to have one to start with but it might be better (faster and easier to lay out) for you to create a local html file to work with (I just wanted to give you a working example using XML only).  Then it grabs the Body tag and rewrites the HTML.

The second command shows how you can modify just a part of the HTML page.  This is probably what you would want to use if you created your own OSD layout file.  In this case I am finding the 2nd heading and changing the text to display the current time.


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.5-->
<commandGroup open="True" name="RoboB OSD example" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="50" name="create osd" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>RoboB.Select</cmdType>
      <params>
        <param>myOSD</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.Navigate</cmdType>
      <params>
        <param>http://blank.org/</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.Wait</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.Show</cmdType>
      <params>
        <param>True</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.ShowFrame</cmdType>
      <params>
        <param>false</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.SetWinSize</cmdType>
      <params>
        <param>400</param>
        <param>180</param>
        <param>33</param>
        <param>33</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.ElementByTag</cmdType>
      <params>
        <param>BODY</param>
        <param>0</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.SetHTML</cmdType>
      <params>
        <param>&lt;h1&gt;My First Heading&lt;/h1&gt;&lt;h2 style="background-color:rgb(0,255,0)"&gt;My second Heading&lt;/h2&gt;&lt;h2 style="color:rgb(0,0,180)"&gt;My third Heading&lt;/h2&gt;</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
  <command id="69" name="update second heading" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>RoboB.Select</cmdType>
      <params>
        <param>myOSD</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.ElementByTag</cmdType>
      <params>
        <param>H2</param>
        <param>0</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.SetText</cmdType>
      <params>
        <param>time now: {ShortTime}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
</commandGroup>





If you do not wish to receive email notifications from the forum please UNSUBSCRIBE and do NOT mark them as SPAM.

Getting Support

monkee

  • $upporter
  • Jr. Member
  • *****
  • Posts: 32
  • Karma: 4
    • View Profile
Re: Two instances of OSD.ShowText ?
« Reply #3 on: May 12, 2017, 02:18:21 AM »
Thanks very much.  The new line using OSD.AddText is working like a charm.  Sorry I didn't figure that out myself.  I did look!

I REALLY wish I could independently control the lines' text color, I'd be done with this project already but the new line will do until I figure out a better option. I'll check out RoboBrowser.  This is the first I've heard of it and it looks interesting.  Since you seem to have to create a local HTML file, would I still be able to scrape from an API, regex, do PY math etc. within VC before it is shown on the OSD?  If it's possible I'll work on figuring it out :)

I was wondering how the OSD did what it did without stealing focus so that's pretty interesting.  Thanks foe explaining it.  I'm not too worried about RoboBrowser stealing focus, I have pretty robust focus reclaiming macros so giving focus back to whatever had it prior to RoboBrowser popping up shouldn't be too hard.

Thanks again!


Aparicio

  • Jr. Member
  • **
  • Posts: 2
  • Karma: 0
    • View Profile
Re: Two instances of OSD.ShowText ?
« Reply #4 on: February 12, 2018, 11:52:39 PM »
What I want is to learn with the website to be knowledgeable and to develop.