Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Buttons, Labels and Clicks, OH MY


  • Please log in to reply
4 replies to this topic

#1 smedley89

smedley89

    Seeker

  • Active Members
  • 11 posts

Posted 06 July 2012 - 09:48 PM

I have an application that works fine, except for one tiny issue. I've had to expand the number of tasks to the point that I've had to shrink the buttons down a bit. Each button has a label describing what it does. The issue is that you cannot click where the label or text is.. only on the outskirts of the button to have it perform its task. Is there something I can do to make the label clickable, or make it so that it doesn't mask the button below it? Here is a snippet with the label and button creation:


GuiCtrlCreateLabel(" (Click to set for SFC)", 5, 50, 135, 30)
$SFCButton = GUICtrlCreateButton("SFC", 130,40, 120, 30)
;the following line creates a tooltip
GuiCtrlSetTip(-1, "Sets IP to" & @cr & "169.254.196.200"& @cr &"255.255.255.0")







#2 smedley89

smedley89

    Seeker

  • Active Members
  • 11 posts

Posted 06 July 2012 - 09:56 PM

Actually, the issue seems to start at the HPV-20 button. The buttons above it, and the exit button at the bottom seem to have no issue. I'm sure at this point it's something screwey I've missed.


AutoIt         
; OS:     XP, Windows 7 ; Author: Ken Stillings ; #include <GUIConstants.au3> ;declaring the variables needed for user input Global $IP = "" Global $SN = "" Global $GW = "" Global $Error = "" ;creating the GUI and related buttons GUICreate("CBE IP Change", 255, 390) GuiCtrlCreateLabel("    (Click to set for ASA)", 5, 15, 140, 30) $ASAButton = GUICtrlCreateButton("ASA", 130, 5, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Sets IP to" & @cr &"192.168.31.200"& @cr &"255.255.255.0"& @cr &"192.168.31.31") GuiCtrlCreateLabel("    (Click to set for SFC)", 5, 50, 135, 30) $SFCButton = GUICtrlCreateButton("SFC", 130,40, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Sets IP to" & @cr & "169.254.196.200"& @cr &"255.255.255.0") GuiCtrlCreateLabel("  (Click to set Custom IP)", 5, 85, 180, 30) $CUSTButton = GUICtrlCreateButton("Custom", 130,75, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "This button allows you to enter"& @cr & "your own IP information") GuiCtrlCreateLabel("(Click to set for Standard)", 5, 120, 135, 30) $STDButton = GUICtrlCreateButton("Standard", 130,110, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Restores your IP to DHCP which"& @cr &"pulls the IP from the router") GuiCtrlCreateLabel("  (Click to ping Sapphire)", 5, 155, 155, 30) $PNGSapphire = GUICtrlCreateButton("Sapphire", 130,145, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Pings the Sapphire"& @cr &"IP 192.168.31.11") GuiCtrlCreateLabel("   (Click to ping HPV-20)", 5, 190, 190, 30) $PNGhpv = GUICtrlCreateButton("HPV-20", 130,180, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Pings the HPV-20"& @cr &"IP 192.168.31.1") GuiCtrlCreateLabel("    (Click to ping Router)", 5, 225, 225, 30) $PNGrouter = GUICtrlCreateButton("ROUTER", 130,215, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Pings the router at "& @cr &"IP 192.168.31.31") GuiCtrlCreateLabel("(Run IPCONFIG /Release)", 5, 260, 225, 30) $IPrelease = GUICtrlCreateButton("/RELEASE", 130,250, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Runs the"& @cr &"IPCONFIG /release command") GuiCtrlCreateLabel(" (Run IPCONFIG /Renew)", 5, 295, 225, 30) $IPrenew = GUICtrlCreateButton("/RENEW", 130,285, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Runs the"& @cr &"IPCONFIG /renew command") GuiCtrlCreateLabel("   (Run IPCONFIG /All)", 5, 330, 225, 30) $IPall = GUICtrlCreateButton("/ALL", 130,320, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "Runs the IPCONFIG /ALL"& @cr &"command, showing current"& @cr &"IP configuration") $EXITButton = GUICtrlCreateButton("Exit", 130,355, 120, 30) ;the following line creates a tooltip GuiCtrlSetTip(-1, "This button exits the program") ; GUI MESSAGE LOOP GuiSetState() While 1     $msg = GUIGetMsg()          Select               Case $msg = $ASAButton                         Run ('c:windowssystem32netsh.exe')                         sleep (1000)                         send ('interface IP set address name="Local Area Connection" source=static 192.168.31.200 255.255.255.0 192.168.31.31 1+{enter}')                         sleep (1000)                         send ('exit+{enter}')                         sleep (1000)                         $answer = MsgBox(0, "IP Address", "Your IP address is set.")               Case $msg = $SFCButton                         Run ('c:windowssystem32netsh.exe')                         sleep (1000)                         send ('interface ip set address name="Local Area Connection" source=static 169.254.196.200 255.255.255.0+{enter}')                         sleep (1000)                         send ('exit+{enter}')                         sleep (1000)                         $answer = MsgBox(0, "IP Address", "Your IP address is set.")               Case $msg = $STDButton                         Run ('c:windowssystem32netsh.exe')                         sleep (1000)                         send ('interface ip set dns name="Local Area Connection" source=DHCP+{enter}')                         sleep (1000)                         send ('interface ip set wins name="Local Area Connection" source=DHCP+{enter}')                         sleep (1000)                         send ('interface ip set address name="Local Area Connection" source=DHCP+{enter}')                         sleep (1000)                         send ('exit+{enter}')                         sleep (500)                         $answer = MsgBox(0, "IP Address", "Your IP address is set.")                Case $msg = $CUSTButton                         GetIP()         GetSN()                         GetGW()                         Run ('c:windowssystem32netsh.exe')                         sleep (1000) if $GW <>"" then                                   send ('interface ip set address "Local Area Connection" static ' & $IP & ' ' & $SN &' ' & $GW & ' 1+{enter}')                              else                                   send ('interface ip set address "Local Area Connection" static ' & $IP &' ' & $SN &'+{enter}')                               endif                         sleep (1000)                         send ('exit+{enter}')                         sleep (500)                         $answer = MsgBox(0, "IP Address", "Your IP address is set.")               Case $msg = $PNGSapphire                         Run ('c:windowssystem32cmd.exe')                         sleep (1000)                         send ('ping 192.168.31.11+{enter}')               Case $msg = $PNGhpv                         Run ('c:windowssystem32cmd.exe')                         sleep (1000)                         send ('ping 192.168.31.1+{enter}')               Case $msg = $PNGrouter                         Run ('c:windowssystem32cmd.exe')                         sleep (1000)                         send ('ping 192.168.31.31+{enter}')               Case $msg = $IPrelease                         Run ('c:windowssystem32cmd.exe')                         sleep (1000)                         send ('ipconfig /release+{enter}')               Case $msg = $IPrenew                         Run ('c:windowssystem32cmd.exe')                         sleep (1000)                         send ('ipconfig /renew+{enter}')               Case $msg = $IPall                         Run ('c:windowssystem32cmd.exe')                         sleep (1000)                         send ('ipconfig /all+{enter}')                Case $msg = $EXITButton                         exit                   EndSelect                If $msg = $GUI_EVENT_CLOSE Then ExitLoop ;ends the application if the red X is clicked on the gui                 Wend ;~~~~~~~~~~~~~~~~~~~ func GetIP() ;remove any information in the variables $IP = "" ;accepts user input $IP = InputBox("Enter IP Address", "Please enter the IP address in this format: xxx.xxx.xxx.xxx", "", "", 0,0)            If @Error = 1 then                  Exit            endIf ValidIP($IP) EndFunc ;~~~~~~~~~~~~~~~~~~~~~ func GetSN() $SN = "" ;clearing any previous data $SN = InputBox("Enter Subnet", "Please enter the subnet mask in this format: xxx.xxx.xxx.xxx", "", "", 0,0)            If @Error = 1 then                  Exit            EndIf ValidSN($SN) EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~ func GetGW() $GW = "" ;clearing any previous data $GW = InputBox("Enter Gateway", "Please enter the gateway in this format: xxx.xxx.xxx.xxx - or leave blank", "", "", 0,0) If $GW <> "" then     ValidGW($GW) ; only needs to check for validity if field is not left blank. EndIf endfunc ;~~~~~~~~~~~~~~~~~~~~~~ func ValidIP($IPcheck) $arrayIP = StringSplit($IPcheck, ".") if $arrayIP[0] <> 4 then msgbox(16, "Error", "Invalid IP range.")                GetIP() elseif $arrayIP[1] < 1 OR $arrayIP[1] > 255 then msgbox(16, "Error", "Invalid IP range.")                GetIP() elseif $arrayIP[2] > 255 then msgbox(16, "Error", "Invalid IP range.")                GetIP() elseif $arrayIP[3] > 255 then msgbox(16, "Error", "Invalid IP range.")                GetIP() elseif $arrayIP [4]> 255 then msgbox(16, "Error", "Invalid IP range.")                GetIP() EndIf $count = 1 while $count < 5 if (StringIsDigit($arrayIP[$count]) ==0) then msgbox(16, "Error", "No letters or special characters allowed.") GetIP() EndIf $count = $count +1 wend endFunc ;~~~~~~~~~~~~~~~~~~~~~~~~ func ValidSN($SNCheck) $arraySN = StringSplit($SNcheck, ".") if $arraySN[0] <> 4 then ;the first element in the split array gives the number of elements. If there's more or less than 4 elements (192.168.1, or 192.124.23.1.2) then there is an error. msgbox(16, "Error", "Invalid Subnet range.")                GetSN() elseif $arraySN[1] < 1 OR $arraySN[1] > 255 then msgbox(16, "Error", "Invalid Subnet range.")                GetSN() elseif $arraySN[2] > 255 then msgbox(16, "Error", "Invalid Subnet range.")                GetSN() elseif $arraySN[3] > 255 then msgbox(16, "Error", "Invalid Subnet range.")                GetSN() elseif $arraySN[4]> 255 then msgbox(16, "Error", "Invalid Subnet range.")                GetIP() EndIf ;the array containing the information from the entry starts at element 1, not 0. Here, we run through a loop looking for non numeric entries. $count = 1 while $count < 5 if (StringIsDigit($arraySN[$count]) ==0) then msgbox(16, "Error", "No letters or special characters allowed.") GetIP() EndIf $count = $count +1 wend endFunc ;~~~~~~~~~~~~~~~~~~~~~~~~ func ValidGW($GWCheck) $arrayGW = StringSplit($GWcheck, ".") if $arrayGW[0] <> 4 then msgbox(16, "Error", "Invalid IP range.")                GetGW() elseif $arrayGW[1] < 1 OR $arrayGW[1] > 255 then msgbox(16, "Error", "Invalid IP range.")                GetGW() elseif $arrayGW[2] > 255 then msgbox(16, "Error", "Invalid IP range.")                GetGW() elseif $arrayGW[3] > 255 then msgbox(16, "Error", "Invalid IP range.")                GetGW() elseif $arrayGW[4]> 255 then msgbox(16, "Error", "Invalid IP range.")                GetGW() EndIf ;the array containing the information from the entry starts at element 1, not 0. Here, we run through a loop looking for non numeric entries. $count = 1 while $count < 5 if (StringIsDigit($arrayGW[$count]) ==0) then msgbox(16, "Error", "No letters or special characters allowed.") GetGW() EndIf $count = $count +1 wend endFunc

