Sign in to follow this  
Followers 0
Automan Empire

Creating a HUD (Heads Up Display)

4 posts in this topic

Has anyone already created a HUD (Heads Up Display)?

I need to create one that overlays some data in the form of numbers or graphs on top of another program. It looks like I will need several HUDs in various places for different attributes. I can't have the HUD cover the entire window, because there are some buttons that I need to get to without juggling windows constantly.

Although I am not the greatest programmer in the world, I can create GUI's, control transparency, etc. I will try to create and post some sample code, but wanted to start with asking for some advice and/or examples.

Thanks


"I've seen your work in the past, and it's novice at best..." SmOke_N

Share this post


Link to post
Share on other sites



Has anyone already created a HUD (Heads Up Display)?

I need to create one that overlays some data in the form of numbers or graphs on top of another program. It looks like I will need several HUDs in various places for different attributes. I can't have the HUD cover the entire window, because there are some buttons that I need to get to without juggling windows constantly.

Although I am not the greatest programmer in the world, I can create GUI's, control transparency, etc. I will try to create and post some sample code, but wanted to start with asking for some advice and/or examples.

Thanks

Not sure I can be too much help, but I'm envisioning, say, your application in the center of the screen, with an au3 GUI wrapping around the edges of the screen - left, right, bottom, top (or a combination of those). I'm pretty sure you can't make a full-screen GUI with a 'cutout' in the center so your application can be seen/accessed. 2 options I can think of though:

1 full screen GUI in which you program your application to always be on top. By launching the application from within the GUI, you can have it come up on top of your GUI and set the position. (Ie, running your au3/exe draws the gui and then opens your application, placing it right where you want it.) Not sure if you can make a non-Au3 app to be 'always on top', but one other way would be for your GUI to immediately return focus/bring to top the application after a button is pressed in gui.

The other option would be to have one parent and (up to) 3 children GUIs, one for each side of the screen. This would effectively give you a wraparound gui with your application in the center. I've only used children windows in a limited capacity, where the child window is for display only and didn't have its own set of buttons - not sure if that complicates matters or not. I tend to think the first option would be easier to set up at least - just might not be as 'pretty' if you can't force your application to be always-on-top when you click conrols in your GUI.

Share this post


Link to post
Share on other sites

Thank you for the reply. It has caused me to rethink the problem.

Instead of creating several HUDs, which is possible, but which would be difficult for me to update individually, I now think that the way to do it is to create one HUD which is ShapedGUI with a transparent background.

There is a functional "ShapedGUI Creator" at

http://www.autoitscript.com/forum/index.ph...p;hl=gui++shape

that I am now working with. I have already created an irregularly shaped GUI overlay that still allows me to reach the buttons on the bottom GUI. I still need to put some Controls on it and make it transparent, but I believe that it will be possible.


"I've seen your work in the past, and it's novice at best..." SmOke_N

Share this post


Link to post
Share on other sites

After trying a few methods, I went back to an "easier" one of just creating separately defined GUIs for each portion of the HUD. No problems addressing them. No problems with focus. Here is a stripped-down example to illustrate how I made a HUD (heads up display) that displays data (as groups of color coded graphs) over another program. Need to set Windows desktop theme to "Classic" to get smooth bars. Sorry about the "monkey code". This is about as good as I get, for now.

#include <GUIConstants.au3>
;example HUD (heads up display) that displays data (as groups of color coded graphs) over another program
;allow access to the controls underneath
;must set Windows theme to "Classic" to get smooth bars

Dim $progressbarv[10]
Dim $progressbarr[10]
Dim $progressbara[10]
Dim $progressbars[10]
Dim $progressbarw[10]
Dim $HUD[10]

;these numbers are to set up the bars
$rightcoord = 1
$downcoord = 1
$height = 50
$rightspacing = 8
$barwidth = 9

;defines bar colors
$color1 = 0X800080;purple
$color2 = 0XFFFF00;yellow
$color3 = 0XFF0000;red
$color4 = 0X000080;navy
$color5 = 0X00FF00;green
$color14 = 0xC6C6C6;another gray

;HUD transparency if desired
$transnum = 255; transparency: A number in the range 0 - 255. The smaller the number, the more transparent the window will become.

