StatusBar Context Menu

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

StatusBar Context Menu

10 Nov 2015, 08:44

I have added a StatusBar to my GUI. I want to be able to right-click the third part of the StatusBar to display a menu.

My question is: Is it possible to detect which part of the StatusBar I am clicking? The WindowSpy tool seems unable to read the StatusBar text. Is the only option to read the coordinates of the mouse to determine the StatusBar part?

Code: Select all

GUIW := 600, GUIH := 400

Gui, +LastFound +Resize
;Gui, Color, FFFFFF
Gui, Margin, 10, 10

Gui, Add, Button, % " x" 10 " y" 10 " w" 73 " h" 26, % "Button1"

Gui, Add, StatusBar,,
SB_SetParts(200, 200, 200)
SB_SetText("`tTEXT", 3)

Gui, Show, % " w" GUIW " h" GUIH, % "Application"
return ; End automatic execution
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: StatusBar Context Menu

10 Nov 2015, 08:54

that docs are your friend here, see the documentations for the statusbar:

Code: Select all

GUIW := 600, GUIH := 400
Menu, SB_ContextMenu, Add, Here I am, MenuHandler ; the context menu
Gui, +LastFound +Resize
;Gui, Color, FFFFFF
Gui, Margin, 10, 10
 
Gui, Add, Button, % " x" 10 " y" 10 " w" 73 " h" 26, % "Button1"
 
Gui, Add, StatusBar, gStatusbarLabel
SB_SetParts(200, 200, 200)
SB_SetText("`tTEXT", 3)
 
Gui, Show, % " w" GUIW " h" GUIH, % "Application"
return ; End automatic execution

GuiEscape:
GuiClose:
ExitApp
return

StatusbarLabel:
if (A_GuiEvent="RightClick" || A_GuiEvent="Normal") && (A_EventInfo=3){ ; clicking or right clicking the 3th part of the stausbar to change the player
	StatusBarGetText, txt, %A_EventInfo%
	Menu, SB_ContextMenu, Show, %A_GuiX%, %A_GuiY%
}
return
MenuHandler:
MsgBox, ,text, the 3rd part text is:`n"%txt%"
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 183 guests