kor Posted February 23, 2011 Posted February 23, 2011 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?
JoHanatCent Posted February 23, 2011 Posted February 23, 2011 (edited) On 2/23/2011 at 3:01 AM, 'kor said: 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 February 23, 2011 by JoHanatCent
Moderators Melba23 Posted February 23, 2011 Moderators Posted February 23, 2011 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 WEndAll clear? M23 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: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Malkey Posted February 23, 2011 Posted February 23, 2011 Here is an OnEvent mode, cross between JoHanatCent and Melba23 examples, script. expandcollapse popupHotKeySet("{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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now