Jump to content
Sign in to follow this  
Saad

How to read control hint when created in Koda

Recommended Posts

I used Koda 1.7.2.0 to create a script GUI. I set the control Hint. While the script is running, I need to read some or all controls "Hint ". I could not find a function to accomplish that.

Here is some of the code created by Koda:

...
...
$chkOptions7 = GUICtrlCreateCheckbox("EA Field.", 88, 312, 425, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "/EA")
...
...

The Hint value of chkOptions7 is "/EA".

How can I read the Hint value of $chkOptions7 field?

 

Share this post


Link to post
Share on other sites
3 hours ago, Saad said:

How can I read the Hint value of ....

Save the hint in a variable yourself, to keep track of what you set it as.

...
$chkOptions7 = GUICtrlCreateCheckbox("EA Field.", 88, 312, 425, 17)
GUICtrlSetFont($chkOptions7, 10, 400, 0, "MS Sans Serif")
$chkOptions7_hint = "/EA"
GUICtrlSetTip($chkOptions7, $chkOptions7_hint)
...

GuiCtrlGetTip() does not exist :( 

Edited by argumentum

Share this post


Link to post
Share on other sites

Hello. If you set the value on the fly you could store in a variable. It's a known value. 

just for fun

#include <GUIConstantsEx.au3>
#include <AutoItConstants.au3>
Global $g_oToolTipDic = ObjCreate("Scripting.Dictionary") ;this for store all the Tooltips




Example()

Func Example()
    GUICreate("My GUI control tip") ; will create a dialog box that when displayed is centered

    Local $idLabel1 = GUICtrlCreateLabel("my label 1 - click me to get the tip text", 10, 20)
    _GUICtrlSetTip(-1, "tip of my label 1")

    Local $idLabel2 = GUICtrlCreateLabel("my label 2 - click me to get the tip text", 10, 60)
    _GUICtrlSetTip(-1, "tip of my label 2")

    Local $idbtn= GUICtrlCreateButton("Change Tips of label 1 and label 2",100,200,200,30)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idLabel1
                MsgBox(0, "", _GUICtrlGetTip($idLabel1))
            Case $idLabel2
                MsgBox(0, "", _GUICtrlGetTip($idLabel2))

            Case $idbtn
                _GUICtrlSetTip($idLabel1, "tip of my label 1 is changed")
                _GUICtrlSetTip($idLabel2, "tip of my label 2 is changed")
                MsgBox(0,"","labels' Tips changed",2)


        EndSwitch
    WEnd
EndFunc   ;==>Example

Func _GUICtrlGetTip($iControlID)
    Local $sTipText = ""
    If $g_oToolTipDic.Exists(String(GUICtrlGetHandle($iControlID))) Then
        $sTipText = $g_oToolTipDic.Item(String(GUICtrlGetHandle($iControlID)))
    EndIf
    Return $sTipText
EndFunc   ;==>_GUICtrlGetTip


Func _GUICtrlSetTip($iControlID, $sTipText, $sTipTitle = "", $iIcon = $TIP_NOICON, $iOptions = 0)
    If Not $g_oToolTipDic.Exists(String(GUICtrlGetHandle($iControlID))) Then
        $g_oToolTipDic.Add(String(GUICtrlGetHandle($iControlID)), $sTipText)
    Else
        $g_oToolTipDic.Item(String(GUICtrlGetHandle($iControlID))) = $sTipText
    EndIf
    GUICtrlSetTip($iControlID, $sTipText, $sTipTitle, $iIcon, $iOptions)
EndFunc   ;==>_GUICtrlSetTip

Saludos

 

Share this post


Link to post
Share on other sites

Thank you all.

Yes, unfortunately,  GuiCtrlGetTip() does not exist :( but GUICtrlSetTip exist.

I was hoping for a more straight simple solution that allows me to use Koda and not set the Hint/Tip through the code.

Have a nice holiday and happy new year (2018).

Share this post


Link to post
Share on other sites
7 minutes ago, Saad said:

Yes, unfortunately,  GuiCtrlGetTip() does not exist

There is _GUIToolTip_GetText though.

Also, the straight forward answer is to keep track of what you're setting the tips to, anything else is complicating things immensely. Koda is merely training wheels for you, learn to ride the bike without them, you'll be better off.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

_GUIToolTip_GetText does not retrieve what  GUICtrlSetTip sets.

It is a matter of preference and I'm not debating the issue. I know how to set the controls in the code without Koda and keep track of what has been set.

To me, using Koda to set the GUI is easier and more "set it and forget it". :)

Share this post


Link to post
Share on other sites
18 minutes ago, Saad said:

_GUIToolTip_GetText does not retrieve what  GUICtrlSetTip sets.

Sure it does.

See the modifications I did below to @Danyfirex's script from above. Hit the hotkey "t" to have it display what the currently visible tooltip is displaying.

#include <GUIConstantsEx.au3>
#include <AutoItConstants.au3>
#include <GUITooltip.au3> ; <<<<<<<<<<<<<<<<<<<<<<<

Global $g_oToolTipDic = ObjCreate("Scripting.Dictionary") ;this for store all the Tooltips
HotKeySet("t", "_GUICtrlGetTip2") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<



Example()

Func Example()
    GUICreate("My GUI control tip") ; will create a dialog box that when displayed is centered

    Local $idLabel1 = GUICtrlCreateLabel("my label 1 - click me to get the tip text", 10, 20)
    _GUICtrlSetTip(-1, "tip of my label 1")

    Local $idLabel2 = GUICtrlCreateLabel("my label 2 - click me to get the tip text", 10, 60)
    _GUICtrlSetTip(-1, "tip of my label 2")

    Local $idbtn = GUICtrlCreateButton("Change Tips of label 1 and label 2", 100, 200, 200, 30)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idLabel1
                MsgBox(0, "", _GUICtrlGetTip($idLabel1))
            Case $idLabel2
                MsgBox(0, "", _GUICtrlGetTip($idLabel2))

            Case $idbtn
                _GUICtrlSetTip($idLabel1, "tip of my label 1 is changed")
                _GUICtrlSetTip($idLabel2, "tip of my label 2 is changed")
                MsgBox(0, "", "labels' Tips changed", 2)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func _GUICtrlGetTip($iControlID)
    Local $sTipText = ""
    If $g_oToolTipDic.Exists(String(GUICtrlGetHandle($iControlID))) Then
        $sTipText = $g_oToolTipDic.Item(String(GUICtrlGetHandle($iControlID)))
    EndIf
    Return $sTipText
EndFunc   ;==>_GUICtrlGetTip


Func _GUICtrlSetTip($iControlID, $sTipText, $sTipTitle = "", $iIcon = $TIP_NOICON, $iOptions = 0)
    If Not $g_oToolTipDic.Exists(String(GUICtrlGetHandle($iControlID))) Then
        $g_oToolTipDic.Add(String(GUICtrlGetHandle($iControlID)), $sTipText)
    Else
        $g_oToolTipDic.Item(String(GUICtrlGetHandle($iControlID))) = $sTipText
    EndIf
    GUICtrlSetTip($iControlID, $sTipText, $sTipTitle, $iIcon, $iOptions)
EndFunc   ;==>_GUICtrlSetTip

Func _GUICtrlGetTip2() ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Local $aTipList = WinList("[CLASS:tooltips_class32]")
    Local $aRet
    For $i = 1 To $aTipList[0][0]
        ; See which one is active
        $aRet = _GUIToolTip_GetCurrentTool($aTipList[$i][1])
        ; If one is active then display it
        If $aRet[8] <> "" Then MsgBox(0, "Visible Tip", $aRet[8])
    Next
EndFunc   ;==>_GUICtrlGetTip2

 


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
47 minutes ago, Saad said:

If I'm not mistaken,

You are mistaken, and you would have known that had you looked at and run the script I posted.

As you can see by danyfirex's script, the tips are being set by GUICtrlSetTip, he's just using it inside another function. They are then read with _GUIToolTip_GetText inside my addition.

 


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...