Jump to content

how to display tooltip while doing other things?


kor
 Share

Recommended Posts

Every code example I can find with tooltip being used has a sleep right after it.

How does one display a tool tip for x seconds (or forever until a tooltip("") is called) while also continuing on with the script?

Under help for Hotkeyset:

Global $Paused
HotKeySet("{PAUSE}", "TogglePause");<< To switch Tooltip on or off
While 1
    Sleep(33)
WEnd
Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(11)
        ToolTip("Paused Script", MouseGetPos(0) + 25, MouseGetPos(1) + 10, "-----Title-----", 1)
;Can do some other stuff for example here!
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause
Edited by JoHanatCent
Link to comment
Share on other sites

  • Moderators

kor,

Tooltips stay active until you close them and the script continues while they are shown as this demonstrates: ;)

#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

All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Here is an OnEvent mode, cross between JoHanatCent and Melba23 examples, script.

HotKeySet("{PAUSE}", "TogglePause");<< To switch Tooltip on or off

Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled

Global $Paused = True
Local $hGUI, $iLabel, $iBegin, $iCount

$hGUI = GUICreate("Test", 500, 500)
GUISetOnEvent(-3, "Terminate")

$iLabel = GUICtrlCreateLabel("0", 10, 50, 280, 80)
GUICtrlSetFont(-1, 36, 800)
$iButton1 = GUICtrlCreateButton("Toggle ToolTip", 10, 10, 80, 30)
GUICtrlSetOnEvent($iButton1, "TogglePause")

GUISetState()

$iBegin = TimerInit()
$iCount = 0

While 1
    Sleep(10) ; Sleep within loop to reduce CPU usage.
    If $Paused = True Then ToolTip("Press Paused to toggle Tooltip", _
            MouseGetPos(0) + 25, MouseGetPos(1) + 10, "-----Title-----", 1)

    ;Can do some other stuff for example here!

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


Func TogglePause()
    $Paused = Not $Paused
    If $Paused = False Then ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate
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...