Valnurat

Several small issues

14 posts in this topic

#1 ·  Posted (edited)

I have put all my small issues into one thread hope that is fine.

I have GUI with many GUICtrlCreateInput and it's working ok.

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=x86\Create Consultant.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <AD.au3>
#include <Array.au3>

Main()

Func Main()
    _AD_Open()
    If @error Then Exit MsgBox(0x40010, "ERROR", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)
    Local $sUsername = InputBox('OPTIONAL', 'Please enter the username.' & @CRLF & @CRLF & 'Exampel: '& @UserName)
    If @error = 1 Then Exit
    If $sUsername <> "" Then
        Local $sFQDN = _AD_SamAccountNameToFQDN($sUsername)
        if @error = 1 Then
            MsgBox(64, "Info", "User '" & $sUsername & "' does not exist")
            Exit
        EndIf
;   MsgBox(64, "Info", "User '" & $sFQDN & @CRLF & _AD_GetObjectAttribute($sFQDN, 'department'))
    EndIf
;   MsgBox(64, "Info", "User '" & $sFQDN & @CRLF & _AD_GetManager($sFQDN, 'department'))

    local $aObj = _AD_GetObjectsInOU("OU=Users,OU=so,OU=dk,OU=company,DC=AD,DC=company,DC=ORG","(&(objectclass=person)(sAMAccountName=" & $sUsername & "))",2,"department,physicalDeliveryOfficeName,company", "")
_ArrayDisplay($aObj)
    _ArrayDelete($aObj,0)
; Create a GUI with various controls.
    Local $hGUI = GUICreate("Create Consultant")
    GUICtrlCreateLabel("First name:", 10, 13)
    Local $idFirst = GUICtrlCreateInput("", 90, 10, 150, 20)
    GUICtrlCreateLabel("Shortname:", 245, 13)
    Local $idShort = GUICtrlCreateInput("", 300, 10, 90, 20)
    GUICtrlCreateLabel("Last name:", 10, 43)
    Local $idLast = GUICtrlCreateInput("", 90, 40, 300, 20)
    GUICtrlCreateLabel("Display name:", 10, 73)
    Local $idDisplay = GUICtrlCreateInput("", 90, 70, 300, 20)
    GUICtrlCreateLabel("Description:", 10, 103)
    Local $idRadio1 = GUICtrlCreateRadio("Consultant", 90, 100)
    Local $idRadio2 = GUICtrlCreateRadio("Group Account", 190, 100)
    GUICtrlCreateLabel("Email:", 10, 133)
    Local $idEmail = GUICtrlCreateInput("", 90, 130, 300, 20)
    GUICtrlCreateLabel("Department:", 10, 163)
    If $sUsername <> "" Then
        Local $idDepart = GUICtrlCreateInput($aObj[0][0], 90, 160, 300, 20)
    Else
        Local $idDepart = GUICtrlCreateInput("", 90, 160, 300, 20)
    EndIf
    GUICtrlCreateLabel("Office:", 10, 193)
    If $sUsername <> "" Then
        Local $idOffice = GUICtrlCreateInput($aObj[0][1], 90, 190, 80, 20)
    Else
        Local $idOffice = GUICtrlCreateInput("", 90, 190, 80, 20)
    EndIf
    Local $idCheckBox = GUICtrlCreateCheckbox("End date", 330, 190, 80, 20)
    Local $idDate = GUICtrlCreateDate("", 200, 190, 120, 20)
    GUICtrlSetState($idDate,$gui_disable)

    GUICtrlCreateLabel("Manager:", 10, 223)
    Local $idComboBox = GUICtrlCreateCombo("", 90, 220, 150, 100)
    GUICtrlCreateLabel("Misal code:", 245, 223)
    If $sUsername <> "" Then
        Local $idMisalCode = GUICtrlCreateInput($aObj[0][2], 310, 220, 80, 20)
    Else
        Local $idMisalCode = GUICtrlCreateInput("", 310, 220, 80, 20)
    EndIf
    GUICtrlCreateLabel("Ticket no.:", 10, 253)
    Local $idTicketNo = GUICtrlCreateInput("", 90, 250, 150, 20)
    GUICtrlCreateLabel("Cost no.:", 245, 253)
    Local $idCostNo = GUICtrlCreateInput("", 290, 250, 100, 20)
    GUICtrlCreateLabel("Ext. Company:", 10, 283)
    Local $idExtComp = GUICtrlCreateInput("", 90, 280, 300, 20)

    GUICtrlCreateGroup("Optional, if no Email", 10, 310, 380, 55)
    GUICtrlCreateLabel("Ext. Email:", 20, 333)
    Local $idExtEmail = GUICtrlCreateInput("", 90, 330, 290, 20)


    local $aObject = _AD_GetObjectsInOU("OU=Users,OU=so,OU=dk,OU=company,DC=AD,DC=company,DC=ORG","(&(objectclass=person)(StaffManager=TRUE))",2,"sAMAccountName,distinguishedName,displayname", "displayname")
