Hidden Menu Bar. aka FooMenuBar()

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Hidden Menu Bar. aka FooMenuBar()

12 Mar 2021, 14:13

I am currently working on a project that requires the use of a hidden menu bar to interact with the different parts of the script and I know that there are at least a few people out there that will find this useful or at the very least draw inspiration from it for something better, so I thought I would share this before it gets buried along with a million other scripts.

.
No toggle buttons
.
20210312132835.png
20210312132835.png (11.78 KiB) Viewed 773 times
.
Some toggle buttons.
.
20210312134257.png
20210312134257.png (13.5 KiB) Viewed 773 times
.

Operation.
.
temp.gif
temp.gif (130.1 KiB) Viewed 773 times
.


This menu was designed around using hotkeys to interact with it rater than typical mouse clicks, it was done this way to alleviate hand / wrist pain that can be caused by constant clicking in some people. Although it uses hotkeys, LButton can be a hotkey so in practice it can be interacted with in a familiar way. In the example code down below I have set it up with what I think are the best keys to use for this but you can use any key you want. You just need to set up the conditions for your hotkey if needed. For example if you used "e" as your hotkey to press the buttons etc. then you will likely want to set it up with some context #IF (Blah blah blah). If you are not sure how to set up hotkeys like that, you can ask in the ask for help section. It is just a general question and not script specific.

This version of the menu bar is hard coded at 5 buttons but I hope to circle back around to this menu when I am done with some other things and re-do it so you can add as many buttons/controls needed / wanted. I didn't spend a lot of time on the graphics for the menu because they were just a prototype I could work with so that I could start writing code around, so I definitely want to at the least give it a re-skin. Although the graphics are just a prototype, I think they don't look half bad, but beauty's in the eye blah blah blah.


Menu details:

The menu is comprised of 5 programmable buttons that can be used as traditional buttons or converted into a switch buttons (basically functions like a checkbox)

When you first run the script the menu will be hidden. To get the menu to appear, move your cursor to the top - center of your prime monitor and scroll your mouse wheel up or down.

With the menu visible, move your mouse over any button and then scroll your wheel to press the button.

To hide the menu again, move your cursor away from the top of your screen.

Requires these ahk libraries:
GDIP
LayeredWindow Class

Menu Set up:

Setup of the menu is very quick and easy and menus can be deployed across multiple scripts (one running at a time*)
Setting up the menu can be broken down into 3 parts.

Part 1: Creating the button array to pass to the class.

There are 5 buttons and each of them need a few bits of data from you or they will use the defaults they are programed with.

These data points are:

Name: ;<----- The text displayed on the button
Label: ;<----- The label to jump to when the button is pressed ( where you add your code )
Toggle: ;<----- Is this button a switch [ 0 , 1 ] *This is graphical only. You program the toggle on your end too.
Active: ;<----- Is this button currently toggled on [ 0 , 1 ]

Here is an example of everything needed to setup the button array.

Code: Select all

Buttons := []
Buttons[1] := { Name: "HUD 1" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 0 }
Buttons[2] := { Name: "Reset" 		, Label: "TestLabel" 		, Toggle: 0 	, Active: 0 }
Buttons[3] := { Name: "Report" 		, Label: "TestLabel" 		, Toggle: 0 	, Active: 0 }
Buttons[4] := { Name: "UnAssigned" 	, Label: "TestLabel" 		, Toggle: 0 	, Active: 0 }
Buttons[5] := { Name: "HUD 2" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 1 }
You can take that code and edit it to the values that you want to use.

.

Part 2: Creating an instance of the menu ( Creating the menu )

To create a menu you need only come up with a name that you want to call it ( "MyMenu" for example ),
and then call the new MenuBar() method and pass it the button object from earlier.

Code: Select all

MyMenu := New MenuBar( Buttons )
.
Part 3: Adding your labels and hotkeys.

Every button needs a label to go to when the button is pressed. This is where you add in the code to do what it is that you want to happen when you press the button. Perhaps you want to run the calculator when you press the button.

Code: Select all

MyLabel:
	run, calc.exe
	return
