Thumbnail

Display Popup

by Synthiam

Popup a custom window with custom text to the user from a command

Requires ARC v13 (Updated 9/3/2024) Source Code

How to add the Display Popup robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the Display category tab.
  5. Press the Display Popup icon to add the robot skill to your project.

Don't have a robot yet?

Follow the Getting Started Guide to build a robot and use the Display Popup robot skill.


How to use the Display Popup robot skill

Use the ControlCommand() to send custom text to this skill, which will be displayed on full screen for a set period. The configuration menu allows you to adjust the text font, text color, and background color. There is a default timeout value as well. All ControlCommand() for this skill can be found in the Cheat Sheet tab. See the video below for an example of use.

Main Window

User-inserted image

1. Display Popup Nothing to interact with. Use the configuration to change parameters such as timeout, text color, background color, and font.

2. Script Use a ControlCommand() script to execute a Display Popup.

Configuration

User-inserted image

1. Default Timeout Numerical Field Enter the default number of seconds you want the popup to stay displayed. It can be overwritten by the ControlCommand() script.

2. Color Buttons Change the color of the popup text and background.

3. Font Change Button  Change the popup font. Use any font that's installed on your device.

How to Use Display Popup

  1. Add the Display Popup skill to your ARC project (Project -> Add Skill -> Misc -> Display Popup).

  2. Change the Display Popup configuration if needed.

  3. Run a Display Popup ControlCommand() script. View your Display Popup until the timeout closes the popup.

*Note: Press any key to close the popup before the timeout expires.

Control Commands

controlCommand("Display Popup", "Display", "Text") controlCommand("Display Popup", "Display", "Text", [timeout seconds]) controlCommand("Display Popup", "Display", "Text", [timeout seconds], [window width], [window height]) controlCommand("Display Popup", "Display", "Text", [timeout seconds], [window width], [window height], [window x location], [window y location])

Code Sample


# use default timeout value
ControlCommand("Display Popup", "Display", "Some text to display")

# use specified 10 second timeout
ControlCommand("Display Popup", "Display", "Some text to display", 10)

# use specified 10 second timeout and specify the window size
ControlCommand("Display Popup", "Display", "Some text to display", 10, 100, 200)
# count to 10
for (var x = 0; x < 10; x++)
   controlCommand("Display Popup", "Display", x, 1);

Resources

Source code available here: DisplayResponse.zip


ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

PRO
USA
#17  

I also tried it, works well

#18  

@Athena After trying the script did not have good results // Set the initial countdown time in seconds var countdownTime = 10;

// Loop to count down from 10 to 0 for (var x = countdownTime; x >= 0; x--) { // Display the current countdown time with a 1-second timeout controlCommand("Display Popup", "Display", "Countdown: " + x, 10, 200, 200); }

I understand the sizing of the popup but where do I change the location of where the popup is located on the screen? Not sure why but as written the code takes 10 seconds between each number 10, 9, 8... rather than the 1 second.

PRO
Canada
#19  

It looks like there was a misunderstanding in the script. The timeout value should be set to 1 second for each countdown step, and the loop should decrement correctly. Additionally, to set the location of the popup, you can specify the window x location and window y location parameters in the controlCommand.

Here's the corrected script with the proper timeout and location settings:

// Set the initial countdown time in seconds
var countdownTime = 10;

// Loop to count down from 10 to 0
for (var x = countdownTime; x >= 0; x--) {
    // Display the current countdown time with a 1-second timeout
    controlCommand("Display Popup", "Display", "Countdown: " + x, 1, 200, 200, 100, 100);
    
    // Pause for 1 second to allow the display to update
    sleep(1000);
}

Explanation:

  1. Initial Countdown Time: Set the initial countdown time in seconds.
  2. Loop: The for loop counts down from the initial countdown time to 0.
  3. Display Popup: The controlCommand updates the Display Popup with the current countdown time, sets a 1-second timeout, specifies the window size (200x200), and sets the window location (100, 100).
  4. Sleep: The sleep(1000) function pauses the script for 1 second to allow the display to update before continuing to the next iteration.

Steps to Run the Script:

  1. Open the script editor in ARC.
  2. Copy and paste the above JavaScript code into the script editor.
  3. Run the script to start the countdown timer.