;   _ArrayDisplay($aObject,"")
    If IsArray($aObject) Then
        Local $sFill = ""
        For $i = 1 To $aObject[0][0]
            $sFill &= $aObject[$i][2] & "|"
        Next
        $sFill = StringTrimRight($sFill,1)
        ; Add additional items to the combobox.
        GUICtrlSetData($idComboBox, $sFill, "")
    EndIf
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)
    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idOK
                MsgBox($MB_SYSTEMMODAL, "", "test")
                Global $sFirst = GUICtrlRead($idFirst)
                Global $sShort = GUICtrlRead($idShort)
                Global $sLast = GUICtrlRead($idLast)
                Global $sDisp = GUICtrlRead($idDisplay)
                If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                    MsgBox($MB_SYSTEMMODAL, "test", "Consultants")
                EndIf

                Global $sEmail = GUICtrlRead($idEmail)
                Global $sDepart = GUICtrlRead($idDepart)
                Global $sOffice = GUICtrlRead($idOffice)
                Global $sManager = GUICtrlRead($idComboBox)
                If $sManager <> "" Then
                    MsgBox($MB_SYSTEMMODAL, "test", $sManager)
                EndIf
                Global $sMisalCode = GUICtrlRead($idMisalCode)
                Global $sTicketNo = GUICtrlRead($idTicketNo)
                Global $sCostNo = GUICtrlRead($idCostNo)
                Global $sExtCompe = GUICtrlRead($idExtComp)
                Global $sExtEmail = GUICtrlRead($idExtEmail)
                ExitLoop
            Case $idCheckBox
                If _IsChecked($idCheckbox) Then
                    GUICtrlSetState($idDate,$gui_enable)
                Else
                    GUICtrlSetState($idDate,$gui_disable)
                EndIf

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
    ; Create a new user
#cs Global $iValue = _AD_CreateUser($sOU, $sShort, "Doe John")
    If $iValue = 1 Then
        MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' in OU '" & $sOU & "' successfully created")
    ElseIf @error = 1 Then
        MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' already exists")
    ElseIf @error = 2 Then
        MsgBox(64, "Active Directory Functions - Example 1", "OU '" & $sOU & "' does not exist")
    ElseIf @error = 3 Then
        MsgBox(64, "Active Directory Functions - Example 1", "Value for CN (e.g. Lastname Firstname) is missing")
    ElseIf @error = 4 Then
        MsgBox(64, "Active Directory Functions - Example 1", "Value for $sAD_User is missing")
    Else
        MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory")
#ce EndIf
    _AD_Close()
EndFunc

Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

Now I have to read all GUICtrlCreateInput and I want to be sure that all GUICtrlCreateInput is filled. Do I have to this for all of them:

Global $sManager = GUICtrlRead($idComboBox)
                If $sManager <> "" Then
                    MsgBox($MB_SYSTEMMODAL, "test", $sManager)
                    Global $bManager = True
                EndIf

Or is there a nice way of controlling that they all are filled out?