.
or perhaps you want to toggle a set of hotkeys or hotstrings.

Code: Select all

MyLabel:
	MyToggleVar := !MyToggleVar
	return
	

#If ( MyToggleVar )

;My Hotkeys...

;My Hotstrings...

#If	
You can use pretty much any hotkey you want to show and interact with the menu.
Here is an example of using the mouse wheel to do both show the menu and click its buttons and the right and left mouse buttons to only click the buttons (see comments further below for more info about right and left mouse clicks with this program)

Code: Select all

~LButton::
~RButton::
~WheelUp::
~WheelDown::
	MyMenu.Checkkeys( A_ThisHotkey )
	return
Lastly in regards to setting the menu up, here is a working example of using the menu in a script, it is stripped down of any comments or noise so you can see just how little is needed to get this working for yourself.

Code: Select all

#Include <My Altered Gdip Lib>
#Include <LayeredWindow Class>
#Include <Menu class>

Gdip_Startup()

Buttons := []
Buttons[1] := { Name: "HUD 1" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 0 }
Buttons[2] := { Name: "Reset" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 1 }
Buttons[3] := { Name: "Report" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 1 }
Buttons[4] := { Name: "UnAssigned" 	, Label: "TestLabel" 		, Toggle: 1 	, Active: 0 }
Buttons[5] := { Name: "HUD 2" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 1 }

MyMenu := New MenuBar( Buttons )

return

~WheelUp::
~WheelDown::
	MyMenu.Checkkeys( A_ThisHotkey )
	return

TestLabel:
	SoundBeep, 500
	return
Here is the same with comments added to help explain things.

Code: Select all

; This following code sets the settings for the script and the libs used.
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

;***************************************************************************************************
#Include <My Altered Gdip Lib>
#Include <LayeredWindow Class>
#Include 
;***************************************************************************************************
#SingleInstance, Force
;~ SetBatchLines, -1
#NoEnv

;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


;This following code loads the gdi+ lib.
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;This whole script revolves around the use of gdip so there won't be any need to unload gdip until the script exits.

Gdip_Startup()

;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

;This following code is how a new menu is created.
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;First a button object is created and populated with the following 4 properties.
;Each button requires a Name. The name is used as the text on the button.
;Each button requires a Label. The name of the subroutine that you want to run when this button is activated.
;Each button requires being set to be a button that has a toggle state or not. ( Values 0 or 1 ) If set to 1 the button will have a little indicator light that shows its current toggle state
;Each button requires having its current toggle state set.

Buttons := []
Buttons[1] := { Name: "HUD 1" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 0 }
Buttons[2] := { Name: "Reset" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 1 }
Buttons[3] := { Name: "Report" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 1 }
Buttons[4] := { Name: "UnAssigned" 	, Label: "TestLabel" 		, Toggle: 1 	, Active: 0 }
Buttons[5] := { Name: "HUD 2" 		, Label: "TestLabel" 		, Toggle: 1 	, Active: 1 }

;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

;This following code is how a new menu is created.
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;Pass the button object when creating the new menu. 

MyMenu := New MenuBar( Buttons )

;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

;The following code is where the labels for the button are. 
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

TestLabel:
	SoundBeep, 400
	return

;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

;The follow are the hotkeys that can be used to interact with the menu.
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

;The hotkeys do two things. 
;First they trigger the menu being shown when the user uses them while their cursor is up at the top of the screen.
;Second is that they are also used to interact with the buttons (Press them)
;There are two exceptions to the statements above. If LButton and RButton are used as hotkeys, they can be used only to interact with the buttons once they are visible, they can't (for obvious reasons) trigger the menu being shown.
~LButton::
~RButton::
~WheelUp::
~WheelDown::
	MyMenu.Checkkeys( A_ThisHotkey )
	return

;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

.
Here is the menu class, you can paste this right into a script or save it as its own file and use #Include
.

Code: Select all

