vvb Posted September 12, 2012 Posted September 12, 2012 Hi All, I am creating a simple user input form which contains a number of standard inputs and some IP address inputs created using _GUICtrlIpAddress_Create. I am able to add a tooltip to the standard inputs using GUICtrlSetTip but am not able to for the IP Addresses. I've tried the following and nothing appears: Func SetToolTip($form, $ctrl, $tip) Local $ExtStyle = 0 Local $ctrlHdl = GUICtrlGetHandle($ctrl) Local $tipHdl = _GUIToolTip_Create($ctrlHdl, BitOR($TTS_ALWAYSTIP, $TTS_NOPREFIX)) _GUIToolTip_AddTool($tipHdl, 0, $tip, $ctrlHdl, 0, 0, 0, 0, 0, 0) EndFunc All help much appreciated as I would not want to go down the path of monitoring the mouse position as there are more than 20 inputs. Kind Regards, Vlad I'll be AutoIting my entire system soon.
Moderators JLogan3o13 Posted September 12, 2012 Moderators Posted September 12, 2012 Can you please post the entirety of your code, or a short reproducer? The Tooltip function by itself kind of has us shooting in the dark for an answer to your problem "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
vvb Posted September 13, 2012 Author Posted September 13, 2012 Hi JLogan3o13, Following is a sample of the script I am writing: expandcollapse popup#include <Misc.au3> #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <GuiToolTip.au3> _Main() Func _Main() ; Ensures only one instance is running. _Singleton(@ScriptName, 0) ; Enable on event GUI Opt("GUIOnEventMode", 1) ; Sleep time in idle loop Global Const $SLEEP_TIME = 50 Local Const $TITLE = "User Inputs" ; Create the main form Global $form = GUICreate($TITLE, 230, 70, -1, -1) ; General Host Information GUICtrlCreateLabel("Hostname:", 10, 12) Global $hostNameTxt = GUICtrlCreateInput("", 70, 10, 150, 20) GUICtrlSetTip($hostNameTxt, "Enter the name of the computer") GUICtrlCreateLabel("Host IP:", 10, 42) Global $hostIPTxt = _GUICtrlIpAddress_Create($form, 70, 40, 150, 20) SetToolTip($form, $hostIPTxt, "Enter the IP address of the computer") ; Add callback for closing via X button GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGUI") ; Show GUI GUISetState(@SW_SHOW, $form) While 1 sleep($SLEEP_TIME) WEnd EndFunc Func ExitGUI() Exit EndFunc Func SetToolTip($form, $ctrl, $tip) Local $ExtStyle = 0 Local $ctrlHdl = GUICtrlGetHandle($ctrl) Local $tipHdl = _GUIToolTip_Create($ctrlHdl, BitOR($TTS_ALWAYSTIP, $TTS_NOPREFIX)) _GUIToolTip_AddTool($tipHdl, 0, $tip, $ctrlHdl, 0, 0, 0, 0, 0, 0) EndFunc Kind Regards, Vlad I'll be AutoIting my entire system soon.
BrewManNH Posted September 13, 2012 Posted September 13, 2012 Why are you using _GUIToolTip_Create instead of using GUICtrlSetTip? I would think the latter would be much easier to use. I've also never run into a script that uses _GUIToolTip_* before, so I'm not sure what the issue might be. 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 GudeHow 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
vvb Posted September 13, 2012 Author Posted September 13, 2012 Why are you using _GUIToolTip_Create instead of using GUICtrlSetTip? I would think the latter would be much easier to use. I've also never run into a script that uses _GUIToolTip_* before, so I'm not sure what the issue might be. Because it does not work on IP address input. See following code with IP address input using GUICtrlSetTip: expandcollapse popup#include <Misc.au3> #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <GuiToolTip.au3> _Main() Func _Main() ; Ensures only one instance is running. _Singleton(@ScriptName, 0) ; Enable on event GUI Opt("GUIOnEventMode", 1) ; Sleep time in idle loop Global Const $SLEEP_TIME = 50 Local Const $TITLE = "User Inputs" ; Create the main form Global $form = GUICreate($TITLE, 230, 100, -1, -1) ; General Host Information GUICtrlCreateLabel("Hostname:", 10, 12) Global $hostNameTxt = GUICtrlCreateInput("", 80, 10, 140, 20) ; Using GUICtrlSetTip on a standard input works GUICtrlSetTip($hostNameTxt, "Enter the name of the computer") GUICtrlCreateLabel("Host IP:", 10, 42) Global $hostIPTxt = _GUICtrlIpAddress_Create($form, 80, 40, 140, 20) ; Using UDF tooltip method on a non-standard IP address input does not work SetToolTip($form, $hostIPTxt, "Enter the IP address of the computer") GUICtrlCreateLabel("Subnet Mask:", 10, 72) Global $maskTxt = _GUICtrlIpAddress_Create($form, 80, 70, 140, 20) ; Using GUICtrlSetTip on a UDF IP address input does not work GUICtrlSetTip($maskTxt, "Enter the subnet mask of the computer") ; Add callback for closing via X button GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGUI") ; Show GUI GUISetState(@SW_SHOW, $form) While 1 sleep($SLEEP_TIME) WEnd EndFunc Func ExitGUI() Exit EndFunc Func SetToolTip($form, $ctrl, $tip) Local $ExtStyle = 0 Local $ctrlHdl = GUICtrlGetHandle($ctrl) Local $tipHdl = _GUIToolTip_Create($ctrlHdl, BitOR($TTS_ALWAYSTIP, $TTS_NOPREFIX)) _GUIToolTip_AddTool($tipHdl, 0, $tip, $ctrlHdl, 0, 0, 0, 0, 0, 0) EndFunc I'll be AutoIting my entire system soon.
BrewManNH Posted September 13, 2012 Posted September 13, 2012 martin posted a couple of years ago that creates a tooltip with a workaround for the problem associated with GUICtrlSetTip and the IP address control. Because there aren't any clear examples of how to use the tooltip UDFs I'm struggling with getting them to work. 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 GudeHow 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
vvb Posted September 13, 2012 Author Posted September 13, 2012 martin posted a couple of years ago that creates a tooltip with a workaround for the problem associated with GUICtrlSetTip and the IP address control. Because there aren't any clear examples of how to use the tooltip UDFs I'm struggling with getting them to work.Thanks but as mentioned above, that is not the step I want to take as I have a lot of IP address fields. I'll have to loop through each of them to see if the mouse is within its area.I've decided to create a custom input with 4 individual standard inputs restricted to 3 digit numbers for now.Cheers all. I'll be AutoIting my entire system soon.
BrewManNH Posted September 13, 2012 Posted September 13, 2012 Couldn't you just put a label above the IP address field that explains what's needed in that input? Seems a lot simpler. 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 GudeHow 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
vvb Posted September 14, 2012 Author Posted September 14, 2012 Couldn't you just put a label above the IP address field that explains what's needed in that input? Seems a lot simpler. That would be too messy. Interesting however, I have also tried a simple method of getting the control id from the hover point using a DLL call and the tooltip does appear for the IP address input but only when the mouse is over the edge or the dots and not when it is over the actual white input area. Func GetHoverHandle() Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1)) If IsArray($iRet) Then Return HWnd($iRet[0]) Return SetError(1, 0, 0) EndFunc I'll be AutoIting my entire system soon.
BrewManNH Posted September 14, 2012 Posted September 14, 2012 (edited) If you're creating your own inputs for an IP address entry, you might want to use one of the snippets in the wiki that deal with verifying whether the IP address entered is a valid IP. One of those entries is one that I submitted, which if I do say so myself, is one of the very few that actually validates an IPv4 address correctly. Edited September 14, 2012 by BrewManNH 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 GudeHow 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
James Posted September 14, 2012 Posted September 14, 2012 Don't forget IPV6 Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
BrewManNH Posted September 14, 2012 Posted September 14, 2012 Verifying that an IPv6 string is valid would be a daunting task, considering that there are varying values that are valid, yet don't look like a normal address. I'm not going to attempt that one 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 GudeHow 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
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