lolikols
lolikols

Reputation: 87

Permanent Tooltip in the Upper Right-Hand corner of screen

I have a bit of an issue. I need a tooltip to be placed in the upper right hand corner of my screen (and I work with several different computers with different resolutions) that will not go away until the script is terminated, but will change its text based on the hotkeys that are pressed. Can anyone give me an example to work with? I found several things on Google, but nothing like what I'm looking for.

Example:

key_SIMPLE1:="F1"
key_SIMPLE2:="F2"
key_SIMPLE3:="F3"
key_COMPLEX1:="F4"


loop 
{
sleep 1


if GetKeyState(key_SIMPLE1)
{
Tooltip, Simple Mode 1
SetTimer, ResetTooltip, -500
}

if GetKeyState(key_SIMPLE2)
{
Tooltip, Simple Mode 2
SetTimer, ResetTooltip, -500
}

if GetKeyState(key_SIMPLE3)
{
Tooltip, Simple Mode 3
SetTimer, ResetTooltip, -500
}

if GetKeyState(key_COMPLEX1)
{
Tooltip, Complex Mode 1
SetTimer, ResetTooltip, -500
}

So basically I have a tooltip that shows up at the mouse position indicating what the user has selected. This tooltip goes away. I'm interested in getting a second tooltip (that doesn't go away - and by default says "Nothing") that changes based on what hotkey is pressed.

So, if I press F1, I see a tooltip near my mouse that says "Simple Mode 1" (this one disappears) and a second tooltip in the upper right hand corner that also says "Simple Mode 1" that doesn't disappear.

And then if I press F2, I see a tooltip near my mouse that says "Simple Mode 2" (this one disappears) and the second tooltip updates to say "Simple Mode 2".

Upvotes: 0

Views: 3157

Answers (3)

Jim U
Jim U

Reputation: 3366

This displays a tool tip at the mouse position and the upper right corner of the screen. The mouse-cursor tool tip disappears after 1 second

CoordMode tooltip, screen

F1::show("Simple Mode 1")
F2::show("Simple Mode 2")
F3::show("Simple Mode 3")

show(text) {
  tooltip %text%
  tooltip %text%, A_ScreenWidth - 100, 0, 9
  settimer clear_tool_tip, -1000
}

clear_tool_tip:
  tooltip
  return

Upvotes: 3

HaveSpacesuit
HaveSpacesuit

Reputation: 4014

This script should get you going. Instead of running a loop constantly to check the mode, just call a function when your hotkey is pressed.

If used on multiple monitors, it will only show on the main monitor.

F5 and F6 will call a permanent Tooltip to stay in the top "right" corner, though it will not be possible to get it in exactly the right corner.

F7 and F8 will call a permanent SplashText title bar to stay in the top right corner. You can get this to stay in the exact corner, and looks nicer in my opinion. It has the side effect of hiding the minimize and close icons of maximized windows. I got around this by a) moving the SplashText down 20 pixels and b) setting the TransColor so clicks will fall through to the window behind it.

The Tooltip/SplashText will go away when the script closes.

; will have issues with multiple monitors (will only show on main monitor)

; used to place tooltips relative to screen instead of active window
CoordMode, ToolTip ; https://autohotkey.com/docs/commands/CoordMode.htm

ShowSplash("Nothing", 300)

F5::ShowTooltip("Mode 5", 200)

F6::ShowTooltip("Mode 6", 200)

F7::ShowSplash("Mode 7", 300)

F8::ShowSplash("Mode 8", 300)

ShowTooltip(title, width) ; https://autohotkey.com/docs/commands/ToolTip.htm
{
    Tooltip ; remove existing tooltip
    Tooltip %title%, A_ScreenWidth - width, 0
}

ShowSplash(title, width) ; https://autohotkey.com/docs/commands/SplashTextOn.htm
{
    SplashTextOff ; remove existing splash text
    SplashTextOn, width, , %title%
    WinMove, %title%, , A_ScreenWidth - width, 20 ; moved down a bit so can see close buttons in top corner
    WinSet, TransColor, White, %title% ; allows to click through white, so can close windows under SplashText   
}

Upvotes: 0

Jim U
Jim U

Reputation: 3366

This displays a tool tip in the upper right hand corner of the screen when F4 is pressed, and removes it when F1, F2, or F3 is pressed.

CoordMode tooltip, screen
F1::
F2::
F3::tooltip ,,,,9
F4::tooltip  Blah Boo, A_ScreenWidth - 100, 0, 9

Upvotes: 0

Related Questions