Jump to content

Recommended Posts

Posted

Consider the below autoit GUI script:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Launch Spice", 485, 220, 201, 136)
$Tab1 = GUICtrlCreateTab(16, 16, 457, 140, BitOR($TCS_FOCUSONBUTTONDOWN,$TCS_TOOLTIPS))
GUICtrlCreateTabItem("Single")
$Label1 = GUICtrlCreateLabel("Single VM", 181, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("Multi")
$Label2 = GUICtrlCreateLabel("Multiple VMs", 170, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("Lookup")
$Label3 = GUICtrlCreateLabel("Lookup VM", 170, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input3 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("Deploy", 186, 165, 113, 41)
GUICtrlSetState ( -1, $GUI_DISABLE )
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

As you can see, I have created a tab control with several tabs, each of which contains a unique input box.  Here is my first question: lets say I want to process whatever information the user inputs into any of the input controls.  Is there a way to determine within the script which tab is currently selected when the button is clicked (which, by extension, would indicate the input control whose contents should be processed)?  I hope that makes sense.  The other question that I have involves the $TCS_TOOLTIPS tab control style.  Based on the description in the help file, I believe that this style would allow one to create a tooltip that would appear whenever the user hovers over one of the different tabs.  IS that accurate?  If so, how would one go about doing so?  I haven't really been able to find a good example.  IF my assessment is not accurate, can someone help clarify?  

Posted (edited)
34 minutes ago, MattHiggs said:

  Is there a way to determine within the script which tab is currently selected when the button is clicked

Yes there is :) 

GUICtrlRead($Tab1) returns the index of the selected tabitem (0-based).
Example:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Launch Spice", 485, 220, 201, 136)
$Tab1 = GUICtrlCreateTab(16, 16, 457, 140, BitOR($TCS_FOCUSONBUTTONDOWN,$TCS_TOOLTIPS))
GUICtrlCreateTabItem("Single")
$Label1 = GUICtrlCreateLabel("Single VM", 181, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("Multi")
$Label2 = GUICtrlCreateLabel("Multiple VMs", 170, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("Lookup")
$Label3 = GUICtrlCreateLabel("Lookup VM", 170, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input3 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("Deploy", 186, 165, 113, 41)
; GUICtrlSetState ( -1, $GUI_DISABLE )
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(0, "Test", "Tab " & Guictrlread($Tab1) & " selected.")
    EndSwitch
WEnd

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

Toolstips can work this way. Hover over the header of the Tab control.

#include <AutoItConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Launch Spice", 485, 220, 201, 136)
$Tab1 = GUICtrlCreateTab(16, 16, 457, 140, BitOR($TCS_FOCUSONBUTTONDOWN, $TCS_TOOLTIPS))
GUICtrlCreateTabItem("Single")

; TOOLTIP for TAB 0
GUICtrlSetStyle(-1, $TCS_TOOLTIPS)
GUICtrlSetTip(-1, " Tip for Tab 'Single'", "Testtitel", $TIP_INFOICON, $TIP_CENTER)

$Label1 = GUICtrlCreateLabel("Single VM", 181, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("Multi")
$Label2 = GUICtrlCreateLabel("Multiple VMs", 170, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("Lookup")
$Label3 = GUICtrlCreateLabel("Lookup VM", 170, 40, 194, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Input3 = GUICtrlCreateInput("", 96, 95, 297, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NOHIDESEL))

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("Deploy", 186, 165, 113, 41)
; GUICtrlSetState ( -1, $GUI_DISABLE )
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetCursor(-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(0, "Test", "Tab " & GUICtrlRead($Tab1) & " selected.")
    EndSwitch
WEnd

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

You do not need to specify $TCS_TOOLTIPS as it is a forced style for tab control.  Specifying it for a tab item will return a failure.  So simply use this :

...
$Tab1 = GUICtrlCreateTab(16, 16, 457, 140, $TCS_FOCUSONBUTTONDOWN)
GUICtrlCreateTabItem("Single")
GUICtrlSetTip(-1, "First tab")
...
GUICtrlCreateTabItem("Multi")
GUICtrlSetTip(-1, "Second tab")
...

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...