Jump to content
Sign in to follow this  
Odewallrus

Tab not being painted gui loads

Recommended Posts

Odewallrus

I have looked and read for 2 days now without finding what I assume is a simple solution. Can someone please look at the codebelow and help me to understand why when the gui opens the controls on the default tab (tab1) do not show up unless another tab is selected and tab1 is re-selected. I am trying to get the controls to be available when the form opens.

This code uses GUIScrollbars_Ex.au3 which I have attached if needed. and reads a MobileMan.ini file the contents wich are below.

Thank you,

[Groups]
ActiveGroups=MobileTest,Mobile

[Mobile]
ActiveHosts=computer1,computer2,computer3,computer4

[MobileTest]
ActiveHosts=computer5,computer6

#include <GuiConstants.au3>
#include <GuiEdit.au3>
#Include <Date.au3>
#include <GUIScrollbars_Ex.au3>
#include <Array.au3>
$Logfile = @ScriptDir & '\' & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "-" & @min & "-" & @SEC & "_" & 'MobileMan.log'
Global $aHosts[1][18] = [[0, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",""]]
;~ Create Gui
$sTitle = "Mobile Management Console"
$sINI = @ScriptDir & "\MobileMan.ini"
$GUI = GUICreate($sTitle,900, 570, -1, -1)
$MessageMenu = GUICtrlCreateMenu("&File")
$HelpMenu = GUICtrlCreateMenu("Help")
GUICtrlCreateTab(160,10,730,310)
$tabFreeform = GUICtrlCreateTabItem("tab1")
$tabInpMessage = GUICtrlCreateInput("Enter text here...", 180,50,400,40, $ES_MULTILINE )
GUICtrlCreateTabItem("tab2")
GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("tab4")
GUISetState()
;~ Create Child gui
$cGUI = GUICreate("Child GUI", 140,525,10,10, $WS_CHILD, $WS_EX_CLIENTEDGE, $Gui)
GUICtrlSetResizing($cGUI, $GUI_DOCKALL)
Opt("GUICoordMode", 2)
$GrpCord = GUISetCoord(5,5)
$bToggleAll = GUICtrlCreateButton("Toggle All", -1, 1, 115, 20)
GUISetState()
FileOpen($Logfile,1)
FileWrite($Logfile, _Now() & " - Session started" & @CRLF)
;~ Read ini
$aGroups = IniReadSection($sINI, "Groups")
If @error Then
MsgBox(16, "Error", "Failed to read 'Groups' section.")
FileWrite($Logfile, _Now() & " - Failed to read 'Groups' section" & @CRLF)
Exit
EndIf
If ($aGroups[0][0] >= 1) And ($aGroups[1][0] = "ActiveGroups") Then
$aActiveGroups = StringSplit($aGroups[1][1], ",")
If ($aActiveGroups[0] = 1) And (StringStripWS($aActiveGroups[1], 8) = "") Then Dim $aActiveGroups[1] = [0]
Else
MsgBox(16, "Error", "Missing or invalid Groups keys.")
FileWrite($Logfile, _Now() & " - Missing or invalid Groups keys" & @CRLF)
Exit
EndIf
For $g = 1 To $aActiveGroups[0]
$sGroupName = $aActiveGroups[$g]
$aGroupSection = IniReadSection($sINI, $sGroupName)
If @error Then
     MsgBox(16, "Error", "Failed to read groups section: '" & $sGroupName & "'.")
FileWrite($Logfile, _Now() & " - Failed to read groups section: '" & $sGroupName & "'" & @CRLF)
     ContinueLoop
EndIf
If ($aGroupSection[0][0] >= 1) And ($aGroupSection[1][0] = "ActiveHosts") Then
     $aActiveHosts = StringSplit($aGroupSection[1][1], ",")
     If ($aActiveHosts[0] = 1) And (StringStripWS($aActiveHosts[1], 8) = "") Then Dim $aActiveHosts[1] = [0]
     For $h = 1 To $aActiveHosts[0]
         _AddActiveHost($sGroupName, $aActiveHosts[$h])
     Next
Else
     MsgBox(16, "Error", "Missing or invalid keys in group: '" & $sGroupName & "'.")
FileWrite($Logfile, _Now() & " - Missing or invalid keys in group: '" & $sGroupName & "'." & @CRLF)
     ContinueLoop
EndIf
Next
Dim $GrpButton[($aActiveGroups[0] + 1)]
$Btn_Start = GUICtrlCreateDummy()
For $g = 1 To $aActiveGroups[0]
$GrpButton[$g] = GUICtrlCreateButton($aActiveGroups[$g],-1, 1, 115, 20)
FileWrite($Logfile, _Now() & " - Group created: '" & $aActiveGroups[$g] & "'" & @CRLF)
     For $n = 1 To $aHosts[0][0]
if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][2] = GUICtrlCreateCheckbox($aHosts[$n][1],-1,0,130,15)
if $aActiveGroups[$g] = $aHosts[$n][0] then FileWrite($Logfile, _Now() & " - Host created: '" & $aHosts[$n][1] & "'")
if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][3] = IniRead($sINI, $aActiveGroups[$g], 'Share','C$')
;~ if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][4] = ping ($aHosts[$n][1],$PingTimeout)
;~ if not $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_DISABLE)
if $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_ENABLE)
if $aActiveGroups[$g] = $aHosts[$n][0] and not $aHosts[$n][4] = 1 then
FileWrite($Logfile, " -DISABLED" & @CRLF)
Elseif $aActiveGroups[$g] = $aHosts[$n][0] Then
FileWrite($Logfile, @CRLF)
EndIf
Next
Next
$Btn_End = GUICtrlCreateDummy()
_GUIScrollbars_Generate($cGUI, 0, ($n * 15) + ($g * 21)) ;number of checkboxes in the list * 15 pixels (height of the checkbox + spacing ???)
GUISetState()
;~ _ArrayDisplay($aActiveGroups)
;~ _ArrayDisplay($aHosts)
While 1
$msg = GUIGetMsg()
     Switch $msg
