Jump to content

Recommended Posts

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
Link to post
Share on other sites
  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to post
Share on other sites
  • Moderators

Odewallrus,

My pleasure. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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

    No registered users viewing this page.

  • Similar Content

    • By AntS
      Help! The mouse clicks I'm sending to a control on a dialog box produce no response.
      The dialog box in question handles advanced display properties. The tab page my script interacts with is created by Trident Microsystems. It allows the user to enhance or attenuate the screen's RGB values. (See image.) My script automates the process of changing these in order to adjust the screen's hue or, when the red, green and blue values are all the same, the brightness.
      Producing a script to change the brightness has been quite straightforward. I use ControlClick() to send a mouse click to one of the trackbars on the right of the tab page. By default, they're linked and so move as one. The difficulty I'm having however is in automating the process when the desired red, green and blue values aren't the same as each other.
      Ordinarily, there are three ways of doing this: 
      (1) clear the Link check box to unlink the three trackbars then either click on each trackbar or drag their sliders,
      (2) clear the Link tick-box then for each colour, click on the corresponding trackbar slider (to select it) then click on a point on the graph, and
      (3) click on the Load button to open an Open dialog box and load a preset (stored as a .gam file).
      However, when ControlClick() is used to clear the Link check box or to push the Load button, nothing happens. Making the dialog box the active window makes no difference.
      The AutoIt Window Info tool indicates that the Reload a Bitmap, Save, Load and Reset buttons, the Link check box and the graph are all the same control. (See other images.) In fact, it there are only four controls on the page: the tab page, which is an instance of a SysTabControl32 class, and the three trackbars, each of which is an instance of the TridentTrackBar class. (Am unsure whether the SysTabControl32 class is a Windows or third-party control.)
      What's the solution?
      Note that the MouseClick() function—as opposed to ControlClick()—does work, but having AutoIt commandeer the screen pointer isn't an acceptable solution.
      For the sake of completeness, here's the relevant code fragment for the Link check box. 
      ;unlink trackbars WinActivate("(Multiple Monitors)") ControlClick("(Multiple Monitors)", "", 12320, "left", 1, 211, 252)  



    • By Cengokill
      Hi everyone,
      I have created a ListView that is in a tab, and I want to display an image in that tab, with the ListView on top.
      However, the image still appears on top of my ListView.
      If I remove the tabs everything works. 
      I looked at the autoit documentation and the <GuiListView.au3> documentation , I can't figure out how to display a background image, and put on top a ListView, inside a tab. 😥
      Here is the code:
      Opt("GUIOnEventMode", 1) $Form1 = GUICreate($Titre, 700, 627, $Form1Width, $Form1Height); main window $tabulation = GUICtrlCreateTab(148,0,700,580); creating tabs $tab1=GUICtrlCreateTabItem("Tab 1"); first tab GUICtrlSetState(-1, $GUI_SHOW); this tab is selected by default $Pic1 = GUICtrlCreatePic("image.jpg", 0, 30, 700, 627) GUICtrlSetState(-1, $GUI_DISABLE). $idListview = GUICtrlCreateListView("list 1|list 2|list 3", 200, 50, 390, 200) GUISetState(@SW_SHOW) While 1     Sleep(100) WEnd Thank you in advance.

    • By v0id
      I am starting out using AutoIt. Here is a simple form with username and password. I want to check if information entered is valid once user clicks a button.
      My problem now is that it only validates once. E.g.: if I type 5 character username, it will complain it is not 7 character (good). But once I correct that mistake and press the button again it will still say the same thing.
      Do I need to have a loop?
       
      #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) $main = GUICreate("Test Tool", 600, 600) $hyourlabel = GUICtrlCreateLabel("YOUR CREDENTIALS", 30, 10, 256) GUICtrlSetFont($hyourlabel, Default, 600) Local $adminfrejalabel = GUICtrlCreateLabel("Username:", 8, 38, 64, 17) Global $adminfrejaid = GUICtrlCreateInput("", 80, 38, 110, 17) Local $adminpasswordlabel = GUICtrlCreateLabel("Password:", 8, 62, 64, 17) Global $adminpassword = GUICtrlCreateInput("", 80, 62, 110, 17, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $userButton_Check = GUICtrlCreateButton("VALIDATE", 32, 480, 85, 25) GUICtrlSetOnEvent($userButton_Check, "startvalidation") GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGUI") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func startvalidation() ;CHECK VALIDATIONS $adminfrejaid = GUICtrlRead($adminfrejaid) $adminpassword = GUICtrlRead($adminpassword) If StringLen($adminfrejaid) <> '7' Then MsgBox($MB_SYSTEMMODAL, "User ID", "Please enter exactly 7 characters.") ;Exit EndIf If StringLen($adminpassword) < '5' Then MsgBox($MB_SYSTEMMODAL, "Your Password", "Please enter a valid password.") ;Exit EndIf EndFunc Func ExitGui () Exit ; Exit the program EndFunc  
    • 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?
    • 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
×
×
  • Create New...