Jump to content
Valnurat

Several small issues

Recommended Posts

Valnurat

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
Valnurat

Anyone who could help?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
orbs
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
Valnurat

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
orbs
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
Valnurat

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
orbs
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
Valnurat

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
orbs

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
orbs
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
Valnurat
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
Valnurat

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
orbs

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
Valnurat

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

    • DynamicRookie
      By DynamicRookie
      Hey there!
       
      Is there a way to detect movement only for 1 specific window?

      HWnd is not really working, it still detects movement in all the windows within the region

      This is my script:
       
      ;Checksum actual HotKeySet("{f2}", 'exit_') MsgBox(0, '', '0') Beep(500, 2000) $Hwnd = WinActive('') while 1 $Checksum = PixelChecksum(211, 650, 1094, 914, 1, $Hwnd) If PixelChecksum(211, 650, 1094, 914, 1, $Hwnd) <> $Checksum Then For $i = 1 To 100 Beep(1000, 50) Next MsgBox(0, '', 'New message!', 1) EndIf WEnd Func exit_() Beep(500, 1000) Exit 0 EndFunc I just want to check whenever a message comes because the app i use doesn't give notifications properly.

      Any help is really appreciated!
    • PramodR
      By PramodR
      Can you please see whats wrong im doing in the below code? i can read few registry entry but not all for eg, i am able to get value of "Shell" Key from the registry path  but not AutoAdminLogon which has the value of "1", is there any change i have to do to read numeric values?
       Global  $shello = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Shell" )
       ConsoleWrite("This is Hello"& $shello)
      above command returns proper value , but same command with AutoAdminLogon returns null as shown in below ? infact registry has the value of 1.
       Global  $shello = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","AutoAdminLogon" )
       ConsoleWrite("This is Hello"& $shello)
    • Eminence
      By Eminence
      Hello,
      I've been searching on how to select the first row in my database which includes a time column based on the latest start_time date for today's date.
      This is my current code:
      Local $iCurrentDate = _Now() Local $sqlHandle = _dbOpen($sDbPath) Local $aResult, $iRows, $iCols _SQLite_GetTable2d($sqlHandle, "SELECT start_time FROM " & $srawDb & " ORDER BY datetime(start_time) DESC LIMIT 1", $aResult, $iRows, $iCols) _ArrayDisplay($aResult) _dbClose($sDbpath) What it does is it gets the first row entry in the database however it does not select the latest start_time entry in the database, it always select the first row. I've tried changing DESC to ASC to see if that will do it but the issue still remains. Any thoughts on this? Thanks in advance.
       
      *EDIT
      The date format in the database is by MM/DD/YYYY HH:MM:SS.
    • Trisha
      By Trisha
      Hello,
      I Have clicked on save as option to save a file, while doing that I need to rename a file appending with sysdate. I have searched in google find the below one line of code:
      FileMove("C:\somefile.txt", "C:\somefile1.txt"), When I am trying to append with sysdate. It is not happening. Please help me out  with the small issue.
    • TrashBoat
      By TrashBoat
      hey i would like to know if its possible to take a string like this
      $string = "onethousandninehundredeightyfive" and convert it into:
      $string = "one thousand nine hundred eighty five" i have something going on here but its no use
      $string = "onethousandninehundredeightyfive" Global $array[9] = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] Global $array1[19] = ['onethousand', 'twothousand', 'threethousand', 'fourthousand', 'fivethousand', 'sixthousand', 'seventhousand', 'eightthousand', 'ninethousand','tenthousand','hundred', 'twohundred', 'threehundred', 'fourhundred', 'fivehundred', 'sixhundred', 'sevenhundred', 'eighthundred', 'ninehundred'] MsgBox(0, 0, AddSpaces($string)) Func AddSpaces($string) Local $finalStr $length = StringLen($string) For $x = 0 To $length Local $trim = StringTrimRight($string, $x) For $h = 0 To 18 If $trim = $array1[$h] Then $finalStr = $finalStr & " " & $trim $string = StringTrimLeft($string, $h) $length = StringLen($string) EndIf Next For $z = 0 To 8 If $trim = $array[$z] Then $finalStr = $finalStr & " " & $trim $string = StringTrimLeft($string, $z) $length = StringLen($string) EndIf Next Next Return $finalStr EndFunc ;==>AddSpaces  
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.