Aphotic

Multi "Screen" GUI Management

7 posts in this topic

#1 ·  Posted (edited)

Just wanted to share my functions for managing a GUI with lots of controls and many screens.

I personally feel that it is very efficient and keeps line count to a minimum.

And if it's not, I'll learn a better solution!

Note: There are some conditional veriables such as $changes and $cont that are modified by the main loop in this particular script; they are meant as an example, please don't try too hard to understand why they're used.

*Usage*

This allows you to re-state a handful of buttons in one line when doing slight GUI changes:

ToggleCTRL($GUI_DISABLE, $dALO, $dAAF, $dRLA) (A few buttons on a certain screen)

ToggleCTRL($GUI_DISABLE, $dSAV, $dCAN) (Save/Cancel buttons)

AND

A single line solution to switching a GUI "screen":

GuiMod("MAIN", $GUI_HIDE)

GuiMod("DETAILS", $GUI_SHOW)

GuiMod("PLANS", $GUI_HIDE)

Another way I've used this to my advantage is as follows:

Say a GUI has 3 or 4 main screens, and 3 or 4 "form" screens.

When switching to a form screen, save the main screen that it was on to a variable; then once the user is done with the form, either submitting or cancelling, you can call the variable to revert back to the main screen it was on.

Func _GuiMod($i, $tog, $act = True)
   Switch $i
   Case "MAIN"
      If $tog = $GUI_SHOW And $changes Then
         $changes = False
         ControlClick($GUI, "", $LOGfg)
      Else
      EndIf
      If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 535, 445)
      _ToggleCTRL($tog, $TAB, $LOGfl, $LOGfc, $LOGfi, $LOGfg, $LOGta, $LOGvd)
      _ToggleCTRL($tog, $LOGtp, $LOGse)
   Case "DETAILS"
      If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 535, 475)
      Local $cont = True
      If $tog = $GUI_SHOW And $act Then
         If Not UpdateDetails() Then
            $cont = False
            _GuiMod("MAIN", $GUI_SHOW)
         EndIf
      EndIf
      If $cont Then
         _ToggleCTRL($tog, $dUID, $dICU, $dACC, $dCOF, $dNAM, $dCO2, $dIPW, $dEMA, $dEDI, $dLOG, $dMOD)
         _ToggleCTRL($tog, $dUPD, $dINP, $dAPL, $dALO, $dAAF, $dPLL, $dLOL, $dAFL, $dSAV, $dCAN, $dRPL)
         _ToggleCTRL($tog, $dRLA, $dACT, $dAC2, $dRET, $dDEL, $dADD, $dMQC)
      EndIf
   Case "ADD-INPUT"
      _ToggleCTRL($tog, $nCOMi, $nCO2i, $nNAMi, $nNAMb, $nEMAi, $nPREc, $nACCc, $nICUi, $nADDi, $nNOTi)
      _ToggleCTRL($tog, $nAPLb, $nALOb, $nAAFb, $nPLAl, $nLOCl, $nAFFl, $nRPLb, $nRLAb, $nADDb, $nCLEb)
   Case "PLANS"
      If $tog <> $GUI_SHOW Or Not $changing Then
         If $act Then _ToggleCTRL($tog, $dMOD, $dLOG, $dUPD, $dDEL)
         _ToggleCTRL($tog, $dINP, $dAPL, $dALO, $dAAF, $dPLL, $dLOL, $dAFL, $dSAV, $dCAN, $dRPL, $dRLA)
      EndIf
   Case "CHANGE"
      _ToggleCTRL($tog, $dITL, $dITC, $dAML, $dAMC, $dSCB, $dCCB, $dEAB)
      If $tog = $GUI_SHOW Then
         GUICtrlSetState($dRET, $GUI_DISABLE)
      Else
         GUICtrlSetState($dRET, $GUI_ENABLE)
      EndIf
   Case "NEW"
      If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 465, 475)
      _ToggleCTRL($tog, $TAB, $nCOMl, $nCOMi, $nCO2l, $nCO2i, $nNAMl, $nNAMi, $nEMAl, $nEMAi, $nPREl, $nPREc)
      _ToggleCTRL($tog, $nACCl, $nACCc, $nPAEb, $nICUl, $nICUi, $nADDi, $nAPLb, $nALOb, $nAAFb, $nPLAl, $nLOCl)
      _ToggleCTRL($tog, $nAFFl, $nRPLb, $nNOTl, $nNOTi, $nADDb, $nCLEb, $nLAST)
   Case "ACCESS"
      If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 465, 330)
      _ToggleCTRL($tog, $ACCd1, $ACCd2, $TYPla, $TYPli, $TYPad, $TYPde, $TYPmu, $TYPmd, $ACCla, $ACCli)
      _ToggleCTRL($tog, $ACCde, $ACCmu, $ACCmd, $ACCdl, $ACCdi, $ACCal, $ACCai, $ACCaa, $taRET)
   Case "TPi"
      _ToggleCTRL($tog, $tpOPEb, $tpCREr, $tpLINr, $tpCO2i, $tpEMAi, $tpEMAl, $tpCREb, $tpCOPb, $tpCOPi, $tpCTOi, $tpCGOb)
      _ToggleCTRL($tog, $tpUFLi, $tpUFLb, $tpICUi, $tpPLAi, $tpLINb, $tpDLIb, $tpUFMi, $tpSCAl, $tpCFAr, $tpCBAr)
   Case "TPC"
      If $tog = $GUI_SHOW Then
         _GuiMod("TPL", $GUI_HIDE)
         _GuiMod("TPH", $GUI_HIDE)
         _GuiMod("TPD", $GUI_HIDE)
      EndIf
      _ToggleCTRL($tog, $tpCO2l, $tpCO2i, $tpCOPl, $tpCOPi, $tpCREb, $tpCOPb, $tpSEPl, $tpCTOl, $tpCTOi, $tpCGOb, $tpLAST)
      _ToggleCTRL($tog, $tpIDNl, $tpIDNi, $tpIDNn, $tpSCAl, $tpEMAi, $tpEMAl, $tpCFAr, $tpCBAr)
   Case "TPL"
      If $tog = $GUI_SHOW Then
         _GuiMod("TPC", $GUI_HIDE)
         _GuiMod("TPH", $GUI_HIDE)
         _GuiMod("TPD", $GUI_HIDE)
      EndIf
      _ToggleCTRL($tog, $tpUFLl, $tpUFLi, $tpUFLb, $tpICUl, $tpICUi, $tpPLAl, $tpPLAi, $tpLINb, $tpDLIb, $tpUFMl, $tpUFMi, $tpIMAb, $tpIMRb)
   Case "TPH"
      If $tog = $GUI_SHOW Then
         _GuiMod("TPC", $GUI_HIDE)
         _GuiMod("TPL", $GUI_HIDE)
         _GuiMod("TPD", $GUI_HIDE)
      EndIf
      _ToggleCTRL($tog, $tpUFLl, $tpUFLi, $tpUFLb, $tpUFMl, $tpUFMi, $tpCOCl, $tpCOCi, $tpCOGb)
   Case "TPD"
      If $tog = $GUI_SHOW Then
         _GuiMod("TPC", $GUI_HIDE)
         _GuiMod("TPL", $GUI_HIDE)
         _GuiMod("TPH", $GUI_HIDE)
      EndIf
      _ToggleCTRL($tog, $tpDIDl, $tpDIDi, $tpDIDb)
   EndSwitch