And how can I be in the loop until all fields are filled out?

 

I also have 2 radiobuttons. 1 with text "Consultants" and 1 with "Group account".

How do I get the text from the 1 that's active? I tried this and it's working, but is there another way?

If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                    MsgBox($MB_SYSTEMMODAL, "test", "Consultants")
                EndIf

 

Edited by Valnurat

Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites



Anyone who could help?


Yours sincerely

Kenneth.

Share this post


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

Or is there a nice way of controlling that they all are filled out?

first, declare your variables at the top of your script, unconditionally. yes, i know it works for you; it does not work for everyone else trying to troubleshoot your issues, and it is by nature prone to more issues than you would care to tackle.

second, when you post a reproducer, do try to strip it down. why are you sending people, who are here to help you, on a quest to download the AD UDF? and worse, no-one can test your script without an Active Directory infrastructure! quite inconsiderate i dare say. yes, i know i can modify your script to eliminate those; but that's not my job, is it?

now, please revise your reproducer. then, you can create your inputs sequentially and loop their id for testing empty fields. i'd be happy to elaborate when a working reproducer, with variables properly declared, is available.

 

Share this post


Link to post
Share on other sites

1st, do you mean like this:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=x86\Create Consultant.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <AD.au3>
#include <Array.au3>

Global $sUsername, $sFQDN
Global $aObj
Global $hGUI
Global $idFirst, $idShort, $idLast, $idDisplay, $idRadio1, $idRadio2, $idEmail

Main()

ect...

if not, then I'm not sure what you mean that I need to declare my variables at the top.

If it is, then why is the exampels, that comes with AutoIT, not like this. I guess if the exampels is like what I started with, then it should be ok, but I was wrong.

2nd, I'm not asking people here to download AD.au3 at all. I'm asking if there is a nice way to control that all the fields are used. That, I think you don't need AD.au3 to accomplished, cause the AD.au3 and GUICtrlCreateInput is totally diffirent, right. And am I asking you to do the job for me? I don't think so, I'm asking for a nice way. Maybe there was a special command in AutoIT the could do it, that I was not aware of or someone could just give me an exampel on how to do it.

3rd, the reason for me to show my code, is

   3.1 - because someone might want to use it

   3.2 - that I have seen in this forum that, when people want to have help and didn't showed the code they was scold, like you do now, so tell me Mr. Orbs, what should n00bs - like me - do to fitt your needs?

 


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

42 minutes ago, Valnurat said:

that I have seen in this forum that, when people want to have help and didn't showed the code they was scold

there is a reason why people want to see your code. the reason is simple: it is easier to suggest and test solutions.

if you do not provide code, or provide a code that is not runnable, then the entire discussion becomes theoretical. not that i mind having a theoretical discussion, but this forum is about help and support, and if one wishes to get help and support, then usually one has a more concrete situation to resolve.

for example, if i were to ask your question about checking for existence of content in multiple input fields, i would post this reproducer - based on the GUICreate example, adding a few labels and input controls:

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")

    GUICtrlCreateLabel('input 1:', 20, 50)
    Local $idInput1 = GUICtrlCreateInput('', 120, 50, 100, 20)
    GUICtrlCreateLabel('input 2:', 20, 100)
    Local $idInput2 = GUICtrlCreateInput('', 120, 100, 100, 20)
    GUICtrlCreateLabel('input 3:', 20, 150)
    Local $idInput3 = GUICtrlCreateInput('', 120, 150, 100, 20)

    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idOK
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

it is runnable, and so is my suggested solution:

1 hour ago, orbs said:

create your inputs sequentially and loop their id