This script will display a countdown timer in the popup window, updating every second until it reaches zero, at which point the popup will disappear. The popup will be located at the specified coordinates (100, 100) on the screen.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#20  

@Athena Yes that was better but I'd still like to fine tune it more. The popup keeps turning on and off would rather have it continuously on and decrement the number. I'd also like to have the seconds broken into the hundredths  3.33 seconds etc.  Is there a schematic of the grid location of the screen so I can pinpoint the location that I'd like to have it located rather than trial and error. How does the x  y work and is there a calibration somewhere that I need to know about for sizing and location?

PRO
Canada
#21  

To achieve a smoother countdown without the popup turning on and off, you can update the text within the same popup window instead of creating a new one each second. Additionally, to display the countdown in hundredths of a second, you can adjust the sleep interval and the countdown decrement accordingly.

Regarding the screen coordinates, the x and y values represent the position of the top-left corner of the popup window relative to the top-left corner of the screen. The coordinates (0, 0) would place the popup at the top-left corner of the screen. There isn't a specific schematic for the grid location, but you can use the screen resolution to determine the coordinates.

Here's an updated script that keeps the popup continuously on and updates the countdown in hundredths of a second:

// Set the initial countdown time in seconds
var countdownTime = 10.00;

// Display the initial popup
controlCommand("Display Popup", "Display", "Countdown: " + countdownTime.toFixed(2), 100, 200, 200, 100, 100);

// Loop to count down from 10.00 to 0.00
for (var x = countdownTime; x >= 0; x -= 0.01) {
    // Update the popup text with the current countdown time
    controlCommand("Display Popup", "Display", "Countdown: " + x.toFixed(2), 100, 200, 200, 100, 100);
    
    // Pause for 10 milliseconds to allow the display to update
    sleep(10);
}

// Close the popup after the countdown is complete
controlCommand("Display Popup", "Display", "Countdown Complete!", 2, 200, 200, 100, 100);

Explanation:

  1. Initial Countdown Time: Set the initial countdown time in seconds with two decimal places.
  2. Initial Popup: Display the initial popup with the countdown time, setting a long timeout (100 seconds) to keep it on the screen.
  3. Loop: The for loop counts down from the initial countdown time to 0, decrementing by 0.01 seconds each iteration.
  4. Update Popup: The ControlCommand updates the text within the same popup window with the current countdown time.
  5. Sleep: The sleep(10) function pauses the script for 10 milliseconds to allow the display to update before continuing to the next iteration.
  6. Close Popup: After the countdown is complete, display a message indicating completion and set a short timeout (2 seconds) to close the popup.

Screen Coordinates:

  • x: Horizontal position of the popup window (0 is the left edge of the screen).
  • y: Vertical position of the popup window (0 is the top edge of the screen).

Tips for Fine-Tuning:

  • Screen Resolution: Use your screen resolution to determine the coordinates. For example, if your screen resolution is 1920x1080, the center of the screen would be approximately (960, 540).
  • Trial and Error: Adjust the x and y values in the script to position the popup window where you want it. You can use a simple script to test different positions:
controlCommand("Display Popup", "Display", "Test Position", 10, 200, 200, x, y);

Replace x and y with different values to see where the popup appears on the screen.

This approach should provide a smoother countdown experience and allow you to fine-tune the popup's position on the screen.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#22  

@Athena Tried your script and understand what you are trying to do but it totally got hung up and did not change till I pushed the escape button which decremented it. Could you please verify that the script works with ARC software.

PRO
Synthiam
#23   — Edited

Do it like this to count down 10

Quote:

for (var x = 10; x > 0; x--) controlCommand("Display Popup", "Display", x, 1);

#24   — Edited

Yes that is very close to what I'm looking for. Would like it to do in tenths or hundredths but not sure how to do that. Here is my modified code with location and size. for (var x = 10; x > 0; x--) controlCommand("Display Popup", "Display", x, 1,100, 200); I also tried this  for (var x = 10; x > 0; x-=.01)  but that didn't work as it counted down 1/100 for each second. How is it known behind the scenes that 10 is 10 seconds as usually we have to specify 10,000 is 10 seconds. example   sleep(10000);