;~ If $msg = $GUI_EVENT_CLOSE Then
Case $GUI_EVENT_CLOSE
Exit
;~ ElseIf $msg = $bToggleAll Then
Case $bToggleAll
For $n = 1 To $aHosts[0][0]
             If $aHosts[$n][0] = True Then
     If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then
                 If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then
                     ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck")
                 Else
                     ControlCommand($cGUI, "", $aHosts[$n][2], "Check")
                 EndIf
     EndIf
             EndIf
         Next

Case $bToggleAll
For $n = 1 To $aHosts[0][0]
             If $aHosts[$n][0] = True Then
     If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then
                 If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then
                     ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck")
                 Else
                     ControlCommand($cGUI, "", $aHosts[$n][2], "Check")
                 EndIf
     EndIf
             EndIf
         Next
Case $Btn_Start To $Btn_End
For $n = 1 To $aHosts[0][0]
     If $aHosts[$n][0] = GUICtrlRead($Msg) Then
     If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then
     If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then
                     ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck")
                 Else
                     ControlCommand($cGUI, "", $aHosts[$n][2], "Check")
                 EndIf
     EndIf
             EndIf
         Next

EndSwitch
WEnd
Func _AddActiveHost($sGrp, $sHost)
ReDim $aHosts[UBound($aHosts) + 1][UBound($aHosts, 2)] ; Resize the array
$aHosts[0][0] = UBound($aHosts) - 1 ; Save count in [0][0]
$aHosts[$aHosts[0][0]][0] = $sGrp ; Put group in [n][0]
$aHosts[$aHosts[0][0]][1] = $sHost ; Put host in [n][1]
EndFunc ;==>_AddActiveHost

GUIScrollbars_Ex.au3

Edited by Melba23
Changed tags

Share this post


Link to post
Share on other sites
Melba23

Odewallrus,

You need to close the tab definition as explained in the Help file:

; .....
GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUISetState()
' .....

M23

P.S. When you post code please use AutoIt tags - put [autoit] before and [/autoit] after your posted code. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

Edited by Melba23
Typo

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Odewallrus

Thank you sooo very much! sorry about the tags it does read much better!

Share this post


Link to post
Share on other sites
Melba23

Odewallrus,

My pleasure. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

  • Similar Content

    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • FroVN
      By FroVN
      I made a software that download music and play it, but i have an idea , listen music online when we have internet connectionm ,no need for download any more, so i want to connect to soundclound but if wan to do that i need  to open google chrome , so is there any way to open that in hide and not show on taskbar? sorry for my bad english
    • jasontj
      By jasontj
      Hello.  I'm working on converting another script from IE to Firefox.  I can't seem to get a handle on the field "Defendant" to fill in a last, first name on this page:
      http://www.hcdistrictclerk.com/Edocs/Public/Search.aspx?Tab=tabCriminal
      I also can't seem to submit the form.   I've tried the code below... stuff may be commented out that I have tested.
       
          _FFOpenUrl("http://www.hcdistrictclerk.com/Edocs/Public/Search.aspx?Tab=tabCriminal")    
          _FFLoadWait()
          $oTextFN = _FSObjGet("ctl00_ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_ContentPlaceHolder2_tabSearch_tabCriminal_txtCrimDefendant", "ID")
          
          _FFObj($oTextFN, "value", "Smith, John")    
          $subButton = _FFObjGet("ctl00$ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder2$ContentPlaceHolder2$btnSearch", "name")
          _FFClick($subButton)
          _FFLoadWait()
          
      ;    _FFFormSubmit()
      ;    _FFLoadWait()
       
      Any help from the experts on here would be greatly appreciated.  
       
      Jason
       
       
       
       
    • dubd83
      By dubd83
      I am trying to click on a tab within an SWT_Window0. The problem is autoit can not see the tab's text and there is no controlid. I have tried using commands to obtain a handle and text with no luck. Any ideas on how to get control of this tab?
    • Gowrisankar
      By Gowrisankar
      Hello everyone,
      I'm trying to pass values to elements in a website.
      The elements are present within a table, which is again present within a table, which is inside a form.
      I tried to read the form, tables, etc., but with no results. It appears to me that the elements, tables, form, etc., were not read at all.
      The following is what I tried. Please guide me.
      ;I tried the following to read the tables into arrays #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate() _IENavigate($oIE, "---- URL HERE ----") _IELoadWait($oIE) $o_Table = _IETableGetCollection ($oIE) $i_NumTables = @extended For $i = 0 To $i_NumTables - 1 Step 1 $o_Table_Temp2 = _IETableGetCollection ($oIE, $i) $a_TableData = _IETableWriteToArray ($o_Table_Temp2) _ArrayDisplay($a_TableData) Next  
      ;I tried the following code to pass value to the field #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate() _IENavigate($oIE, "---- URL HERE ----", 0) _IELoadWait($oIE) Local $oForm = _IEFormGetObjByName($oIE, "default") Local $oField = _IEFormElementGetObjByName($oForm, "tGroup") _IEFormElementSetValue($oField, "---- VALUE HERE ----")  
      The following is the html view of the website and the highlighted field is the one that I want to pass values to. Since this is an official website, I can't share the exact url.

×