which results in this code - note the change of order of creating the controls (all labels first, all inputs sequentially together), and what happens when you click the OK button:

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")

    GUICtrlCreateLabel('input 1:', 20, 50)
    GUICtrlCreateLabel('input 2:', 20, 100)
    GUICtrlCreateLabel('input 3:', 20, 150)
    Local $idInput1 = GUICtrlCreateInput('', 120, 50, 100, 20)
    Local $idInput2 = GUICtrlCreateInput('', 120, 100, 100, 20)
    Local $idInput3 = GUICtrlCreateInput('', 120, 150, 100, 20)

    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idOK
                ConsoleWrite('--- checking for empty input fields ---' & @CRLF)
                For $id = $idInput1 To $idInput3
                    If GUICtrlRead($id) = '' Then ConsoleWrite('at least one input is empty' & @CRLF)
                Next

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

now, about relying on help fie examples: do that with caution. it declares local variables inside functions, which is OK; but it declares variables while creating the controls, which is also OK but some people would find it to be trouble-inviting. this is because there is a short distance between that, and between what you are doing: declaring global variables inside a function, and declaring them conditionally. both cases can not end well. with the first slightest oversight your entire code goes kaboom, and these practices makes your life harder in debugging your own code.

23 hours ago, Valnurat said:

I also have 2 radiobuttons. 1 with text "Consultants" and 1 with "Group account".

How do I get the text from the 1 that's active?

for that, you can use GuiCtrlRead in "advanced" mode - see the help file.

42 minutes ago, Valnurat said:

3rd, the reason for me to show my code, is

   3.1 - because someone might want to use it

this is why we have the Example Scripts forum, and everyone is happy of any contribution. but before you post code for public use, make sure to describe its purpose, use case, dependencies, etc. don't send your users on a quest to discover all that.

Edited by orbs

Share this post


Link to post
Share on other sites

I have done this and I hope it's ok that I post it.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=x86\Create Consultant.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

Global $hGUI, $sUsername, $aUserNfo
Global $idInput1, $idInput2, $idInput3, $idInput4, $idInput5, $idInput6, $idInput7, $idInput8, $idInput9, $idInput10, $idInput11, $idInput12, $idInput13, $idRadio1, $idRadio2, $idCheckBox ,$idDate, $idOKay

FormCreate()
Main()

Func Main()
    Local $bManager, $bGoodToGo
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idOKay
                For $id = $idInput1 to $idInput13
                    if GUICtrlRead($id) = '' Then
                        MsgBox(64, "info", "At least one input is empty.")
                        ExitLoop
                    EndIf
                Next
                $sFirst = GUICtrlRead($idInput1)
                $sShort = GUICtrlRead($idInput2)
                $sLast = GUICtrlRead($idInput3)
                $sDisp = GUICtrlRead($idInput4)
            Case $idCheckBox
                If _IsChecked($idCheckbox) Then
                    GUICtrlSetState($idDate,$gui_enable)
                Else
                    GUICtrlSetState($idDate,$gui_disable)
                EndIf
        EndSwitch
    WEnd
    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc

Func FormCreate()
    Local $aObjManager
    $sUsername = ''
; Create a GUI with various controls.
    $hGUI = GUICreate("Create Consultant")
    GUICtrlCreateLabel("First name:", 10, 13)
    GUICtrlCreateLabel("Shortname:", 245, 13)
    GUICtrlCreateLabel("Last name:", 10, 43)
    GUICtrlCreateLabel("Display name:", 10, 73)
    GUICtrlCreateLabel("Description:", 10, 103)
    GUICtrlCreateLabel("Email:", 10, 133)
    GUICtrlCreateLabel("Department:", 10, 163)
    GUICtrlCreateLabel("Office:", 10, 193)
    GUICtrlCreateLabel("Manager:", 10, 223)
    GUICtrlCreateLabel("Misal code:", 245, 223)
    GUICtrlCreateLabel("Ticket no.:", 10, 253)
    GUICtrlCreateLabel("Cost no.:", 245, 253)
    GUICtrlCreateLabel("Ext. Company:", 10, 283)
    GUICtrlCreateLabel("Ext. Email:", 20, 333)
    $idInput1 = GUICtrlCreateInput("First", 90, 10, 150, 20)
    $idInput2 = GUICtrlCreateInput("Shortname", 300, 10, 90, 20)
    $idInput3 = GUICtrlCreateInput("Last", 90, 40, 300, 20)
    $idInput4 = GUICtrlCreateInput("Display", 90, 70, 300, 20)
    $idInput5 = GUICtrlCreateInput("Email", 90, 130, 300, 20)
    If $sUsername <> "" Then
        $idInput6 = GUICtrlCreateInput($aUserNfo[0][0], 90, 160, 300, 20)
    Else
        $idInput6 = GUICtrlCreateInput("Depart", 90, 160, 300, 20)
    EndIf
    If $sUsername <> "" Then
        $idInput7 = GUICtrlCreateInput($aUserNfo[0][1], 90, 190, 80, 20)
    Else
        $idInput7 = GUICtrlCreateInput("Office", 90, 190, 80, 20)
    EndIf
    $idInput8 = GUICtrlCreateInput("", 90, 220, 150, 20)