EndFunc

Func _ToggleCTRL($tog, $c0 = 0, $c1 = 0, $c2 = 0, $c3 = 0, $c4 = 0, $c5 = 0, $c6 = 0, $c7 = 0, $c8 = 0, $c9 = 0, $c10 = 0, $c11 = 0, $c12 = 0)
   For $i = 0 To @NumParams
      GUICtrlSetState(Eval("c" & $i), $tog)
   Next
EndFunc

 

Edited by Aphotic

Share this post


Link to post
Share on other sites



I see only functions.
Can you post also example to show us how to use it ?

 


NEW:     ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-11-12
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Small question/suggestion for your _ToggleCTRL function.  Why not just provide an array to the function?  That way you don't limit yourself to x (12) manually defined parameters and you eliminate the extra overhead from the Eval function.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

On ‎11‎/‎11‎/‎2016 at 4:30 PM, mLipok said:

I see only functions.
Can you post also example to show us how to use it ?

 

Edited the first post.

On ‎11‎/‎14‎/‎2016 at 2:54 PM, spudw2k said:

Small question/suggestion for your _ToggleCTRL function.  Why not just provide an array to the function?  That way you don't limit yourself to x (12) manually defined parameters and you eliminate the extra overhead from the Eval function.

Sometimes, I call the ToggleCTRL function with different groups of control variables, maybe even just two to three.

