rm4453

Moving Combo To Next Option Automatically In AutoIt Gui

3 posts in this topic

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



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

#3 ·  Posted (edited)

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

    • WiorDi37
      By WiorDi37
      Hello, Everyone!
      I want when clicking the exit button the window will close. If content changes upon exit the program will automatically choose not save.
      Look forward to the help, thanks.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> $GUI = GUICreate("Form1", 220, 119, 192, 124, $WS_SYSMENU) GUISetFont(10, 400, 0, "Tahoma") GUICtrlCreateGroup("Chuẩn bị trình chiếu", 16, 16, 185, 65) $ok_Button = GUICtrlCreateButton("Ok", 32, 48, 75, 25) $exit_Button = GUICtrlCreateButton("Exit", 112, 48, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $ok_Button ShellExecute(@MyDocumentsDir&'\Dich-thuat\Short-Document.pdf', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Data and Computer Communications (Eighth Edition) - Google Chrome") ShellExecute(@MyDocumentsDir&'\Dich-thuat\Document.rtf', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Document.rtf [Compatibility Mode] - Word") ShellExecute(@MyDocumentsDir&'\Dich-thuat\Presentation1.pptx', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Presentation1.pptx - PowerPoint") MouseClick("left", 1381, 886, 1) Sleep(2000) MsgBox(64, "Thông báo", "Đã chuẩn bị xong") Case $exit_Button WinClose("Presentation1.pptx - PowerPoint") ;I need help handling this place Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  

    • badcoder123
      By badcoder123
      Hey everyone,
      I've been messing around with some new things and adlibs look extremely useful/interesting, however, I can't seem to get it to work.. Here's what I have
      HotKeySet("{F1}", "_Exit") $qCount = 1 Global $_Timer AdlibRegister($_Timer, 1000) AdlibUnRegister($_Timer) While 1 SoundPlay(@WindowsDir & "\media\tada.wav", 1) $qCount += 1 ToolTip('"Tada" has been played ' & $qCount & " times",200,200) WEnd Func _Timer() Local Static $iCount += 1 ConsoleWrite($iCount) If $iCount = 20 Then ConsoleWrite("iCount is at " & $iCount) EndFunc Func _Exit() Exit EndFunc Basically I want it to call the _Timer function but it doesn't seem to work :/ any ideas?
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      Before all, I want to say that I'm doing this script to see how _IE* functions work, and see if my studs can hack a quiz I'm working on.
      I want to clarify that I'm not automating any game, bypassing any CAPTCHAs, or anything that could damage anyone.
      I was trying to autofill a form, based on which question is displayed.
      The question is always stored in here:
      <header> <h1><span class="questionid">1. </span>Here goes the question</h1> </header> And answers are stored in here:
      <ul class="answers"> <li><label><span><input id="answer_0" name="answer[]" type="radio" value="0">Answer 1</span></label></li> <li><label><span><input id="answer_1" name="answer[]" type="radio" value="1">Answer 2</span></label></li> <li><label><span><input id="answer_2" name="answer[]" type="radio" value="2">Anwser 3</span></label></li> <li><label><span><input id="answer_3" name="answer[]" type="radio" value="3">Answer 4</span></label></li> </ul></fieldset></form></div> And, there are 15 questions like this.
      How can automatically fill my form?
      Thanks in advance
      Francesco
    • Viki
      By Viki
      This is my first time here so please dont bombard me that what a silly question I am asking!!
      I have 500 rows (A1:A500) in a spreadsheet and I just want to copy one by one row and then paste into another application and then press enter, loop should repeat this until finishes all 500 rows.
      I have looked at clipget(), clip(put() but dont know how to select next row in next turn. I also looked at Array to store but again no luck. Can some guide me please..
    • DineshPawar
      By DineshPawar
      0down votefavorite   In my current project, Excel macro open AutoIt script using a function Call Shell("location of autoit script").
      For proper functioning of AutoIt script it's need to be close parent Excel workbook, so this closing Excel action is written in AutoIt script itself.
      But as soon as AutoIt script close parent Excel workbook then script get pause and it do nothing.
      How open the AutoIt script from Excel workbook and after that parent Workbook get close?