;   $idInput8 = GUICtrlCreateCombo("", 90, 220, 150, 100)
    If $sUsername <> "" Then
        $idInput9 = GUICtrlCreateInput($aUserNfo[0][2], 310, 220, 80, 20)
    Else
        $idInput9 = GUICtrlCreateInput("Misal", 310, 220, 80, 20)
    EndIf
    $idInput10 = GUICtrlCreateInput("Ticket", 90, 250, 150, 20)
    $idInput11 = GUICtrlCreateInput("Cost", 290, 250, 100, 20)
    $idInput12 = GUICtrlCreateInput("ExtComp", 90, 280, 300, 20)
    $idInput13 = GUICtrlCreateInput("ExtEmail", 90, 330, 290, 20)

    GUICtrlCreateGroup("Optional, if no Email", 10, 310, 380, 55)
    $idRadio1 = GUICtrlCreateRadio("Consultant", 90, 100)
    $idRadio2 = GUICtrlCreateRadio("Group Account", 190, 100)
    $idCheckBox = GUICtrlCreateCheckbox("End date", 330, 190, 80, 20)
    $idDate = GUICtrlCreateDate("", 200, 190, 120, 20)
    GUICtrlSetState($idDate,$gui_disable)
    $idOKay = GUICtrlCreateButton("OK", 310, 370, 85, 25)
    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)
EndFunc


Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

I do get the Info if some of the fields are not filled out, but how can I read the fields when all of them is filled out?

Right now the fields will be read no matter what.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
3 hours ago, Valnurat said:

how can I read the fields when all of them is filled out?

first you must define what exactly is "filled out". if you mean "all fields contain some text" then you will get the "all filled" signal immediately when the user start typing the first character in the last field. i'm certain this is not what you want. what's wrong with checking for empty fields when the user click OK?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Nothing is wrong by checking for empty fields when the user click ok.

But the in my code it will still read the fields even if they are empty. I want, after all fields contains some text, to read them and then close GUI and then I will create the user in our system.

At this point my application is looping in the While .. WEnd, but I need a ExitLoop to exit that, but if I do that, it will read empty fields and exitloop and delete my GUI.

Func Main()
    Local $bManager, $bGoodToGo
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idOKay
                For $id = $idInput1 to $idInput13
                    if GUICtrlRead($id) = '' Then
                        MsgBox(64, "info", "At least one input is empty.")
                        ExitLoop
                    EndIf
                Next
                $sFirst = GUICtrlRead($idInput1)
                $sShort = GUICtrlRead($idInput2)
                $sLast = GUICtrlRead($idInput3)
                $sDisp = GUICtrlRead($idInput4)
                ExitLoop
            Case $idCheckBox
                If _IsChecked($idCheckbox) Then
                    GUICtrlSetState($idDate,$gui_enable)
                Else
                    GUICtrlSetState($idDate,$gui_disable)
                EndIf
        EndSwitch
    WEnd
    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc

Maybe my explaination for my goal is not so clear, sorry about that.

Edited by Valnurat

Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

replace this:

MsgBox(64, "info", "At least one input is empty.")
                        ExitLoop