I like your idea, although I wish I could call it with something like:

ToggleCTRL($GUI_DISABLE, [$nALOb, $nAAFb])

I don't like the idea of having to declare a local variable every time before calling it, unless I'm missing something...

Local $tcArr = [$nALOb, $nAAFb]

ToggleCTRL($GUI_DISABLE, $tcArr)

The idea is to reduce the line count in the main script logic; please advise?

 

Thank you to you both!

 

 

Edited by Aphotic

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Well, you're right...you'd have to define the arrays, but not every time (unless it truly needs to be dynamic).  You could declare arrays for each collection of controls at the beginning of your script.  

edit:
Another idea I thought of to simply the array creation....you could use StringSplit to create an array from a character delimited string with your control IDs.  Really cutting out the Eval overhead is what I was suggesting.  

Edited by spudw2k
1 person likes this

Share this post


Link to post
Share on other sites
21 hours ago, spudw2k said:

Well, you're right...you'd have to define the arrays, but not every time (unless it truly needs to be dynamic).  You could declare arrays for each collection of controls at the beginning of your script.  

edit:
Another idea I thought of to simply the array creation....you could use StringSplit to create an array from a character delimited string with your control IDs.  Really cutting out the Eval overhead is what I was suggesting.  

Yeah, I'd rather not define an array that's going to be used once.

The delimited string idea is perfect, thank you very much; I'll edit the first post with that!

Share this post


Link to post
Share on other sites

I'm not sure if I prefer this method. It may reduce the need for Eval and turn it into a one line solution, although I've never had issues with performance when using Eval and the method I'm currently using is a tad easier to read.