Edited by Melba23, 07 July 2012 - 08:40 AM.
Added tags


#3 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,482 posts

Posted 06 July 2012 - 10:22 PM

Please add code blocks to that script, or use [autoit ] [/autoit ] tags. It's very hard to follow that.Remove the spaces from the tags before using them.

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 an XP machine, 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!

 

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

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.


#4 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,827 posts

Posted 07 July 2012 - 08:54 AM

smedley89,

You have a slight overlap between the labels and the buttons - AutoIt then does not know which control you are trying to click as so actions neither. I have added colour to the labels to show you. ;)

The solution is to reduce the size of the label - as I have shown with the "ASA" button. Then there is no overlap and the button works across its width. :)
AutoIt         
; OS:     XP, Windows 7 ; Author: Ken Stillings ; #include <GUIConstants.au3> ;declaring the variables needed for user input Global $IP = "" Global $SN = "" Global $GW = "" Global $Error = "" ;creating the GUI and related buttons GUICreate("CBE IP Change", 255, 390) GUICtrlCreateLabel("    (Click to set for ASA)", 5, 15, 125, 30) GUICtrlSetBkColor(-1, 0x00FF00) $ASAButton = GUICtrlCreateButton("ASA", 130, 5, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Sets IP to" & @CR & "192.168.31.200" & @CR & "255.255.255.0" & @CR & "192.168.31.31") GUICtrlCreateLabel("    (Click to set for SFC)", 5, 50, 135, 30) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetBkColor(-1, 0xFF0000) $SFCButton = GUICtrlCreateButton("SFC", 130, 40, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Sets IP to" & @CR & "169.254.196.200" & @CR & "255.255.255.0") GUICtrlCreateLabel("  (Click to set Custom IP)", 5, 85, 180, 30) GUICtrlSetBkColor(-1, 0xFF0000) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $CUSTButton = GUICtrlCreateButton("Custom", 130, 75, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "This button allows you to enter" & @CR & "your own IP information") GUICtrlCreateLabel("(Click to set for Standard)", 5, 120, 135, 30) GUICtrlSetBkColor(-1, 0xFF0000) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $STDButton = GUICtrlCreateButton("Standard", 130, 110, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Restores your IP to DHCP which" & @CR & "pulls the IP from the router") GUICtrlCreateLabel("  (Click to ping Sapphire)", 5, 155, 155, 30) GUICtrlSetBkColor(-1, 0xFF0000) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $PNGSapphire = GUICtrlCreateButton("Sapphire", 130, 145, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Pings the Sapphire" & @CR & "IP 192.168.31.11") GUICtrlCreateLabel("   (Click to ping HPV-20)", 5, 190, 190, 30) GUICtrlSetBkColor(-1, 0xFF0000) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $PNGhpv = GUICtrlCreateButton("HPV-20", 130, 180, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Pings the HPV-20" & @CR & "IP 192.168.31.1") GUICtrlCreateLabel("    (Click to ping Router)", 5, 225, 225, 30) GUICtrlSetBkColor(-1, 0xFF0000) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $PNGrouter = GUICtrlCreateButton("ROUTER", 130, 215, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Pings the router at " & @CR & "IP 192.168.31.31") GUICtrlCreateLabel("(Run IPCONFIG /Release)", 5, 260, 225, 30) GUICtrlSetBkColor(-1, 0xFF0000) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $IPrelease = GUICtrlCreateButton("/RELEASE", 130, 250, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Runs the" & @CR & "IPCONFIG /release command") GUICtrlCreateLabel(" (Run IPCONFIG /Renew)", 5, 295, 225, 30) GUICtrlSetBkColor(-1, 0xFF0000) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $IPrenew = GUICtrlCreateButton("/RENEW", 130, 285, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Runs the" & @CR & "IPCONFIG /renew command") GUICtrlCreateLabel("   (Run IPCONFIG /All)", 5, 330, 225, 30) GUICtrlSetBkColor(-1, 0xFF0000) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $IPall = GUICtrlCreateButton("/ALL", 130, 320, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "Runs the IPCONFIG /ALL" & @CR & "command, showing current" & @CR & "IP configuration") $EXITButton = GUICtrlCreateButton("Exit", 130, 355, 120, 30) ;the following line creates a tooltip GUICtrlSetTip(-1, "This button exits the program") ; GUI MESSAGE LOOP GUISetState() While 1     $msg = GUIGetMsg()     Select         Case $msg = $ASAButton             ;Run('c:windowssystem32netsh.exe')             ;Sleep(1000)             ;Send('interface IP set address name="Local Area Connection" source=static 192.168.31.200 255.255.255.0 192.168.31.31 1+{enter}')             ;Sleep(1000)             ;Send('exit+{enter}')             ;Sleep(1000)             $answer = MsgBox(0, "ASA", "Your IP address is set.")         Case $msg = $SFCButton             ;Run('c:windowssystem32netsh.exe')             ;Sleep(1000)             ;Send('interface ip set address name="Local Area Connection" source=static 169.254.196.200 255.255.255.0+{enter}')             ;Sleep(1000)             ;Send('exit+{enter}')             ;Sleep(1000)             $answer = MsgBox(0, "SFC", "Your IP address is set.")         Case $msg = $STDButton             ;Run('c:windowssystem32netsh.exe')             ;Sleep(1000)             ;Send('interface ip set dns name="Local Area Connection" source=DHCP+{enter}')             ;Sleep(1000)             ;Send('interface ip set wins name="Local Area Connection" source=DHCP+{enter}')             ;Sleep(1000)             ;Send('interface ip set address name="Local Area Connection" source=DHCP+{enter}')             ;Sleep(1000)             ;Send('exit+{enter}')             ;Sleep(500)             $answer = MsgBox(0, "STD", "Your IP address is set.")         Case $msg = $CUSTButton             ;GetIP()             ;GetSN()             ;GetGW()             ;Run('c:windowssystem32netsh.exe')             ;Sleep(1000)             ;If $GW <> "" Then             ;    Send('interface ip set address "Local Area Connection" static ' & $IP & ' ' & $SN & ' ' & $GW & ' 1+{enter}')             ;Else             ;    Send('interface ip set address "Local Area Connection" static ' & $IP & ' ' & $SN & '+{enter}')             ;EndIf             ;Sleep(1000)             ;Send('exit+{enter}')             ;Sleep(500)             $answer = MsgBox(0, "Cust", "Your IP address is set.")         Case $msg = $PNGSapphire             Run('c:windowssystem32cmd.exe')             Sleep(1000)             Send('ping 192.168.31.11+{enter}')         Case $msg = $PNGhpv             Run('c:windowssystem32cmd.exe')             Sleep(1000)             Send('ping 192.168.31.1+{enter}')         Case $msg = $PNGrouter             Run('c:windowssystem32cmd.exe')             Sleep(1000)             Send('ping 192.168.31.31+{enter}')         Case $msg = $IPrelease             Run('c:windowssystem32cmd.exe')             Sleep(1000)             Send('ipconfig /release+{enter}')         Case $msg = $IPrenew             Run('c:windowssystem32cmd.exe')             Sleep(1000)             Send('ipconfig /renew+{enter}')         Case $msg = $IPall             Run('c:windowssystem32cmd.exe')             Sleep(1000)             Send('ipconfig /all+{enter}')         Case $msg = $EXITButton             Exit         Case $msg = $GUI_EVENT_CLOSE             Exit     EndSelect WEnd

All clear? :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#5 smedley89

smedley89

    Seeker

  • Active Members
  • 11 posts

Posted 09 July 2012 - 01:04 PM

Thank you very much! I figured it had to be something simple I was overlooking!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users