with this:

MsgBox(64, "info", "At least one input is empty.", 0, $hGUI)
                        ContinueLoop 2

so instead of exiting the secondary loop (the For...Next loop) and proceeding on reading the fields and exiting the main loop, you just continue the main loop as if nothing happened. look at the help for ContinueLoop.

also, the for MsgBox call - add the last parameter to assign the MsgBox to your GUI, so the main GUI cannot become operational until the user acknowledges the MsgBox. because currently, if the user simply ignores the MsgBox and just clicks on the GUI, the GUI gets focus but the MsgBox is left behind, blocking the GUI actions. ugly.

EDIT: ignore snippets indentation. bloody forum software.

Edited by orbs

Share this post


Link to post
Share on other sites
On 8/26/2016 at 10:08 AM, orbs said:

... declare your variables at the top of your script, unconditionally. yes, i know it works for you; it does not work for everyone else trying to troubleshoot your issues, and it is by nature prone to more issues than you would care to tackle ...

well, it didn't take too long for someone to show up with this issue - caused directly by incorrectly declaring a variable.

Share this post


Link to post
Share on other sites
5 hours ago, orbs said:

replace this:

MsgBox(64, "info", "At least one input is empty.")
                        ExitLoop

with this:

MsgBox(64, "info", "At least one input is empty.", 0, $hGUI)
                        ContinueLoop 2

so instead of exiting the secondary loop (the For...Next loop) and proceeding on reading the fields and exiting the main loop, you just continue the main loop as if nothing happened. look at the help for ContinueLoop.

also, the for MsgBox call - add the last parameter to assign the MsgBox to your GUI, so the main GUI cannot become operational until the user acknowledges the MsgBox. because currently, if the user simply ignores the MsgBox and just clicks on the GUI, the GUI gets focus but the MsgBox is left behind, blocking the GUI actions. ugly.

EDIT: ignore snippets indentation. bloody forum software.

Thank you very much.

It was an instructive experience for the me.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

When I meantioned that I had 2 radiobuttons, you said for that, I can use GuiCtrlRead in "advanced" mode - see the help file.

Do I have to do this:

If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
    $sres = GUICtrlRead($idRadio1, $GUI_READ_EXTENDED)
EndIf
If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
    $sres = GUICtrlRead($idRadio2, $GUI_READ_EXTENDED)
EndIf

It seems to work, but I'm not sure it is correct, because then I feel I just could have done this:

If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
    $sres = "Consultants"
EndIf
If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
    $sres = "Group Account"
EndIf

 


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

when you have only two radio options, then you can just check them directly, with 6 lines of code.

but how many lines of such code would it take to check five or seven radio options?

15 to 21 lines of code.

but if you apply the same loop check that we did for the input fields, you would have only 3 lines of code for no matter how many radio options you have:

For $id = $idRadio1 To $idRadio7
    If GUICtrlRead($id) = $GUI_CHECKED Then $sres = GUICtrlRead($id, $GUI_READ_EXTENDED)
Next
; of the 7 radio options, $sres now holds the text of the selected one

 

Edited by orbs

Share this post


Link to post
Share on other sites

Yes, you are right.

I was not thinking clear.

Thank you.


Yours sincerely