Func _GuiMod($i, $tog, $act = True)
   Switch $i
   Case "MAIN"
      If $tog = $GUI_SHOW And $changes Then
         $changes = False
         ControlClick($GUI, "", $LOGfg)
      Else
      EndIf
      If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 535, 445)
      _ToggleCTRL($tog, $TAB &"|"& $LOGfl &"|"& $LOGfc &"|"& $LOGfi &"|"& $LOGfg &"|"& $LOGta &"|"& $LOGvd &"|"& $LOGtp &"|"& $LOGse)
   Case "DETAILS"
      If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 535, 475)
      Local $cont = True
      If $tog = $GUI_SHOW And $act Then
         If Not UpdateDetails() Then
            $cont = False
            _GuiMod("MAIN", $GUI_SHOW)
         EndIf
      EndIf
      If $cont Then
         _ToggleCTRL($tog, $dUID &"|"& $dICU &"|"& $dACC &"|"& $dCOF &"|"& $dNAM &"|"& $dCO2 &"|"& $dIPW &"|"& $dEMA &"|"& $dEDI &"|"& $dLOG &"|"& $dMOD)
         _ToggleCTRL($tog, $dUPD &"|"& $dINP &"|"& $dAPL &"|"& $dALO &"|"& $dAAF &"|"& $dPLL &"|"& $dLOL &"|"& $dAFL &"|"& $dSAV &"|"& $dCAN &"|"& $dRPL)
         _ToggleCTRL($tog, $dRLA &"|"& $dACT &"|"& $dAC2 &"|"& $dRET &"|"& $dDEL &"|"& $dADD &"|"& $dMQC)
      EndIf
   Case "ADD-INPUT"
      _ToggleCTRL($tog, $nCOMi &"|"& $nCO2i &"|"& $nNAMi &"|"& $nNAMb &"|"& $nEMAi &"|"& $nPREc &"|"& $nACCc &"|"& $nICUi &"|"& $nADDi &"|"& $nNOTi)
      _ToggleCTRL($tog, $nAPLb &"|"& $nALOb &"|"& $nAAFb &"|"& $nPLAl &"|"& $nLOCl &"|"& $nAFFl &"|"& $nRPLb &"|"& $nRLAb &"|"& $nADDb &"|"& $nCLEb)
   Case "PLANS"
      If $tog <> $GUI_SHOW Or Not $changing Then
         If $act Then _ToggleCTRL($tog, $dMOD &"|"& $dLOG &"|"& $dUPD &"|"& $dDEL)
         _ToggleCTRL($tog, $dINP &"|"& $dAPL &"|"& $dALO &"|"& $dAAF &"|"& $dPLL &"|"& $dLOL &"|"& $dAFL &"|"& $dSAV &"|"& $dCAN &"|"& $dRPL &"|"& $dRLA)
      EndIf
   Case "CHANGE"
      _ToggleCTRL($tog, $dITL &"|"& $dITC &"|"& $dAML &"|"& $dAMC &"|"& $dSCB &"|"& $dCCB &"|"& $dEAB)
      If $tog = $GUI_SHOW Then
         GUICtrlSetState($dRET, $GUI_DISABLE)
      Else
         GUICtrlSetState($dRET, $GUI_ENABLE)
      EndIf
   Case "NEW"
      If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 465, 475)
      _ToggleCTRL($tog, $TAB &"|"& $nCOMl &"|"& $nCOMi &"|"& $nCO2l &"|"& $nCO2i &"|"& $nNAMl &"|"& $nNAMi &"|"& $nEMAl &"|"& $nEMAi &"|"& $nPREl &"|"& $nPREc &"|"& $nACCl &"|"& $nACCc &"|"& $nPAEb &"|"& $nICUl &"|"& $nICUi &"|"& $nADDi &"|"& $nAPLb &"|"& $nALOb &"|"& $nAAFb &"|"& $nPLAl &"|"& $nLOCl &"|"& $nAFFl &"|"& $nRPLb &"|"& $nNOTl &"|"& $nNOTi &"|"& $nADDb &"|"& $nCLEb &"|"& $nLAST)
   Case "ACCESS"
      If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 465, 330)
      _ToggleCTRL($tog, $ACCd1 &"|"& $ACCd2 &"|"& $TYPla &"|"& $TYPli &"|"& $TYPad &"|"& $TYPde &"|"& $TYPmu &"|"& $TYPmd &"|"& $ACCla &"|"& $ACCli &"|"& $ACCde &"|"& $ACCmu &"|"& $ACCmd &"|"& $ACCdl &"|"& $ACCdi &"|"& $ACCal &"|"& $ACCai &"|"& $ACCaa &"|"& $taRET)
   Case "TPi"
      _ToggleCTRL($tog, $tpOPEb &"|"& $tpCREr &"|"& $tpLINr &"|"& $tpCO2i &"|"& $tpEMAi &"|"& $tpEMAl &"|"& $tpCREb &"|"& $tpCOPb &"|"& $tpCOPi &"|"& $tpCTOi &"|"& $tpCGOb &"|"& $tpUFLi &"|"& $tpUFLb &"|"& $tpICUi &"|"& $tpPLAi &"|"& $tpLINb &"|"& $tpDLIb &"|"& $tpUFMi &"|"& $tpSCAl &"|"& $tpCFAr &"|"& $tpCBAr)
   Case "TPC"
      If $tog = $GUI_SHOW Then
         _GuiMod("TPL", $GUI_HIDE)
         _GuiMod("TPH", $GUI_HIDE)
         _GuiMod("TPD", $GUI_HIDE)
      EndIf
      _ToggleCTRL($tog, $tpCO2l &"|"& $tpCO2i &"|"& $tpCOPl &"|"& $tpCOPi &"|"& $tpCREb &"|"& $tpCOPb &"|"& $tpSEPl &"|"& $tpCTOl &"|"& $tpCTOi &"|"& $tpCGOb &"|"& $tpLAST &"|"& $tpIDNl &"|"& $tpIDNi &"|"& $tpIDNn &"|"& $tpSCAl &"|"& $tpEMAi &"|"& $tpEMAl &"|"& $tpCFAr &"|"& $tpCBAr)
   Case "TPL"
      If $tog = $GUI_SHOW Then
         _GuiMod("TPC", $GUI_HIDE)
         _GuiMod("TPH", $GUI_HIDE)
         _GuiMod("TPD", $GUI_HIDE)
      EndIf
      _ToggleCTRL($tog, $tpUFLl &"|"& $tpUFLi &"|"& $tpUFLb &"|"& $tpICUl &"|"& $tpICUi &"|"& $tpPLAl &"|"& $tpPLAi &"|"& $tpLINb &"|"& $tpDLIb &"|"& $tpUFMl &"|"& $tpUFMi &"|"& $tpIMAb &"|"& $tpIMRb)
   Case "TPH"
      If $tog = $GUI_SHOW Then
         _GuiMod("TPC", $GUI_HIDE)
         _GuiMod("TPL", $GUI_HIDE)
         _GuiMod("TPD", $GUI_HIDE)
      EndIf
      _ToggleCTRL($tog, $tpUFLl &"|"& $tpUFLi &"|"& $tpUFLb &"|"& $tpUFMl &"|"& $tpUFMi &"|"& $tpCOCl &"|"& $tpCOCi &"|"& $tpCOGb)
   Case "TPD"
      If $tog = $GUI_SHOW Then
         _GuiMod("TPC", $GUI_HIDE)
         _GuiMod("TPL", $GUI_HIDE)
         _GuiMod("TPH", $GUI_HIDE)
      EndIf
      _ToggleCTRL($tog, $tpDIDl &"|"& $tpDIDi &"|"& $tpDIDb)
   EndSwitch
