Aphotic

Multi "Screen" GUI Management

8 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 ?

 


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-12-23
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

#8 ·  Posted (edited)

Today I realized a good way to further reduce the needed code to process controls like this.

 

Local $mNamLa = GUICtrlCreateLabel("Name:", 8, 9)
Local $mNamIn = GUICtrlCreateInput("", 50, 5, 220, 20)
Local $mTypLa = GUICtrlCreateLabel("Type:", 12, 39)
Local $mTypAD = GUICtrlCreateRadio("Active Directory", 50, 35, 100)
Local $mTypIn = GUICtrlCreateRadio("Input", 160, 35, 50)
Local $mTypSe = GUICtrlCreateRadio("Select", 220, 35, 50)
Local $mADaLa = GUICtrlCreateLabel("Attribute Name:", 10, 71, 79)
Local $mADaIn = GUICtrlCreateInput("", 90, 67, 180)
Local $mSelLa = GUICtrlCreateLabel("Values:", 30, 71, 44)
Local $mSelCo = GUICtrlCreateCombo("", 75, 67, 120, 25, $CBS_DROPDOWNLIST)
Local $mSelAd = GUICtrlCreateButton("", 205, 64, 26, 26, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\icons\add.ico")
Local $mSelRe = GUICtrlCreateButton("", 240, 64, 26, 26, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\icons\delete.ico")
Local $mActSa = GUICtrlCreateButton("Save", 30, 105, 100, 25)
Local $mActCa = GUICtrlCreateButton("Cancel", 150, 105, 100, 25)

;Using the function below, you can use the following to toggle gui screens.
_ToggleCTRL($GUI_HIDE, "mNamLa", "mActCa")
;Further, it leaves the option to toggle a list of particular ones that are not in order if you need to
_ToggleCTRL($GUI_HIDE, $mTypLa, $mTypAD, $mTypIn, $mTypSe, $mSelLa, $mSelCo)

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)
   If IsString($c0) Then
      For $i = Eval($c0) To Eval($c1)
         GUICtrlSetState($i, $tog)
      Next
   Else
      For $i = 0 To @NumParams
         GUICtrlSetState(Eval("c" & $i), $tog)
      Next
   EndIf
EndFunc

 

Edited by Aphotic

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

    • Lights_On
      By Lights_On
      Hi all,

      I am having a little trouble with ‘GUICtrlSetResizing’ an hoping someone could push me in the direction of best practice.

      I have a basic GUI created to a set size with the enabled abilities to resize it:

      GUICreate("Test", 500, 450, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))

      Inside this I have an image and label:

      GUICtrlCreateLabel($Image1StampInfo, 10, 395, 480, 20, $SS_CENTER) GUICtrlCreatePic($TheImage, 25, 25, 450, 350)

      Using:

      Case ($GUI_EVENT_MAXIMIZE or $GUI_EVENT_RESTORE or $GUI_EVENT_RESIZED)

      I activate:

       
      GUICtrlSetResizing($TheImageBox, $GUI_DOCKAUTO) GUICtrlSetResizing($Image1Stamp, $GUI_DOCKAUTO)

      This works fine with the image but not with the label – the label after a bit of resizing seems to get stuck in different places in the GUI as if the $GUI_DOCKAUTO has not worked properly.

      So 2 questions if I may. 

      1)    Have I used $GUI_DOCKAUTO incorrectly for use with lables?

      2)    I am happy to manually set new sizes dynamically but how? I can get the size of the window with ‘WinGetPos()’ but how do I set new size parameters for the ‘label’ and ‘image’?

      Thank you in advance.

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening guys ( almost good night here in Italy )  
      How are you? Hop you're fine  
      I'm trying to do a Login Form ( I did, but I'm missing something in the management ), that allows the user to login when the script is launched, and, when the main GUI is opened, the user can Logout and Login with another username and password.
      The username and password "checking" I do is done by a text file, which in there are username and password, crypted through _Crypt_EncryptData().
      The "issue" I'm having at the moment, is to manage the Login form when the user hasn't already done the login, and so, the main GUI is not visible, but is created...
      I create the main GUI after the Login form... I tried with WinActive, WinGetState, but nothing changed ( even at the first Login, the script says ( through a MsgBox ) that the Win does exists ( or is active... ) and, as I want, it is not shown again...

      I really don't know If I missed something, or, I don't know...
      I'm going crazy for this thing...
      If someone could help me, I'd really appreaciate it!
      Thanks for the reading
      #Region ### START Koda GUI section ### Form=C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione_Magazzino_v2\form_Login.kxf Global $form_Login = GUICreate("Effettua il Login per continuare:", 405, 120, @DesktopWidth/2 - 202.5, @DesktopHeight/2 - 150) ; 302, 218 GUISetOnEvent($GUI_EVENT_CLOSE, "GUIDeleteLogin") Global $combo_Username = GUICtrlCreateCombo("Di Muro Francesco", 104, 64, 217, 25) GUICtrlSetFont(-1, 10, 400, 0, "Arial") GUICtrlSetData($combo_Username, "somedata") Global $input_Password = GUICtrlCreateInput("", 104, 89, 217, 25, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) GUICtrlSetFont(-1, 10, 400, 0, "Arial") $button_VerificaDati = GUICtrlCreateButton("", 328, 66, 42, 42, $BS_ICON) GUICtrlSetImage(-1, "C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione_Magazzino_v2\Icone\icon_check.ico", -1) GUICtrlSetOnEvent($button_VerificaDati, "CheckLogin") $label_Titolo = GUICtrlCreateLabel("Login", 167, 14, 71, 33) GUICtrlSetFont(-1, 18, 800, 0, "Arial") $label_Username = GUICtrlCreateLabel("Username :", 24, 64, 76, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $label_Password = GUICtrlCreateLabel("Password :", 24, 89, 73, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") #EndRegion ### END Koda GUI section ### Func CheckLogin() Local $sUsername = GUICtrlRead($combo_Username) Local $sPassword = GUICtrlRead($input_Password) MsgBox($MB_ICONINFORMATION, "", "Username: " & $sUsername & @CRLF & "Password: " & $sPassword) Local $sFileUtenti = @ScriptDir & "\utenti.txt" If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura del file!") Exit Else Local $hFileUtenti = FileOpen($sFileUtenti, $FO_READ) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file " & $sFileUtenti & "." & @CRLF & "Errore: " & @error) Else Local $sDatiUtente, $aDatiUtente Local $bUtenteTrovato = False Local $iLinea = 1 Local $sControlloWin = "" Local $sWin = WinGetState($form_GestioneMagazzino) MsgBox($MB_ICONINFORMATION, "", $sWin) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la verifica della GUI attiva." & @CRLF & "Errore: " & @error) EndIf If($sWin == 5) Then MsgBox($MB_ICONINFORMATION, "", "La GUI esiste!") Do $sDatiUtente = FileReadLine($hFileUtenti, $iLinea) $aDatiUtente = StringSplit($sDatiUtente, "|", $STR_NOCOUNT) If(BinaryToString(_Crypt_DecryptData($aDatiUtente[0], "CRYPT", $CALG_RC4)) = $sUsername And BinaryToString(_Crypt_DecryptData($aDatiUtente[1], "CRYPT", $CALG_RC4)) = $sPassword) Then $sControlloWin = "ESISTE" $bUtenteTrovato = True ExitLoop Else $iLinea+=1 If($sDatiUtente = "" And $bUtenteTrovato = False) Then MsgBox($MB_ICONWARNING, "Attenzione!", "Username o Password errati.") ExitLoop EndIf EndIf Until $bUtenteTrovato = True Else MsgBox($MB_ICONINFORMATION, "", "La GUI esiste!") Do $sDatiUtente = FileReadLine($hFileUtenti, $iLinea) $aDatiUtente = StringSplit($sDatiUtente, "|", $STR_NOCOUNT) If(BinaryToString(_Crypt_DecryptData($aDatiUtente[0], "CRYPT", $CALG_RC4)) = $sUsername And BinaryToString(_Crypt_DecryptData($aDatiUtente[1], "CRYPT", $CALG_RC4)) = $sPassword) Then $sControlloWin = "NON ESISTE" $bUtenteTrovato = True ExitLoop Else $iLinea+=1 If($sDatiUtente = "" And $bUtenteTrovato = False) Then MsgBox($MB_ICONWARNING, "Attenzione!", "Username o Password errati.") ExitLoop EndIf EndIf Until $bUtenteTrovato = True EndIf If($sControlloWin = "ESISTE") Then MsgBox($MB_ICONINFORMATION, "Login effettuato!", "Hai effettuato l'accesso come: " & @CRLF & $sUsername & ".") ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) GUICtrlSetState($button_VisualizzaGiacenze, $GUI_ENABLE) GUICtrlSetState($button_AggiungiProdotto, $GUI_ENABLE) GUICtrlSetState($button_PrelevaProdotto, $GUI_ENABLE) GUICtrlSetState($button_RicercaProdotto, $GUI_ENABLE) GUICtrlSetState($button_CreaDDT, $GUI_ENABLE) GUICtrlSetState($button_MostraGiacenzeAZero, $GUI_ENABLE) GUICtrlSetState($combo_Magazzino, $GUI_ENABLE) GUICtrlSetState($button_Logout, $GUI_ENABLE) ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) ; Setta l'utente che ha effettuato l'accesso nella label $label_CaptionUtente GUICtrlSetData($label_CaptionUtente, $sUsername) ; "Distruggi" la GUI Login GUIDelete($form_Login) FileClose($hFileUtenti) Else MsgBox($MB_ICONINFORMATION, "", "La GUI non esiste!") MsgBox($MB_ICONINFORMATION, "Login effettuato!", "Hai effettuato l'accesso come: " & @CRLF & $sUsername & ".") ; Mostra la GUI Principale GUISetState(@SW_SHOW, $form_GestioneMagazzino) ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) ; Setta l'utente che ha effettuato l'accesso nella label $label_CaptionUtente GUICtrlSetData($label_CaptionUtente, $sUsername) ; "Distruggi" la GUI Login GUIDelete($form_Login) FileClose($hFileUtenti) EndIf EndIf EndIf EndFunc Func Logout() GUICtrlSetData($label_CaptionUtente, "") MsgBox($MB_ICONINFORMATION, "Logout effettuato!", "Effettua nuovamente il Login per utilizzare il programma.") ; Disabilita tutti i bottoni della GUI Principale GUICtrlSetState($button_VisualizzaGiacenze, $GUI_DISABLE) GUICtrlSetState($button_AggiungiProdotto, $GUI_DISABLE) GUICtrlSetState($button_PrelevaProdotto, $GUI_DISABLE) GUICtrlSetState($button_RicercaProdotto, $GUI_DISABLE) GUICtrlSetState($button_CreaDDT, $GUI_DISABLE) GUICtrlSetState($button_MostraGiacenzeAZero, $GUI_DISABLE) GUICtrlSetState($combo_Magazzino, $GUI_DISABLE) GUICtrlSetState($button_Logout, $GUI_DISABLE) ; Abilita il Login GUICtrlSetState($button_Login, $GUI_ENABLE) EndFunc EDIT:
      Solved, making an "integrated" Login form... 
    • AnonymousX
      By AnonymousX
      Hello, 
      I'm wondering if it is possible to read a radio button off a GUI running by another program? 
      Someone created these Outlook emails that when open appear to be in a GUI format. I could easily come up with a way of navigating these fields by using tab inputs, and then copying specific fields that I need. However there is a spot on the form that has 4 choices of radio buttons, asking for what the status of the task is, and I have no idea how to store which one of these was pressed. 
      End game is to be able to go through thousands of these forms, take input from specific fields from this GUI form in outlook and copy into cells in an excel spreadsheet. I believe I could create a script to do everything I need, if I could just obtain the value from which radio button was pressed.
      Any advice on how to obtain which radio button was press in this outlook form would be appreciated.
      Thanks,
      If I knew VBA better Outlook might have its own functions for figuring this out.
       
      Example:

      In this example I'd want to be able to know that the 2nd or Assigned radio button was selected. Only 1 button is able to be selected at a time. I'm assuming the way to do this would be to tab through the form get to the first box and then run some command to check if pressed then if no, keep checking till I find which of the 4 were pressed.
    • rcmaehl
      By rcmaehl
      A UDF with Extended Functions for Window Management

      DISCLAIMER:
      This UDF is still in the development phase. All code works and should be generally bug free, however function names and parameters are subject to change.
       
      Notes:
      Fixes _WindowGetClassList's barbaric returning of a @LF separated string instead of an array.
       
      Potential Uses:
      Automating applications that change their controls' handles/classes on each launch (e.g. half of Cisco's programs)
       
      Functions:
      _WinGetClassList
      _WinGetClassNNList
      _WindowGetHandleList
      _WindowGetHandleListFromPos
       
      Download: 
      WindowEx.zip  (v0.4)
       
      Changelog:
      10/04/2016 (v0.4): _WinGetClassNNList Fixed : Not Returning an Index when using $2D_ARRAY _WinGetClassNNList Fixed : Not Properly returning $aArray[x][1] on Classes with instances > 9 when using $2D_ARRAY 10/03/2016 (v0.3): _WinGetClassList Added : Exactly the same as WinGetClassList but returns a more civilized Array _WinGetClassNNList Added : Returns Classes and their instances in either a 1D or 2D array depending on Flags _WindowGetHandleList Renamed: _WinGetHandleList SCRIPT BREAKING! _WindowGetHandleListFromPos Renamed: _WinGetHandleListFromPos SCRIPT BREAKING! 10/01/2016 (v0.2): WindowsExConstants.au3 Added : Flags in _WindowGetHandleListFromPos _WindowGetHandleListFromPos Removed: ConsoleWrite left in during debug _WindowGetHandleListFromPos Added : Flag for if part of a Control is at $X, $Y return it as well. 10/01/2016 (v0.1): _WindowGetHandleList Added : Retrieves the handles of classes from a window. _WindowGetHandleListFromPos Added : Retrieves the handles of classes at a specific position from a window. Known and Reported Bugs:
      None reported To Do:
      To Be Decided. Opinions welcome! Upcoming Changes:
      To Be Decided.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning guys
      How are you? Hope you're fine
      I'm doing some field checking...
      Can you suggest me something? Something like: If the user doesn't prompt anything in a field, MsgBox and focus on the "blank" field, else, keep up with the script.
      I thought on a nested If...Else, but I have something like 10+ edit to control...
      Thanks guys! 
      EDIT:
      And I would like to know either how to retrieve all listview item ( 2 columns ) from a ListView...
      Column A|Column B
      abcd         | 1234
      bcda         | 1432
      How can I retrieve an array with abcd|1234|bcda|1432 ?
      Thanks