Kenneth.

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

    • Skysnake
      By Skysnake
      Scite comes up occasional, almost incidentally, in some support topics.  I have not found a "Scite" topic in the forums, so this is where I will start.  I have recently been using Scite intensively, specifically with a large project and I have certain issues.  I know that Scite is not an AutoIt product, but it is so closely integrated to the core release that it makes sense to raise issues and request support here.  If this is not the right please refer me to the right forum.
      Thx
       
      Skysnake
    • P3rsp3ctiv3
      By P3rsp3ctiv3
      Hello how can I send a {Enter} into the edit window ($cmd)? I tried it first with:
      GUICtrlSetData($cmd, "Line 1" + "{ENTER}")
      but it doesn´t work. Can someone help me please?
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> $Admin = GUICreate("Admin", 234, 168, 192, 229, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE)) GUISetBkColor(0xB4B4B4) $exit = GUICtrlCreateButton("Close", 160, 136, 65, 25) $cmd = GUICtrlCreateEdit("",0, 0, 225, 137, $ES_AUTOVSCROLL + $WS_VSCROLL) GUICtrlSetData(-1, "") GUICtrlSetFont(-1, 10, 400, 0, "Candara") GUICtrlSetBkColor(-1, 0xE3E3E3) $cmd_clear = GUICtrlCreateButton("Clear", 9, 136, 65, 25) GUISetState(@SW_SHOW) HotKeySet("{f1}", CMD_1) HotKeySet("{f2}", CMD_2) While 1 $msg = GUIGetMsg(1) Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $exit GUIDelete($Admin) Exit EndSwitch WEnd Func CMD_1(); GUICtrlSetData($cmd, "Line 1" & "{ENTER}") GUICtrlSetData($cmd, "Line 2" & "{ENTER}") EndFunc Func CMD_2(); GUICtrlSetData($cmd, "Line 3" & "{ENTER}") GUICtrlSetData($cmd, "Line 4" & "{ENTER}") EndFunc
    • nacerbaaziz
      By nacerbaaziz
      hello
      please i need to link a progress bar with a time can you help me?
      e.g
      i want to set a progress bar for 10 sec
      am waiting for your answers
      thank you.
    • AdminC
      By AdminC
      #RequireAdmin
      #include <SendMessage.au3>
      #include <WinAPI.au3>
      #include <WindowsConstants.au3>
      #include <GDIPlus.au3>
      #include <GUIConstantsEx.au3>
      #include <WinAPIGdi.au3>
      #include <Array.au3>
      #include <WinAPIDiag.au3>
      $Imglocation = @ScriptDir&"\Image\testimg.bmp"
      _GDIPlus_Startup()
      Local $Bitmap = _GDIPlus_BitmapCreateFromFile($Imglocation)
      Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Bitmap)
      Local $imgSize = _WinAPI_GetBitmapDimension($hBitmap)
      Local $imgBits = DllStructCreate('dword[' & ($imgSize.X * $imgSize.Y) & ']')
      _WinAPI_GetBitmapBits($hBitmap, DllStructGetSize($imgBits), DllStructGetPtr($imgBits))
      _WinAPI_DisplayStruct($imgBits)
      MsgBox(0, "", DllStructGetData($imgBits, 1, 1)) 
      _GDIPlus_Shutdown()
      DllstructGetData can't get data color B, G, R value. Who's know that? teach me plz
       
    • Miliardsto
      By Miliardsto
      Hello. Im trying to make my scripts safe - unnable to decompile. I search for obfuscators and other security methods but the search has come to nothing.
      Then one guy gave that idea below. If I rightly understood this idea lets we talk about example program with this secutiy method.
      Program have two parts, first is only login gui and the second part is the main program Second part (main program) is uploaded on ftp server lets say that on http://xxx/autoit/main_program.au3 So we have the first gui with login, we put correctly login and pass and this is the moment when code from http://xxx/autoit/main_program.au3 will be downloaded and executed Finally main program will be appear This is the similiar way like new games are protected by cracking.
      I have few questions in this moment about this:
      Is something like that even possible to do with the autoit? First part of program (login gui) must have somewhere given that link to download the rest of code - http://xxx/autoit/main_program.au3 to make it execute. As we know this first part of program is easy able to hack and retrieve this web url http://xxx/autoit/main_program.au3 where located is main part of program. Is the way to encrypt or secure it? If only code will be stored in .php we know it cannot be previewed. So it could for example get code from .php file instead of .au3 I know that methods works in other languages (I dont know exactly how) thats becouse I only speculates, maybe something may looks different in these solution? Other way would be compiling second part of code on web server (there are available web autoit servers) maybe this way is possible? Tell me anything U know about this ideas and if its even possible to achieve.
      Thanks for ur any response, advice or thoughts