;################################################################################################################################################################################################
;################################################################################################################################################################################################
;#########################################												Menu Bar class														#####################################
;################################################################################################################################################################################################
;################################################################################################################################################################################################
;Written By: Hellbent
;Date: March 5th 2021
;Description: This class is used to create a small menu bar with 5 buttons that sits at the top of the screen. 
;Each of the 5 buttons can be programed to do the same thing a normal gui button does.
class MenuBar	{
	static 	Index := 0 	, Init 
		, 	DrawCycle 	, DrawCycleTime := 200
		, 	KeyLock		, KeyPressed
	__New( Buttons ){
		static DrawCycle , KeyLock , KeyPress , DrawCycleTime := 200
		if( !Init && Init := 1 ){
			This._Bind( "DrawCycle" , "_Update" )
			This._Bind( "KeyLock" , "_UnLockKeys" )
			This._Bind( "KeyPressed" , "_ResetKeyPress" )
		}
		This._SetDefaults() 
		This._CreateButtons( Buttons )
		This._CreateWindow() 
	}
	_CreateButtons( Buttons ){
		local x := 14 , y := 8 , w := 150 , h := 29
		This.Button := []
		if(Buttons){
			This.ButtonNames := []
			This.Labels := []
			This.Toggable := []
			This.ButtonActive := []
			Loop, %  Buttons.Length()	{
				This.ButtonNames[A_Index] := Buttons[A_Index].Name 
				This.Labels[A_Index] := Buttons[A_Index].Label 
				This.Toggable[A_Index] := Buttons[A_Index].Toggle
				This.ButtonActive[A_Index] := Buttons[A_Index].Active 
			}
		}else{
			This.ButtonNames := ["Activate","Reset","Report","Unassigned","Unassigned"]
			This.Labels := ["Test1","","","","Test5"]
			This.Toggable := [1,0,0,0,1]
			This.ButtonActive := [0,0,0,0,0]
		}
		Loop, % This.ButtonNames.Length()	{
			This.Button[ A_Index ] := { Active: This.ButtonActive[A_Index] , ToggleButton: This.Toggable[A_Index] , Label: This.Labels[A_Index] , Hover: 0 , Pressed: 0 , Text: This.ButtonNames[ A_Index ] , Position: { X: x , Y: y , W: w , H: h , X2: x + w , Y2: y + h } }
			x += w + 5
		}
	}
	_UnLockKeys(){
		Critical, On
		This.KeysLocked := 0
	}
	_Update(){
		local ctrl , x , y 
		Critical, On
		CoordMode, Mouse, Screen
		MouseGetPos, x , y ,, ctrl , 2
		if( This._CheckActiveY( y ) )
			return
		if( This._SetHover() && This.Hover := This._CheckButtons( x , y ) )
			This.Button[ This.Hover ].Hover := 1
		if( This.KeyPress && !This.Pressed && This.Pressed := 1 )
			This._CheckKeypress()
		This._DrawMenu()
	}
	_CheckKeypress(){
		if( This.KeyPress ){
			This._ReSetPressed()
			This.Button[ This.CurrentButton ].Pressed := 1
			This._ToggleTimer( "KeyPressed" , -100 )
		}
	}
	_ResetKeyPress(){
		Critical, On
		This._ReSetPressed()
		This.KeyPress := 0
		This.Pressed := 0
		Try{
			sub := This.Button[ This.CurrentButton ].Label
			setTimer, % sub , -10
		}catch
			TrayTip,Failed, Could not connect with label
	}
	_ReSetPressed(){
		Loop, % This.Button.Length()
			This.Button[A_index].Pressed := 0
	}
	_SetHover(){
		Loop, % This.Button.Length()
			This.Button[A_index].Hover := 0
		return 1
	}
	CheckKeys( HK ){
		local x , y
		if( This.KeysLocked )
			return
		CoordMode, Mouse , Screen
		MouseGetPos, x , y 
		if( This._ActivateCheck( x , y , HK ) ){
			return
		}else if( This.Active && This.CurrentButton := This._CheckButtons( x , y ) ){
			This._LockKeys()
			This.KeyPress := 1
			This._CheckToggle()
		}
	}
	_CheckToggle(){
		if(This.Button[This.CurrentButton].ToggleButton)
			This.Button[This.CurrentButton].Active := !This.Button[This.CurrentButton].Active
	}
	_ActivateCheck( x , y , HK := "" ){
		if( !This.Active && y < 50 && x >= This.X && x <= This.X + This.W && ( HK != "~LButton" && HK != "~RButton" ) ){
			This._LockKeys()
			This._ToggleTimer( "DrawCycle" , MenuBar.DrawCycleTime )
			return 1
		}else 
			return 0
	}
	_LockKeys(){
		This.KeysLocked := 1
		This.Active := 1
		This._ToggleTimer( "KeyLock" , -300 )
	}
	_CheckButtons( x , y ){
		Loop, % This.Button.Length()	{
			if( x >= This.Button[ A_Index ].Position.X + This.X && x <=  This.Button[ A_Index ].Position.X2 + This.X && y >= This.Button[ A_Index ].Position.Y && y <=  This.Button[ A_Index ].Position.Y2 )
				return A_Index
		}
		return 0
	}
	_CheckActiveY( y ){
		if( y >= 100 ){
			This._ClearScreen()
			This.Active := 0
			This._ToggleTimer( "DrawCycle" , "Off" )
			return 1
		}
	}
	_CreateWindow(){
		local w
		This.HUD := New LayeredWindow( This.X , This.Y , w := This.W , This.H , "HUDMenu_" This.Number , " HUDMenu" , 2 , "+AlwaysOnTop -DPIScale +ToolWindow" , 1 , 0 )
	}
	_SetDefaults(){
		This.HUD := {}
		This.Active := 0
		This.Hover := 0
		This.KeysLocked := 0
		This.KeyPress := 0
		This.CurrentButton := ""
		This.Pressed := 0
		This.Number := ++MenuBarControl.Index
		This.W := 800
		This.H := 46
		This.X := ( A_ScreenWidth / 2 ) - ( This.W / 2 )
		This.Y := 0
	}
	_ClearScreen(){
		This.HUD.ClearWindow( 1 )
		This.HUD.UpdateWindow()
	}
	_DrawMenu(){
		This.HUD.ClearWindow()
		This.HUD.Draw( This._MenuBitmap() , { X: 0 , Y: 0 , W: This.W , H: This.H } , 1 , 1 )
		This.HUD.UpdateWindow()
	}
	_Bind( Key , Method ){
		This[ Key ] := ObjBindMethod( This , Method )
	}
	_ToggleTimer( Key , Timing ){
		local Timer := This[ Key ]
		SetTimer, % Timer , % Timing 
	}
	_MenuBitmap(){
		;Bitmap Created Using: HB Bitmap Maker
		local x , y , w , h
		pBitmap := Gdip_CreateBitmap( 800 , 46 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
		;Background
		Brush := Gdip_BrushCreateHatch( "0xaa32363a" , "0xaa02060a" , 39 ) , Gdip_FillRoundedRectangle( G , Brush , 1 , 1 , 797 , 43 , 5 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 4 , 2 , 788 , 40 , "0xaa0066aa" , "0xaa02060a" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 1 , 1 , 797 , 43 , 5 ) , Gdip_DeleteBrush( Brush )
		Pen := Gdip_CreatePen( "0xaa02060a" , 1 ) , Gdip_DrawRoundedRectangle( G , Pen , 1 , 1 , 797 , 43 , 5 ) , Gdip_DeletePen( Pen )
		Brush := Gdip_CreateLineBrushFromRect( 2 , 1 , 795 , 43 , "0xaa62666a" , "0xaa15191f" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 2 , 2 , 795 , 41 , 4 ) , Gdip_DeletePen( Pen )
		Brush := Gdip_BrushCreateSolid( "0x113399FF" ) , Gdip_FillRoundedRectangle( G , Brush , 3 , 4 , 793 , 17 , 6 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0x3302060a" ) , Gdip_FillRoundedRectangle( G , Brush , 3 , 21 , 793 , 18 , 6 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_CreateLineBrushFromRect( 4 , 3 , 790 , 38 , "0x11F0F0F0" , "0x1102060a" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 2 , 7 , 788 , 35 , 6 ) , Gdip_DeleteBrush( Brush )
		;Buttons 
		x := 14 , y := 8 , w := 150 , h := 29 
		Loop, % This.Button.Length()	{
			if( !This.Button[ A_Index ].Pressed ){
				Brush := Gdip_BrushCreateHatch( "0xaa32363a" , "0xaa02060a" , 39 ) , Gdip_FillRectangle( G , Brush , This.Button[ A_Index ].Position.X , This.Button[ A_Index ].Position.Y , This.Button[ A_Index ].Position.W , This.Button[ A_Index ].Position.H ) , Gdip_DeleteBrush( Brush )
				Brush := Gdip_CreateLineBrushFromRect( This.Button[ A_Index ].Position.X  , This.Button[ A_Index ].Position.Y , This.Button[ A_Index ].Position.W , This.Button[ A_Index ].Position.H , "0xaa0066aa" , "0xaa02060a" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , This.Button[ A_Index ].Position.X , This.Button[ A_Index ].Position.Y , This.Button[ A_Index ].Position.W , This.Button[ A_Index ].Position.H ) , Gdip_DeleteBrush( Brush )
			}else 
				Brush := Gdip_CreateLineBrushFromRect( This.Button[ A_Index ].Position.X  , This.Button[ A_Index ].Position.Y , This.Button[ A_Index ].Position.W , This.Button[ A_Index ].Position.H , "0xaa02060a" , "0xaa002266" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , This.Button[ A_Index ].Position.X , This.Button[ A_Index ].Position.Y , This.Button[ A_Index ].Position.W , This.Button[ A_Index ].Position.H ) , Gdip_DeleteBrush( Brush )
			Brush := Gdip_CreateLineBrushFromRect( This.Button[ A_Index ].Position.X  + 2 , This.Button[ A_Index ].Position.Y + 2 , This.Button[ A_Index ].Position.W - 4 , This.Button[ A_Index ].Position.H + 5 , ( !This.Button[A_Index].Hover ) ? ( "0x223399FF" ) : ( "0xaa3399FF" ) , ( !This.Button[A_Index].Hover ) ? ( "0x22006699" ) : ( "0xaa006699" ) , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , This.Button[ A_Index ].Position.X - 2 , This.Button[ A_Index ].Position.Y - 2 , This.Button[ A_Index ].Position.W + 4 , This.Button[ A_Index ].Position.H + 4 ) , Gdip_DeletePen( Pen )
			Brush := Gdip_CreateLineBrushFromRect( This.Button[ A_Index ].Position.X  , This.Button[ A_Index ].Position.Y , This.Button[ A_Index ].Position.W , This.Button[ A_Index ].Position.H , "0xaa001144" , "0xaa000409" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , This.Button[ A_Index ].Position.X , This.Button[ A_Index ].Position.Y , This.Button[ A_Index ].Position.W , This.Button[ A_Index ].Position.H ) , Gdip_DeletePen( Pen )
			Brush := Gdip_CreateLineBrushFromRect( This.Button[ A_Index ].Position.X  , 9 , 153 , 29 , "0x44002266" , "0x2202060a" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , This.Button[ A_Index ].Position.X - 1 , This.Button[ A_Index ].Position.Y - 1 , This.Button[ A_Index ].Position.W + 2 , This.Button[ A_Index ].Position.H + 2 ) , Gdip_DeletePen( Pen )
			Brush := Gdip_BrushCreateSolid( "0x333399FF" ) , Gdip_FillRectangle( G , Brush , This.Button[ A_Index ].Position.X + 2 , 10 , 146 , 13 ) , Gdip_DeleteBrush( Brush )
			Brush := Gdip_CreateLineBrushFromRect( This.Button[ A_Index ].Position.X  , 25 , 143 , 10 , "0x6622262a" , "0x6602060a" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , This.Button[ A_Index ].Position.X + 2 , This.Button[ A_Index ].Position.Y + 17 , This.Button[ A_Index ].Position.W - 4 , This.Button[ A_Index ].Position.H - 16 ) , Gdip_DeleteBrush( Brush )
			if( This.Button[A_Index].ToggleButton ){
				Brush := Gdip_BrushCreateSolid( ( This.Button[A_Index].Active ) ? ( "0xff3399FF" ) : ( "0x663399FF" ) ) , Gdip_FillRectangle( G , Brush , This.Button[ A_Index ].Position.X + 10 , This.Button[ A_Index ].Position.Y + 10 , 8 , 8 ) , Gdip_DeleteBrush( Brush )
				Brush := Gdip_CreateLineBrushFromRect( This.Button[ A_Index ].Position.X + 5 , 11 , 15 , 20 , "0x66006699" , "0xFF02060a" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , This.Button[ A_Index ].Position.X + 5 , This.Button[ A_Index ].Position.Y + 5 , 18 , 18 ) , Gdip_DeletePen( Pen )
			}
			Brush := Gdip_BrushCreateSolid( "0xFF02060a" ) , Gdip_TextToGraphics( G , ( This.Button[A_Index].Active ) ? ( This.Button[ A_Index ].Text ) : ( This.Button[ A_Index ].Text ) , "s12 Center vCenter Bold c" Brush " x" This.Button[ A_Index ].Position.X + 1 " y10" , "Segoe ui" , w , h ) , Gdip_DeleteBrush( Brush )
			Brush := Gdip_BrushCreateSolid( "0xFF22262a" ) , Gdip_TextToGraphics( G , ( This.Button[A_Index].Active ) ? ( This.Button[ A_Index ].Text ) : ( This.Button[ A_Index ].Text ) , "s12 Center vCenter Bold c" Brush " x" This.Button[ A_Index ].Position.X - 1 " y8" , "Segoe ui" , w , h ) , Gdip_DeleteBrush( Brush )
			Brush := Gdip_BrushCreateSolid( ( !This.Button[A_Index].ToggleButton ) ? ( "0xFF92969a" ) : ( ( This.Button[A_Index].Active ) ? ( "0xff3399FF" ) :( "0x993399FF" ) ) ) , Gdip_TextToGraphics( G , ( This.Button[A_Index].Active ) ? ( This.Button[ A_Index ].Text ) : ( This.Button[ A_Index ].Text ) , "s12 Center vCenter Bold c" Brush " x" This.Button[ A_Index ].Position.X " y9" , "Segoe ui" , 150 , 29 ) , Gdip_DeleteBrush( Brush )
			Pen := Gdip_CreatePen( "0x223399FF" , 2 ) , Gdip_DrawLine( G , Pen , This.Button[ A_Index ].Position.X + 2 , 11 , This.Button[ A_Index ].Position.X + 148 , 11 ) , Gdip_DeletePen( Pen )
			x += w + 5
		}
		Gdip_DeleteGraphics( G )
		return pBitmap
	}
}

Here are a few ideas on what you can use this for.

Turn on or off sets of hotkeys
Turn on or off sets of hotstrings.
Launch a webpage
Launch a program
...

Hopefully I have covered everything, and I hope someone finds this useful.
Mika_erdo
Posts: 41
Joined: 30 Jul 2020, 17:23

Re: Hidden Menu Bar. aka FooMenuBar()

13 Mar 2021, 15:02

Excellent stuff as always, cant really delve into it now but I am saving it for later.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Hidden Menu Bar. aka FooMenuBar()

14 Mar 2021, 13:55

kczx3 wrote:
13 Mar 2021, 14:50
Guess it’s a custom AppBar then?
https://docs.microsoft.com/en-us/windows/win32/shell/application-desktop-toolbars
That could be a common name for it, I don't have a clue what others call things on their computers because it doesn't really come up in conversation and I don't work on a computer for a living so there isn't really much pushing me to pick up the lingo.

All I can say about the button bar is that it was created as part of a larger project that required a way of interfacing with the other parts. So that could be to launch applications or navigate to web pages etc. My use of it was to toggle a couple of HUD elements and save files based on the values taken from the HUD elements.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 81 guests