EndFunc

Func _ToggleCTRL($tog, $ctrl)
   Local $arr = StringSplit($ctrl, "|")
   For $i = 1 To Ubount($arr)-1
      GUICtrlSetState($arr[$i], $tog)
   Next
EndFunc

 

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

    • cookiemonster
      Loading window not closing and not staying on top of main window
      By cookiemonster
      Hi,
      I have a main window with one button, when i press that button it brings up a loading screen, but I have two problems with the loading screen at the moment:
      1) Once I have pressed the button, if i open something else full screen over this autoit project (eg: chrome), then on my task bar click on the autoit project to bring it up to the front, the loading screen does not stay on top of the main window, I tried using $WS_EX_TOPMOST but this makes the loading screen stay on top of all windows, I only want it to stay on top of $Main (my main window GUI)
      2) Once the loading screen has been updated to 100%, it should sleep for a further two seconds then close, but at the moment after that 2 seconds, it goes back down to 25% instead of $LoadingWindow being deleted.
      Has anyone got any thoughts or suggestions?
      #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <FontConstants.au3> $Main = GUICreate("Main Window", 600, 480, -1, -1, -1, $WS_EX_ACCEPTFILES) Global $button_Load = GUICtrlCreateButton("Loading Screen", 484, 98, 89, 20, $WS_GROUP) GUICtrlCreateTab(8, 16, 585, 424) GUICtrlCreateTabItem("Settings") GUICtrlCreateGroup("Settings", 16, 50, 569, 380) GUISetState(@SW_SHOWNORMAL) Func Load() WinSetState($Main, "", @SW_DISABLE) LoadingScreen("Loading @ 25%") GUICtrlSetData($LoadingPercent, 25) sleep(2000) LoadingScreen("Loading @ 100%") GUICtrlSetData($LoadingPercent, 100) sleep(2000) GUIDelete($LoadingWindow) WinSetState($Main, "", @SW_ENABLE) EndFunc Func LoadingScreen($LoadingText) ;Creates a Splash Text Screen with a progress bar. Global $LoadingWindow = GUICreate("", 500, 184, -1, -1, BitOR($WS_POPUP, $WS_BORDER), BitOR($WS_EX_WINDOWEDGE, $WS_EX_TOOLWINDOW)) Global $LoadingPercent = GUICtrlCreateProgress(18, 144, 461, 25, $PBS_SMOOTH) GUICtrlCreateLabel($LoadingText, 2, 44, 494, 88, $SS_CENTER) GUICtrlSetFont(-1, 15, 800, 0, "Calibra", $CLEARTYPE_QUALITY) GUISetState(@SW_SHOW) EndFunc While (1) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button_Load Load() EndSwitch WEnd  
    • Katie_Deely
      Copying selected data from GUI Edit
      By Katie_Deely
      Hey
       
      I have a GUI with an edit-field and a button.
      First I write some text into the edit-field and select a part of it. After that I press the button, and the selection is edited.
      How would I do that, though? When the text is selected and I press the button, it's unselected before the button actually raises an event. 
    • Altor
      GUI problem with While loop and buttons
      By Altor
      Hi all
      My problem is that I have no way to work with buttons in a while loop
      When i run the form i can exit well clicking a close main window and olso if i click in a exit button but if i start the apllication whith a Start button  execute a loop for view a random numbers and then i can't stop the rogram and i can't not exit with a Exit button.
      I think the problem is in the use of events but i can not find the solution....
      Thank's to all
      The exemple is this:
      #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> Opt("GUIOnEventMode", 1) $random_numbers = GUICreate("Random numbers",351,171,-1,-1,-1,-1) GUISetOnEvent($GUI_EVENT_CLOSE, "close") $lavel_number = GUICtrlCreateLabel("",117,36,98,26,BitOr($SS_CENTER,$SS_CENTERIMAGE),$WS_EX_STATICEDGE) GUICtrlSetBkColor(-1,"0xFFFFFF") $start = GUICtrlCreateButton("Start",34,95,100,30,-1,-1) GUICtrlSetOnEvent(-1,"start") $stop = GUICtrlCreateButton("Pause",182,95,100,30,-1,-1) GUICtrlSetOnEvent(-1,"pause") $exit = GUICtrlCreateButton("Exit",112,136,100,30,-1,-1) GUICtrlSetOnEvent(-1,"close") GUISetState(@SW_SHOW) While 1 Sleep (50) Wend Func start() While 1 Sleep(100) Local $a = Random(1,10,1) GUICtrlSetData($lavel_number,$a) WEnd EndFunc Func pause() EndFunc func close() exit EndFunc  
    • Satvik
      Unable to open DLL files
      By Satvik
      Hi 
      I am trying to open a dll using DLLOpen, however everytime i try to do so the function fails and returns -1 result. 
      I have the dll in the same folder as the auto it script. 
      Local $hDLL = DllOpen("C:\Users\310255155\Downloads\COMMGvv2\commg.dll") DllCall($hDLL, "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0) DllClose($hDLL) MsgBox(0,'result',$hDLL)  
    • S0lidFr0st
      SQL Query Manipulation
      By S0lidFr0st
      Hello! I'm fairly new to using Autoit, I like the language and simplicity, however, there is a bit of a learning curve for me. I'm stuck and need some community help!
      I need to manipulate a query by using GUICtrlCreateDate to select the correct date and pipe the selected date into my actual query in a specific format (yyyymmdd).
      Here is an example:
      _Flag_RecordsetDisplay($sConnectionString, "select * from trips_to_complete_20161122 where trip_type in ('P','C') and trip_status in ('S','PC','DC') and Flagged = 1") Func _Flag_RecordsetDisplay($sConnectionString, $sQUERY) ; Create connection object Local $oConnection = _ADO_Connection_Create() ; Open connection with $sConnectionString _ADO_Connection_OpenConString($oConnection, $sConnectionString) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) ; Executing some query directly to Array of Arrays (instead to $oRecordset) Local $aRecordset = _ADO_Execute($oConnection, $sQUERY, True) ; Clean Up _ADO_Connection_Close($oConnection) $oConnection = Null ; Display Array Content with column names as headers _ADO_Recordset_Display($aRecordset, 'Recordset content') EndFunc ;==>_Flag_RecordsetDisplay The part of the query that needs modified is "trips_to_complete_20161122" I need to be able to select a date (via the gui) and that selection pipe into my query.  
       
      Thanks in Advanced!