Jump to content

Wanting to use multiple Tooltips for instructions


timmyc
 Share

Recommended Posts

Hi all,

I am wanting to use multiple tooltips similar to the one below to give instructions for a process. I like below as it follows the cursor. 

ToolTip("Paused Script", MouseGetPos(0) + 25, MouseGetPos(1) + 10, "---Testing---", 1)

User would start the .exe file and tooltip would appear and when the user pressed Right arrow the next tip would appear and so on until the final tooltip where the script would exit.

For example - Start .exe - Tip 1 appears - Right arrow pressed - Tip 2 appears - Right arrow pressed - Tip 3 appears - Right arrow pressed - Exit.
Any help would be greatly appreciated.

Thanks!

 

Link to comment
Share on other sites

Here one simple way :

#include <Constants.au3>
#include <GUIConstants.au3>

Opt ("MustDeclareVars", 1)
Global Const $aTooltip = ["First tooltip", "Second tooltip", "Third tooltip", "Last tooltip"]

Local $hGUI = GUICreate ("Tooltip")
Local $idButton = GUICtrlCreateButton ("OK", 150, 150, 89, 25)

Local $idDummy = GUICtrlCreateDummy ()
Local $aAccelKeys[1][2] = [["{RIGHT}", $idDummy]]
GUISetAccelerators($aAccelKeys)

GUISetState ()

Local $iTootip = 0, $iX = -1, $iY = -1

While True
  Switch GUIGetMsg ()
    Case $GUI_EVENT_CLOSE, $idButton
      ExitLoop
    Case $idDummy
      $iTootip += 1
      If $iTootip = UBound ($aTooltip) Then ExitLoop
      $iX = -1
  EndSwitch
  If $iX <> MouseGetPos(0) Or $iY <> MouseGetPos(1) Then
   ToolTip($aTooltip[$iTootip], MouseGetPos(0) + 25, MouseGetPos(1) + 10, "--Test--", 1)
   $iX = MouseGetPos(0)
   $iY = MouseGetPos(1)
  EndIf
WEnd

 

Edited by Nine
corrected a small bug
Link to comment
Share on other sites

HotKeySet("{ESC}","Exit1")
HotKeySet("{RIGHT}","ToolToggle")
$tipcount=1

ToolToggle()

while 1

WEnd



Func ToolToggle()
    if $tipcount=1 Then
        ToolTip("ToolTip-1", MouseGetPos(0) + 25, MouseGetPos(1) + 10, "---Testing---", 1)
    Elseif $tipcount=2 Then
        ToolTip("ToolTip-2", MouseGetPos(0) + 25, MouseGetPos(1) + 10, "---Testing---", 1)
    Elseif $tipcount=3 Then
        ToolTip("ToolTip-3", MouseGetPos(0) + 25, MouseGetPos(1) + 10, "---Testing---", 1)
    Else
        ToolTip("ToolTip-4", MouseGetPos(0) + 25, MouseGetPos(1) + 10, "---Testing---", 1)

    EndIf
    $tipcount+=1

    if $tipcount>=6 Then
        Exit
    EndIf

    EndFunc

one simple way

 

or

;this is a little cleaner 

HotKeySet("{ESC}","Exit1")
HotKeySet("{RIGHT}","ToolToggle")
$tipcount=1
dim $tooltipdata[4]=['Data1', 'Data2', 'Data3', 'Data4']
ToolToggle()

while $tipcount<5

WEnd



Func ToolToggle()
ToolTip("ToolTip-" & $tipcount, MouseGetPos(0) + 25, MouseGetPos(1) + 10, $tooltipdata[$tipcount-1], 1)

$tipcount+=1

    EndFunc

Func Exit1()
    Exit
    EndFunc

this also works

HotKeySet("{ESC}","Exit1")
HotKeySet("{RIGHT}","ToolToggle")
Global $tipcount=1
dim $tooltipdata[4]=['Data1', 'Data2', 'Data3', 'Data4']


for $x=1 to 4
ToolTip("ToolTip-" & $tipcount, MouseGetPos(0) + 25, MouseGetPos(1) + 10, $tooltipdata[$tipcount-1], 1)
    while $tipcount<5
        if $tipcount>$x Then
            ExitLoop
        EndIf
    WEnd
Next

Func ToolToggle()
$tipcount+=1
EndFunc

Func Exit1()
    Exit
    EndFunc

 

Edited by markyrocks
Link to comment
Share on other sites

Thanks @markyrocks & @Nine!

Can you help me find which part of the below script (found while googling) allows the tooltip to follow the cursor?

Thanks! :)
 

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hButton1 = GUICtrlCreateButton("Show", 10, 10, 80, 30)
$hButton2 = GUICtrlCreateButton("Hide", 10, 50, 80, 30)

$hLabel = GUICtrlCreateLabel("0", 10, 100, 80, 40)
GUICtrlSetFont(-1, 18)

GUISetState()

$iBegin = TimerInit()
$iCount = 0

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton1
            $aPos = WinGetPos($hGUI)
            Tooltip("Testing!", $aPos[0] + 100, $aPos[1] + 100)
        Case $hButton2
            ToolTip("")
    EndSwitch

    If TimerDiff($iBegin) > 1000 Then
        $iCount += 1
        GUICtrlSetData($hLabel, $iCount)
        $iBegin = TimerInit()
    EndIf

WEnd

 

Link to comment
Share on other sites

Yep, love the examples. Thanks for them!

What i mean is your examples the tooltip appears where the cursor is but doesn't follow the cursor

In the example i have given above the tooltip appears at the cursor and then follows the cursor.

I'm thinking its something to do with this bit and i have tried playing around with it but cant get it to follow the cursor.

$aPos = WinGetPos($hGUI)
            Tooltip("Testing!", $aPos[0] + 100, $aPos[1] + 100)

Thanks! 

 

 

 

Link to comment
Share on other sites

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...