;creates the HUDs
$HUD[1] = GUICreate("HUD 1", 43, 52, 565, 90, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 1
_formatbars()

$HUD[2] = GUICreate("HUD 2", 43, 52, 565, 145, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 2
_formatbars()

$HUD[3] = GUICreate("HUD 3", 43, 52, 565, 335, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 3
_formatbars()

$HUD[4] = GUICreate("HUD 4", 43, 52, 565, 393, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 4
_formatbars()

$HUD[5] = GUICreate("HUD 5", 43, 52, 415, 393, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 5
_formatbars()

$HUD[6] = GUICreate("HUD 6", 43, 52, 265, 393, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 6
_formatbars()

$HUD[7] = GUICreate("HUD 7", 43, 52, 265, 335, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 7
_formatbars()

$HUD[8] = GUICreate("HUD 8", 43, 52, 265, 145, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 8
_formatbars()

$HUD[9] = GUICreate("HUD 9", 43, 52, 265, 90, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$x = 9
_formatbars()

;main statistical analysis code goes here
;takes data from the target program, performs statistical analysis, displays it in HUD
;this is just some sample data to send to the bars
GUICtrlSetData($progressbarv[1], 40);sample data
GUICtrlSetData($progressbarr[1], 20);sample data
GUICtrlSetData($progressbara[1], 10);sample data
GUICtrlSetData($progressbars[1], 25);sample data
GUICtrlSetData($progressbarw[1], 50);sample data

GUICtrlSetData($progressbarv[2], 50);sample data
GUICtrlSetData($progressbarr[2], 20);sample data
GUICtrlSetData($progressbara[2], 20);sample data
GUICtrlSetData($progressbars[2], 55);sample data
GUICtrlSetData($progressbarw[2], 10);sample data

GUICtrlSetData($progressbarv[3], 60);sample data
GUICtrlSetData($progressbarr[3], 10);sample data
GUICtrlSetData($progressbara[3], 40);sample data
GUICtrlSetData($progressbars[3], 65);sample data
GUICtrlSetData($progressbarw[3], 20);sample data

GUICtrlSetData($progressbarv[4], 70);sample data
GUICtrlSetData($progressbarr[4], 10);sample data
GUICtrlSetData($progressbara[4], 60);sample data
GUICtrlSetData($progressbars[4], 85);sample data
GUICtrlSetData($progressbarw[4], 40);sample data

GUICtrlSetData($progressbarv[5], 80);sample data
GUICtrlSetData($progressbarr[5], 30);sample data
GUICtrlSetData($progressbara[5], 80);sample data
GUICtrlSetData($progressbars[5], 15);sample data
GUICtrlSetData($progressbarw[5], 30);sample data

GUICtrlSetData($progressbarv[6], 90);sample data
GUICtrlSetData($progressbarr[6], 10);sample data
GUICtrlSetData($progressbara[6], 40);sample data
GUICtrlSetData($progressbars[6], 75);sample data
GUICtrlSetData($progressbarw[6], 60);sample data

GUICtrlSetData($progressbarv[7], 10);sample data
GUICtrlSetData($progressbarr[7], 50);sample data
GUICtrlSetData($progressbara[7], 80);sample data
GUICtrlSetData($progressbars[7], 35);sample data
GUICtrlSetData($progressbarw[7], 10);sample data

GUICtrlSetData($progressbarv[8], 20);sample data
GUICtrlSetData($progressbarr[8], 20);sample data
GUICtrlSetData($progressbara[8], 70);sample data
GUICtrlSetData($progressbars[8], 95);sample data
GUICtrlSetData($progressbarw[8], 80);sample data

GUICtrlSetData($progressbarv[9], 30);sample data
GUICtrlSetData($progressbarr[9], 40);sample data
GUICtrlSetData($progressbara[9], 20);sample data
GUICtrlSetData($progressbars[9], 45);sample data
GUICtrlSetData($progressbarw[9], 70);sample data

While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func _settrancs($window, $trans)
   WinSetTrans($window, '', $trans)
EndFunc  ;==>_settrancs

Func _formatbars()
   _settrancs($HUD[$x], $transnum); transparency: A number in the range 0 - 255. The smaller the number, the more transparent the window will become.
   GUISetState()
   $progressbarv[$x] = GUICtrlCreateProgress(($rightcoord), $downcoord, $barwidth, $height, $PBS_SMOOTH + $PBS_VERTICAL)
   GUICtrlSetColor(-1, $color1)
   GUICtrlSetBkColor(-1, $color14)
   $progressbarr[$x] = GUICtrlCreateProgress(($rightcoord) + ($rightspacing * 1), $downcoord, $barwidth, $height, $PBS_SMOOTH + $PBS_VERTICAL)
   GUICtrlSetColor(-1, $color2)
   GUICtrlSetBkColor(-1, $color14)
   $progressbara[$x] = GUICtrlCreateProgress(($rightcoord) + ($rightspacing * 2), $downcoord, $barwidth, $height, $PBS_SMOOTH + $PBS_VERTICAL)
   GUICtrlSetColor(-1, $color3)
   GUICtrlSetBkColor(-1, $color14)
   $progressbars[$x] = GUICtrlCreateProgress(($rightcoord) + ($rightspacing * 3), $downcoord, $barwidth, $height, $PBS_SMOOTH + $PBS_VERTICAL)
   GUICtrlSetColor(-1, $color4)
   GUICtrlSetBkColor(-1, $color14)
   $progressbarw[$x] = GUICtrlCreateProgress(($rightcoord) + ($rightspacing * 4), $downcoord, $barwidth, $height, $PBS_SMOOTH + $PBS_VERTICAL)
   GUICtrlSetColor(-1, $color5)
   GUICtrlSetBkColor(-1, $color14)
EndFunc  ;==>_formatbars

"I've seen your work in the past, and it's novice at best..." SmOke_N

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0