Jump to content
rm4453

Moving Combo To Next Option Automatically In AutoIt Gui

Recommended Posts

rm4453

I need to find a way to after x amount of seconds set the Autoit gui's ComboBox to next option available, and if it reaches the end of the list start back at beginning. This way I can cycle through checking if users are connected to a network. The combo is populated via a recursive file search that contains folders with each connected user's username. The ComboBox will contain something like " username\config " for every connected user. So I need to make so it cycles through constantly every X seconds I have the gui functioning, and all that I just can't get this one part to work.

TL:DR - How do I make so an AutoIt GUI ComboBox will cycle through all of its options every X seconds, and when it reaches bottom of options cycle back to top and continue the process again.

Thanks! I can't post any code due to NDA sorry...

Share this post


Link to post
Share on other sites
Melba23

rm4453,

How about something along these lines:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; List of combo contents
Global $sList = "Alpha|Bravo|Charlie|Delta|Echo|Foxtrot"
;Convert to array
$aList = StringSplit($sList, "|")

$hGUI = GUICreate("Test", 500, 500)

$cCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)

; Fill the combo
_FillCombo()

GUISetState()

$nBegin = TimerInit()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; Every 2 seconds
    If TimerDiff($nBegin) > 2000 Then
        ; Refill the combo
        _FillCombo()
        ; Reset the timestamp
        $nBegin = TimerInit()
    EndIf

WEnd

Func _FillCombo()

    ; Index of array item to use as default
    Local Static $iIndex = 1

    ; Set combo data with selected item as default
    GUICtrlSetData($cCombo, "|" & $sList, $aList[$iIndex])

    ; increase index - and reset if required
    $iIndex += 1
    If $iIndex > $aList[0] Then
        $iIndex = 1
    EndIf

EndFunc

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
rm4453

Thank You For Your Help.  I was just about to post that i figured it out...  Here is what I ended up using "at least what i can post of it"

 

$CurrentAccount = GUICtrlRead($AccountSelect)
    $acc = _GUICtrlComboBox_GetCurSel($AccountSelect)

    Sleep(50)
    $timer = $timer + 50
    If $go = 1 Then
        If $timer = $ConnectTimer * 60000 Then
            ProcessClose($pid)
            _GUICtrlComboBox_SetCurSel($AccountSelect, $acc + 1)
            If $acc = $accs + 1 Then
                _GUICtrlComboBox_SetCurSel($AccountSelect, 0)
                $acc = 0
            EndIf
            $timer = 0
            $copied = 0
        EndIf
    EndIf

    $update = $update + 1
    If $update = 25 Then
        _GUICtrlComboBox_SelectString($AccountSelect, $CurrentAccount)
        $update = 0
    EndIf

 *EDIT :
New Problem

How would I Filecopy something If I only know parts of the file name... I need to grab the User Session info in a .config and for each user the first part is unique... I know that the last part is .config every time that is it...

*EDIT:
NEW PROB SOLVED

I just set the filecopy to the dir with a *.config wildecard ... that should work for what I need due to it being only .config in the folder it would be copying from THANKS!

;=== CODE EXAMPLE FOR THOSE WHO COME LATER ON AND NEED THIS

FileCopy(C:\example\Folders\*.config, $sDir, "1")

;=== ENJOY!

 

Edited by rm4453
NEW PROB

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

  • Similar Content

    • nooneclose
      By nooneclose
      My program has to first search for names in Column D that do not match up with column C. I got that search to work using arrays. It was slow and I could not figure out how to delete them so I just manually put coded the names that do not belong. I found their cell location but I do not know how to store that location and delete it.
      This is what I have so far.
      Local $NameToDelete1[6]  = _Excel_RangeFind($OpenWorkbook, "Smith, Bill") _ArrayDisplay($NameToDelete1, "Excel UDF: _Excel_RangeFind Example 1", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment") _Excel_RangeDelete($OpenWorkbook.ActiveSheet, $NameToDelete1[2], $xlShiftUp)  
      Please help, I wanted to have this program done yesterday but I did not see this problem until yesterday. 
    • TrashBoat
      By TrashBoat
      So Im trying to make a simple 2d game and make some sort of collision detection so why not to make a 2 dimensional array but i have no clue how  to write it in multiple lines
      Global $map[5,5] = [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0] something like this but it doesn't work
    • Zein
      By Zein
      #include "..\Include\Array.au3" #include "..\Include\File.au3" #include "..\Include\AutoItConstants.au3" Local $aRetArray Local $sFilePath = "n.csv" _FileReadToArray($sFilePath, $aRetArray, ",") ; _FileReadToArray($sFilePath, $aRetArray, $FRTA_COUNT, ",") _ArrayDisplay($aRetArray, "Original", Default, 8) The above code shows two versions of _FileReadToArray and both don't work as expected.
      The first one doesn't use the comma as a delimiter. (so I get a single column array)  I tried adding "Default" between $aRetArray and "," then it told me it had an incorrect number of parameters. 

      I looked again at the documentation:
       
      #include <File.au3> _FileReadToArray ( $sFilePath, ByRef $vReturn [, $iFlags = $FRTA_COUNT [, $sDelimiter = ""]] )
      And I with or without the flags params I should be getting a 2D array due to my file being a csv. 
      I then tried a regular flag, $FRTA_COUNT, and it tells me that I'm using a variable $FRTA_COUNT while it's not declared. Tried putting in 1 instead and it told me again, incorrect number of params. 

       
    • nooneclose
      By nooneclose
      I need to perform a subtotal in excel and I would like to automate this process using Autoit if possible like always any and all help will be greatly appreciated. 
      I can not find a good example but the two from Microsoft. Here is one of the two from msdn.microsoft.com/en-us/vba/excel-vba/articles/range-subtotal-method-excel
      I do not really understand how to translate this into AutoIt, but I gave it a try and here is what I have.
      $OpenRange      = "A1:E200" $xlSum          = -4157 $Added_Array[2] = [2, 3] $OpenRange.Subtotal("B1", $xlSum, $Added_Array, True, False, True) I just need to perform a subtotal on a range based on a header called department, and then perform a sum on the results.
    • nacerbaaziz
      By nacerbaaziz
      hi dears, i have an question please if you can help me.
      i maked an program to do some functions
      and this program works with the global hot keys
      i added an option to the users to change the hot keys
      when i searched about how to do that i found this UDF
      GUIHotkey.au3
      http://www.autoitscript.com/forum/index.php?showtopic=107965
      but the problem here that this UDF cant be detect the win key.
      can you help me to add it, or if there are any others UDFSS wich do that work please give me some.
      i hope that my question is clear for you.
      thanks in advance
×