Sign in to follow this  
Followers 0
pintas

Proper inputbox clean on click, restore on exit

16 posts in this topic

I have some input boxes with different values, like this:

$Name = GUICtrlCreateInput("Client Name", 432, 176, 153, 21)
$Folder = GUICtrlCreateInput("Username", 432, 256, 153, 21)
$Pass = GUICtrlCreateInput("Pass", 432, 296, 153, 21)

I want the input boxes to clean when i click on them, but i want their original value restored when i click anywhere else and if the value is null, ofcourse.

Is there an easy way to do this or i need to specify that for each inputbox i click, to check if all the other input boxes are with null values and restore them to the original value?

I have a total of 18 input boxes and i want my script to be clean, if i try to do it the long way, i'll end up with 300 lines just for this effect.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have some input boxes with different values, like this:

$Name = GUICtrlCreateInput("Client Name", 432, 176, 153, 21)
$Folder = GUICtrlCreateInput("Username", 432, 256, 153, 21)
$Pass = GUICtrlCreateInput("Pass", 432, 296, 153, 21)

I want the input boxes to clean when i click on them, but i want their original value restored when i click anywhere else and if the value is null, ofcourse.

Is there an easy way to do this or i need to specify that for each inputbox i click, to check if all the other input boxes are with null values and restore them to the original value?

I have a total of 18 input boxes and i want my script to be clean, if i try to do it the long way, i'll end up with 300 lines just for this effect.

I coded a complete cue banner UDF in 2008, but never submitted it.

This example uses the _GUICtrlEdit_SetCueBanner() function from that UDF set.

You could also use the $EN_SETFOCUS and $EN_KILLFOCUS notifications

to manually set the input controls original text instead of using an automatic cue banner,

but this issue you have is what a cue banner was made for.

EDIT: undeclared vars

EDIT2: To anyone else who reads this, you can replace the cue banner function with this line below your edit/input control

GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, "Client Name")

_GUICtrlEdit_SetCueBanner() was coded before the change to unicode in version v3.3.0.0, so _WinAPI_MultiByteToWideChar() is now unnecessary.

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

Opt('MustDeclareVars', 1)

Global $Name, $Folder, $Pass
_EditFocus()

Func _EditFocus()
    ;A cue banner always appears when the edit is blank.
    ;Does not work for edit controls with $ES_MULTILINE style.
    ;In XP, the banner disappears when the edit has focus (cursor in edit)
    ;In Vista/7 the banner can optionally still appear when the edit has focus (cursor in edit)
    ;(third parameter = True/False)
    Local $nMsg
    GUICreate("Edit Focus", 400, 300)
    $Name = GUICtrlCreateInput("", 20, 20, 153, 21)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, "Client Name")
    ;_GUICtrlEdit_SetCueBanner(-1, "Client Name", True)
    $Folder = GUICtrlCreateInput("", 20, 50, 153, 21)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, "Username")
    ;_GUICtrlEdit_SetCueBanner(-1, "Username", True)
    $Pass = GUICtrlCreateInput("", 20, 80, 153, 21)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, True, "Pass")
    ;_GUICtrlEdit_SetCueBanner(-1, "Pass", True)
    GUICtrlCreateInput("", 20, 110, 153, 21)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUISetState()

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                Exit
        EndSwitch
    WEnd

EndFunc

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Switch $nID
        Case $Name, $Folder, $Pass ;these specific edit controls only
            Switch $nNotifyCode; Edit control event messages only
                Case $EN_SETFOCUS; Edit (Input) control has focus
                    ;Is this what you meant by 'I want the input boxes to clean when i click on them'?
                    ;GUICtrlSetData($nID, "") ;same as GUICtrlSendMsg($nID, $WM_SETTEXT, 0, "")
                    ;or
                    ;allow undo with Ctrl-Z by replacing selected text (saves previous text in the undo buffer)
                    GUICtrlSendMsg($nID, $EM_SETSEL, 0, -1);select all text in edit
                    GUICtrlSendMsg($nID, $EM_REPLACESEL, True, "")

                    ConsoleWrite(@CRLF & '+Current Edit ID = ' & $nID & @crlf); control ID of Input edit control with focus
                    ;ConsoleWrite('+Control hWnd    = ' & $lParam & @crlf); handle of Input edit control with focus
                    ;ConsoleWrite('+ControlGetFocus = ' & ControlGetFocus($hWnd) & @crlf); the ClassNameNN of control 'Edit#'
                Case $EN_KILLFOCUS; Edit (Input) control lost focus
                    ;use to reset text once edit controls no longer have focus
                    ConsoleWrite(@CRLF & '-Previous Edit ID = ' & $nID); control ID of previous Input edit control with focus
                    ;ConsoleWrite('+ControlGetFocus = ' & ControlGetFocus($hWnd) & @crlf); the ClassNameNN of control 'Edit#'
            EndSwitch
    EndSwitch




    Return $GUI_RUNDEFMSG
EndFunc


; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlEdit_SetCueBanner
; Description ...: Sets the cue banner text that is displayed for single line edit controls
; Syntax.........: _GUICtrlEdit_SetCueBanner($hWnd, $sText, $wParam = False, $iCodePage = 0, $iFlags = 0)
; Parameters ....: $hWnd        - Handle to control
;                  $sText       - String that contains the text
;                  $wParam      - False: (Default) Cue banner disappears when control selected.
;                               - True: Display cue banner even when the edit control is selected.*
;                  $iCodePage   - (Optional) See _WinAPI_MultiByteToWideChar()
;                  $iFlags      - (Optional) See _WinAPI_MultiByteToWideChar()
; Return values .: Success      - True
;                  Failure      - False
; Author ........: rover 2k8
; Modified.......:
; Remarks .......: The cue banner is text that is displayed in an edit control when there is no selection.
;                  You cannot set a cue banner on a multiline edit control or on a rich edit control.
;                  There is a problem with cue banners and Asian language support in XP, this issue has been fixed in Vista.
;                  * wParam TRUE - Vista only. (In XP cue text always disappears when the control gets focus).
;                  EM_SETCUEBANNER vs. international support in XP and Server 2003
;                  https://blogs.msdn.com/michkap/archive/2006/02/25/538735.aspx
;                  EM_SETCUEBANNER Message, wParam TRUE - not working for XP.
;                  http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2799112&SiteID=1
;+
;                  Minimum Operating Systems: Windows XP
; Related .......: _GUICtrlEdit_GetCueBanner
; Link ..........; @@MsdnLink@@ EM_SETCUEBANNER Message
; Example .......; Yes
; ===============================================================================================================================
Func _GUICtrlEdit_SetCueBanner($hWnd, $sText, $wParam = False, $iCodePage = 0, $iFlags = 0)
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    If _WinAPI_GetClassName($hWnd) <> "Edit" Then Return False
    Local $iResult, $struct_String, $sBuffer_pointer
;~  Local $pMemory, $struct_MemMap

    $struct_String = _WinAPI_MultiByteToWideChar($sText, $iCodePage, $iFlags)
    $sBuffer_pointer = DllStructGetPtr($struct_String)

;~  If _WinAPI_InProcess($hWnd, $_ghEditLastWnd) Then
        $iResult = _SendMessage($hWnd, $EM_SETCUEBANNER, $wParam, $sBuffer_pointer)
;~  Else
;~      $pMemory = _MemInit($hWnd, (StringLen($sText) + 1), $struct_MemMap)
;~      _MemWrite($struct_MemMap, $sBuffer_pointer)
;~      $iResult = _SendMessage($hWnd, $EM_SETCUEBANNER, $wParam, $pMemory)
;~      _MemFree($struct_MemMap)
;~  EndIf
    Return $iResult <> 0
EndFunc   ;==>_GUICtrlEdit_SetCueBanner
Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

That sure puts me on the right track. Thanks man!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here is one from the main loop :huh2:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $aCursorInfo
$Form1 = GUICreate("Clear Inputs", 170, 135, -1, -1)
$Input1 = GUICtrlCreateInput("Default 1", 24, 32, 121, 21)
$Input2 = GUICtrlCreateInput("Default 2", 24, 64, 121, 21)
GUISetState(@SW_SHOW)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    $aInfo = GUIGetCursorInfo($Form1)
    If $aInfo[2] Then
        If $aInfo[4] = $Input1 Then
            GUICtrlSetData($Input1, "")
        Else
            If Not $aInfo[4] = $Input1 Then
                GUICtrlSetData($Input1, "Default 1")
            EndIf
            If $aInfo[4] = $Input2 Then
                GUICtrlSetData($Input2, "")
            Else
                If Not $aInfo[4] = $Input2 Then
                    GUICtrlSetData($Input2, "Default 2")
                EndIf
            EndIf
        EndIf
    EndIf

WEnd

P.S nice UDF rover! Thank you!

Edited by Newbercase

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here my version:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
$hGUI = GUICreate("Test", 640, 480)

Global $aDefault_Text[3] = ["Client Name", "Username", "Pass"]
$Name = GUICtrlCreateInput($aDefault_Text[0], 432, 176, 153, 21)
$Folder = GUICtrlCreateInput($aDefault_Text[1], 432, 256, 153, 21)
$Pass = GUICtrlCreateInput($aDefault_Text[2], 432, 296, 153, 21)
$button = GUICtrlCreateButton("Exit", 432, 420, 30, 30)
GUISetState()
ControlFocus($hGUI, "", $button)

GUIRegisterMsg($WM_Command, 'WM_Check')

Do
    $msg = GUIGetMsg()
Until $msg = -3 Or $msg = $button


Func WM_Check($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iCode
    Local Static $iIDFrom, $sOld
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $iCode
        Case $EN_SETFOCUS
            $iIDFrom = _WinAPI_LoWord($iwParam)
            $sOld = GUICtrlRead($iIDFrom)
            If GUICtrlRead($iIDFrom) = $aDefault_Text[$iIDFrom - 3] Then GUICtrlSetData($iIDFrom, "")
        Case $EN_KILLFOCUS
            If GUICtrlRead($iIDFrom) = "" Then GUICtrlSetData($iIDFrom, $sOld)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

You guys are great!

All the examples are very nice, but i'd just like to point out that when you write something in a box, and you click it again, it's being cleared again. I just think it works better if it keeps the previous value and maybe highlights it. I'll play around with these examples, and keep you posted.

Thanks!

Share this post


Link to post
Share on other sites

I updated my code. You mean something like this?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Yep! You sure are faster than me :huh2:

Well done UEZ!

Share this post


Link to post
Share on other sites

What i'm i missing here? Is it because i'm using tabs? It keeps crashing. :S

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $aDefault_Text[18] = ["Nome de Empresa / Cliente", "Nome de Usuário (Laudo)", "Senha (Laudo)", "Email", "Telefone", "Nome de Contato", "Função / Área", "Endereço (Rua, Nº, Bairro, Cidade, Estado)", "Introduza Nova Senha", "Nome de Usuário", "Senha", "Email", "Telefone", "Nome de Contato", "Função / Área", "Nome de Usuário", "Senha", "Introduza Nova Senha"]

$Form1 = GUICreate("", 789, 613, 416, 151)

$TABS = GUICtrlCreateTab(0, 104, 785, 465)
$LaudosDadosClientes = GUICtrlCreateTabItem("Laudos / Dados Cliente")

$GrupoNovoCliente = GUICtrlCreateGroup("", 416, 144, 353, 241)
$NomeCliente = GUICtrlCreateInput($aDefault_Text[0], 432, 176, 153, 21)
$NomeUsuario = GUICtrlCreateInput($aDefault_Text[1], 432, 256, 153, 21)
$SenhaLaudo = GUICtrlCreateInput($aDefault_Text[2], 432, 296, 153, 21)
$Email = GUICtrlCreateInput($aDefault_Text[3], 432, 336, 153, 21)
$Telefone = GUICtrlCreateInput($aDefault_Text[4], 600, 296, 153, 21)
$NomeContato = GUICtrlCreateInput($aDefault_Text[5], 600, 176, 153, 21)
$FuncaoArea = GUICtrlCreateInput($aDefault_Text[6], 600, 256, 153, 21)
$EnderecoNovoCliente = GUICtrlCreateInput($aDefault_Text[7], 432, 216, 321, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Admin = GUICtrlCreateTabItem("Admin")

$GrupoSenhaClientes = GUICtrlCreateGroup("", 384, 208, 185, 121)

$SenhaClientesAdmin = GUICtrlCreateInput($aDefault_Text[8], 400, 264, 153, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$GrupoNovoLoginClienteAdmin = GUICtrlCreateGroup("", 16, 144, 353, 185)
$NovoUsuarioAdmin = GUICtrlCreateInput($aDefault_Text[9], 32, 232, 153, 21)
$NovoSenhaAdmin = GUICtrlCreateInput($aDefault_Text[10], 32, 264, 153, 21)
$NovoEmailAdmin = GUICtrlCreateInput($aDefault_Text[11], 200, 168, 153, 21)
$NovoTelefoneAdmin = GUICtrlCreateInput($aDefault_Text[12], 200, 200, 153, 21)
$NovoContatoAdmin = GUICtrlCreateInput($aDefault_Text[13], 200, 232, 153, 21)
$NovoFuncaoAdmin = GUICtrlCreateInput($aDefault_Text[14], 200, 264, 153, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$GroupoNovoUsuarioWellen = GUICtrlCreateGroup("", 16, 344, 161, 217)
$NovoUsuarioWellen = GUICtrlCreateInput($aDefault_Text[15], 32, 368, 129, 21)
$SenhaNovoUsuarioWellen = GUICtrlCreateInput($aDefault_Text[16], 32, 400, 129, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$GroupoSenhaUsuarioWellen = GUICtrlCreateGroup("", 384, 344, 185, 121)
$NovaSenhaUsuario = GUICtrlCreateInput($aDefault_Text[17], 400, 400, 153, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_Command, 'WM_Check')

Do
    $msg = GUIGetMsg()
Until $msg = -3

Func WM_Check($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iCode
    Local Static $iIDFrom, $sOld
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $iCode
        Case $EN_SETFOCUS
            $iIDFrom = _WinAPI_LoWord($iwParam)
            $sOld = GUICtrlRead($iIDFrom)
            If GUICtrlRead($iIDFrom) = $aDefault_Text[$iIDFrom - 18] Then GUICtrlSetData($iIDFrom, "")
        Case $EN_KILLFOCUS
            If GUICtrlRead($iIDFrom) = "" Then GUICtrlSetData($iIDFrom, $sOld)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Share this post


Link to post
Share on other sites

The problem is that the ID numbers are not continuously increasing.

My idea was to map to the id number the default text. Maybe there is a better way but this was my 1st idea.

#include <ButtonConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $aDefault_Text[18] = ["Nome de Empresa / Cliente", "Nome de Usuário (Laudo)", "Senha (Laudo)", "Email", "Telefone", "Nome de Contato", "Função / Área", "Endereço (Rua, Nº, Bairro, Cidade, Estado)", "Introduza Nova Senha", "Nome de Usuário", "Senha", "Email", "Telefone", "Nome de Contato", "Função / Área", "Nome de Usuário", "Senha", "Introduza Nova Senha"]
$Form1 = GUICreate("", 789, 613)

$TABS = GUICtrlCreateTab(0, 104, 785, 465)
$LaudosDadosClientes = GUICtrlCreateTabItem("Laudos / Dados Cliente")

$GrupoNovoCliente = GUICtrlCreateGroup("", 416, 144, 353, 241)
$NomeCliente = GUICtrlCreateInput($aDefault_Text[0], 432, 176, 153, 21)
$NomeUsuario = GUICtrlCreateInput($aDefault_Text[1], 432, 256, 153, 21)
$SenhaLaudo = GUICtrlCreateInput($aDefault_Text[2], 432, 296, 153, 21)
$Email = GUICtrlCreateInput($aDefault_Text[3], 432, 336, 153, 21)
$Telefone = GUICtrlCreateInput($aDefault_Text[4], 600, 296, 153, 21)
$NomeContato = GUICtrlCreateInput($aDefault_Text[5], 600, 176, 153, 21)
$FuncaoArea = GUICtrlCreateInput($aDefault_Text[6], 600, 256, 153, 21)
$EnderecoNovoCliente = GUICtrlCreateInput($aDefault_Text[7], 432, 216, 321, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Admin = GUICtrlCreateTabItem("Admin")

$GrupoSenhaClientes = GUICtrlCreateGroup("", 384, 208, 185, 121)

$SenhaClientesAdmin = GUICtrlCreateInput($aDefault_Text[8], 400, 264, 153, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$GrupoNovoLoginClienteAdmin = GUICtrlCreateGroup("", 16, 144, 353, 185)
$NovoUsuarioAdmin = GUICtrlCreateInput($aDefault_Text[9], 32, 232, 153, 21)
$NovoSenhaAdmin = GUICtrlCreateInput($aDefault_Text[10], 32, 264, 153, 21)
$NovoEmailAdmin = GUICtrlCreateInput($aDefault_Text[11], 200, 168, 153, 21)
$NovoTelefoneAdmin = GUICtrlCreateInput($aDefault_Text[12], 200, 200, 153, 21)
$NovoContatoAdmin = GUICtrlCreateInput($aDefault_Text[13], 200, 232, 153, 21)
$NovoFuncaoAdmin = GUICtrlCreateInput($aDefault_Text[14], 200, 264, 153, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$GroupoNovoUsuarioWellen = GUICtrlCreateGroup("", 16, 344, 161, 217)
$NovoUsuarioWellen = GUICtrlCreateInput($aDefault_Text[15], 32, 368, 129, 21)
$SenhaNovoUsuarioWellen = GUICtrlCreateInput($aDefault_Text[16], 32, 400, 129, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$GroupoSenhaUsuarioWellen = GUICtrlCreateGroup("", 384, 344, 185, 121)
$NovaSenhaUsuario = GUICtrlCreateInput($aDefault_Text[17], 400, 400, 153, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

Global $aInputID[100]
$j = 0
For $i = 0 To UBound($aInputID) - 1 ;map default text to IDs
    If __myCtrlGetClass($i) = "Input" Then
        $aInputID[$i] = $aDefault_Text[$j]
        $j += 1
    EndIf
Next

GUIRegisterMsg($WM_Command, 'WM_Check')

Do
    $msg = GUIGetMsg()
Until $msg = -3

Func WM_Check($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iCode
    Local Static $iIDFrom, $sOld
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $iCode
        Case $EN_SETFOCUS
            $iIDFrom = _WinAPI_LoWord($iwParam)
            $sOld = GUICtrlRead($iIDFrom)
            If GUICtrlRead($iIDFrom) = $aInputID[$iIDFrom] Then GUICtrlSetData($iIDFrom, "")
        Case $EN_KILLFOCUS
            If GUICtrlRead($iIDFrom) = "" Then GUICtrlSetData($iIDFrom, $sOld)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func __myCtrlGetClass($hHandle) ;code by SmOke_N, modified by Guiness
    Local Const $GWL_STYLE = -16
    Local $iLong, $sClass
    If IsHWnd($hHandle) = 0 Then
        $hHandle = GUICtrlGetHandle($hHandle)
        If IsHWnd($hHandle) = 0 Then
            Return SetError(1, 0, "Unknown")
        EndIf
    EndIf

    $sClass = _WinAPI_GetClassName($hHandle)
    If @error Then
        Return "Unknown"
    EndIf

    $iLong = _WinAPI_GetWindowLong($hHandle, $GWL_STYLE)
    If @error Then
        Return SetError(2, 0, 0)
    EndIf

    Switch $sClass
        Case "Button"
            Select
                Case BitAND($iLong, $BS_GROUPBOX) = $BS_GROUPBOX
                    Return "Group"
                Case BitAND($iLong, $BS_CHECKBOX) = $BS_CHECKBOX
                    Return "Checkbox"
                Case BitAND($iLong, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX
                    Return "Checkbox"
                Case BitAND($iLong, $BS_RADIOBUTTON) = $BS_RADIOBUTTON
                    Return "Radio"
                Case BitAND($iLong, $BS_AUTORADIOBUTTON) = $BS_AUTORADIOBUTTON
                    Return "Radio"
            EndSelect

        Case "Edit"
            Select
                Case BitAND($iLong, $ES_WANTRETURN) = $ES_WANTRETURN
                    Return "Edit"
                Case Else
                    Return "Input"
            EndSelect

        Case "Static"
            Select
                Case BitAND($iLong, $SS_BITMAP) = $SS_BITMAP
                    Return "Pic"
                Case BitAND($iLong, $SS_ICON) = $SS_ICON
                    Return "Icon"
                Case BitAND($iLong, $SS_LEFT) = $SS_LEFT
                    If BitAND($iLong, $SS_NOTIFY) = $SS_NOTIFY Then
                        Return "Label"
                    EndIf
                    Return "Graphic"
            EndSelect

        Case "ComboBox"
            Return "Combo"
        Case "ListBox"
            Return "List"
        Case "msctls_progress32"
            Return "Progress"
        Case "msctls_trackbar32"
            Return "Slider"
        Case "SysDateTimePick32"
            Return "Date"
        Case "SysListView32"
            Return "ListView"
        Case "SysMonthCal32"
            Return "MonthCal"
        Case "SysTabControl32"
            Return "Tab"
        Case "SysTreeView32"
            Return "TreeView"

    EndSwitch
    Return $sClass
EndFunc

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

WOW! You really have gone through a great deal to help me out. I apreciate it.

I just have one question.

I should ID all the controls i have in that GUI, like combo boxes, radio buttons, etc, right?

Because i just tried adding the rest of the GUI elements and it crashes.

Share this post


Link to post
Share on other sites

If you have more inputboxes it will fail because the amount of default textes and inputbox ids are equal which $aInputID[] reflects.

The best is show the whole gui to see what's wrong.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Here it is. Thanks for your patience.

Please don't pay attention if the script looks too lame :huh2:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include<File.au3>
#include <String.au3>
#include <Word.au3>
#include <GUIComboBox.au3>
#include <WinAPI.au3>

Global $aClients, $aPasswords, $sComboValue, $aFilter, $arquivo, $FileList, $WellenPath, $aDefault_Text[18] = ["Nome de Empresa / Cliente", "Nome de Usuário (Laudo)", "Senha (Laudo)", "Email", "Telefone", "Nome de Contato", "Função / Área", "Endereço (Rua, Nº, Bairro, Cidade, Estado)", "Introduza Nova Senha", "Nome de Usuário", "Senha", "Email", "Telefone", "Nome de Contato", "Função / Área", "Nome de Usuário", "Senha", "Introduza Nova Senha"]

ReadData()
$WellenPath = 'D:\WELLEN\LAUDOS\'
#Region ### START Koda GUI section ### Form=C:\Users\Admin\Desktop\Wellen Data Bank\Wellen DB GUI.kxf
$Form1 = GUICreate("Wellen Data Bank", 789, 613, 416, 151)
$MenuItem1 = GUICtrlCreateMenu("&Programa")
$TrocarUsuario = GUICtrlCreateMenuItem("Trocar Usuário"&@TAB&"F2", $MenuItem1)
$Sair = GUICtrlCreateMenuItem("Sair", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Ajuda")
$TABS = GUICtrlCreateTab(0, 104, 785, 465)
$LaudosDadosClientes = GUICtrlCreateTabItem("Laudos / Dados Cliente")
$GrupoListaClientes1 = GUICtrlCreateGroup("Lista de Clientes", 16, 144, 185, 65)
$AbrirListaContato = GUICtrlCreateButton("Abrir Lista de Contatos", 32, 168, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoCriacaoLaudo = GUICtrlCreateGroup("Criação de Laudo", 16, 216, 185, 169)
$NumeroLaudo = GUICtrlCreateLabel("Número de Laudo:", 32, 240, 92, 17)
$AbrirModelo = GUICtrlCreateButton("Abrir Modelo", 32, 344, 155, 25)
$Cliente = GUICtrlCreateCombo("Cliente", 32, 272, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $sComboValue, "")
$Servico = GUICtrlCreateCombo("Serviço", 32, 312, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Ultrassom|Partículas Magnéticas|Liquido Penetrante|Laudo Misto","")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoGraficos = GUICtrlCreateGroup("Gráficos", 16, 400, 185, 153)
$Criar3DSketchup = GUICtrlCreateButton("Criar 3D Sketchup", 32, 496, 155, 25)
$BuscarImagensUS = GUICtrlCreateButton("Buscar Imagens US", 32, 440, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoNovoCliente = GUICtrlCreateGroup("Novo Cliente", 416, 144, 353, 241)
$NomeCliente = GUICtrlCreateInput($aDefault_Text[0], 432, 176, 153, 21)
$NomeUsuario = GUICtrlCreateInput($aDefault_Text[1], 432, 256, 153, 21)
$SenhaLaudo = GUICtrlCreateInput($aDefault_Text[2], 432, 296, 153, 21)
$Email = GUICtrlCreateInput($aDefault_Text[3], 432, 336, 153, 21)
$Telefone = GUICtrlCreateInput($aDefault_Text[4], 600, 296, 153, 21)
$CriarCliente = GUICtrlCreateButton("Criar Cliente", 600, 336, 75, 25)
$LimparInputNovoCliente = GUICtrlCreateButton("Limpar Tudo", 680, 336, 75, 25)
$NomeContato = GUICtrlCreateInput($aDefault_Text[5], 600, 176, 153, 21)
$FuncaoArea = GUICtrlCreateInput($aDefault_Text[6], 600, 256, 153, 21)
$EnderecoNovoCliente = GUICtrlCreateInput($aDefault_Text[7], 432, 216, 321, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoEnviarArquivoCliente = GUICtrlCreateGroup("Envio Arquivo Para Cliente", 216, 400, 553, 153)
$BuscarArquivoCaption = GUICtrlCreateLabel("Arquivo:", 264, 424, 43, 17)
$CaminhoArquivo = GUICtrlCreateInput("", 264, 448, 289, 21)
$BuscarArquivo = GUICtrlCreateButton("Buscar Arquivo", 568, 448, 155, 25)
$ListaClientes = GUICtrlCreateLabel("Cliente:", 264, 480, 39, 17)
$Cliente2 = GUICtrlCreateCombo("Cliente", 264, 504, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $sComboValue, "")
$Enviar = GUICtrlCreateButton("Enviar Arquivo", 568, 504, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoAbrirEditarLaudo = GUICtrlCreateGroup("Abrir/Editar Laudo", 216, 144, 185, 241)
$Cliente1 = GUICtrlCreateCombo("Cliente", 232, 184, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $sComboValue, "")
$AnoEmissao = GUICtrlCreateCombo("Ano de Emissão", 232, 232, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Número de Laudo", 232, 280, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$AbrirLaudo = GUICtrlCreateButton("Abrir Laudo", 256, 336, 107, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Financeiro = GUICtrlCreateTabItem("Financeiro")
$GrupoNotaFiscal = GUICtrlCreateGroup("Nota Fiscal", 16, 144, 753, 193)
$Label1 = GUICtrlCreateLabel("Abrir Proposta Comercial", 112, 200, 119, 17)
$Label2 = GUICtrlCreateLabel("Abrir Apropriação de Horas", 368, 216, 131, 17)
$Label3 = GUICtrlCreateLabel("Abrir Nota Fiscal", 112, 264, 81, 17)
$Label5 = GUICtrlCreateLabel("Criar Proposta Comercial", 272, 248, 119, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoOrcamento = GUICtrlCreateGroup("Proposta Comercial / Orçamento", 16, 344, 753, 209)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Admin = GUICtrlCreateTabItem("Admin")
$GrupoSenhaClientes = GUICtrlCreateGroup("Alterar Senha de Clientes", 384, 208, 185, 121)
$ClienteAdmin2 = GUICtrlCreateCombo("Cliente", 400, 232, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, _ArrayToString($aClients))
$SenhaClientesAdmin = GUICtrlCreateInput($aDefault_Text[8], 400, 264, 153, 21)
$AlterarSenhaCliente = GUICtrlCreateButton("Alterar", 440, 296, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoNovoLoginClienteAdmin = GUICtrlCreateGroup("Novo Login de Cliente", 16, 144, 353, 185)
$ClienteAdmin = GUICtrlCreateCombo("Cliente", 32, 168, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, _ArrayToString($aClients))
$NovoUsuarioAdmin = GUICtrlCreateInput($aDefault_Text[9], 32, 232, 153, 21)
$NovoSenhaAdmin = GUICtrlCreateInput($aDefault_Text[10], 32, 264, 153, 21)
$NovoEmailAdmin = GUICtrlCreateInput($aDefault_Text[11], 200, 168, 153, 21)
$NovoTelefoneAdmin = GUICtrlCreateInput($aDefault_Text[12], 200, 200, 153, 21)
$NovoContatoAdmin = GUICtrlCreateInput($aDefault_Text[13], 200, 232, 153, 21)
$NovoFuncaoAdmin = GUICtrlCreateInput($aDefault_Text[14], 200, 264, 153, 21)
$CriarLoginAdmin = GUICtrlCreateButton("Criar Login", 152, 296, 75, 25)
$TipoLogin = GUICtrlCreateCombo("Escolha Tipo", 32, 200, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoNovoUsuarioWellen = GUICtrlCreateGroup("Criar Usuário Wellen DB", 16, 344, 161, 217)
$NovoUsuarioWellen = GUICtrlCreateInput($aDefault_Text[15], 32, 368, 129, 21)
$SenhaNovoUsuarioWellen = GUICtrlCreateInput($aDefault_Text[16], 32, 400, 129, 21)
$PermissaoUsuarioCaption = GUICtrlCreateLabel("Permissões de Usuário:", 32, 432, 114, 17)
$PermissaoInspetor = GUICtrlCreateRadio("Inspetor / Control Téc.", 32, 456, 129, 17)
$PermissaoFinanceiro = GUICtrlCreateRadio("Financeiro", 32, 480, 113, 17)
$PermissaoAdministrador = GUICtrlCreateRadio("Administrador", 32, 504, 113, 17)
GUICtrlSetState($PermissaoInspetor, $GUI_CHECKED)
$CriarUsuarioWellen = GUICtrlCreateButton("Criar Usuário", 56, 528, 83, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoGestaoOnline = GUICtrlCreateGroup("Gestão Clientes Online", 384, 144, 185, 57)
$AbrirGestaoOnline = GUICtrlCreateButton("Abrir Gestão Online", 416, 168, 123, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoSenhaUsuarioWellen = GUICtrlCreateGroup("Senha Usuário Wellen DB", 384, 344, 185, 121)
$SelecioneUsuarioSenha = GUICtrlCreateCombo("Selecione Usuário", 400, 368, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$NovaSenhaUsuario = GUICtrlCreateInput($aDefault_Text[17], 400, 400, 153, 21)
$AlterarSenhaUsuario = GUICtrlCreateButton("Alterar", 440, 432, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoPermissoesUsuarioWellen = GUICtrlCreateGroup("Alterar Permissões Usuário", 192, 344, 177, 217)
$SelecioneUsuarioPermissoes = GUICtrlCreateCombo("Selecione Usuário", 208, 368, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$PermissaoUsuarioCaption2 = GUICtrlCreateLabel("Permissões de Usuário:", 208, 400, 114, 17)
$PermissaoInspetor2 = GUICtrlCreateRadio("Inspetor / Control Téc.", 208, 424, 129, 17)
$PermissaoFinanceiro2 = GUICtrlCreateRadio("Financeiro", 208, 448, 113, 17)
$PermissaoAdministrador2 = GUICtrlCreateRadio("Administrador", 208, 472, 113, 17)
GUICtrlSetState($PermissaoInspetor2, $GUI_CHECKED)
$AlterarPermissaoUsuario = GUICtrlCreateButton("Alterar", 240, 528, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoRemoverUsuarioWellen = GUICtrlCreateGroup("Remover Usuário Wellen DB", 384, 472, 185, 89)
$SelecioneUsuarioRemover = GUICtrlCreateCombo("Selecione Usuário", 400, 496, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$RemoverUsuarioWellen = GUICtrlCreateButton("Remover", 440, 528, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoEnvioDocsAdmin = GUICtrlCreateGroup("Envio de Documentos", 584, 136, 185, 273)
$CaminhoArquivoAdmin = GUICtrlCreateInput("", 600, 184, 153, 21)
$EnvioArquivoAdmin = GUICtrlCreateLabel("Arquivo:", 600, 160, 43, 17)
$BuscarArquivoAdmin = GUICtrlCreateButton("Buscar Arquivo", 632, 208, 91, 25)
$DestinatarioArquivoAdmin = GUICtrlCreateLabel("Destinatário:", 600, 248, 63, 17)
$EnvioTodosClientesLaudos = GUICtrlCreateRadio("Todos Clientes (Laudos)", 600, 272, 145, 17)
$EnvioTodosClientesOrcamentos = GUICtrlCreateRadio("Todos Clientes (Orçamentos)", 600, 296, 153, 17)
$EnvioTodosClientesNotasFiscais = GUICtrlCreateRadio("Todos Clientes (Notas Fiscais)", 600, 320, 161, 17)
$EnvioTodosClientes = GUICtrlCreateRadio("Todos Clientes/Usuários", 600, 344, 153, 17)
GUICtrlSetState($EnvioTodosClientesLaudos, $GUI_CHECKED)
$EnviarAdmin = GUICtrlCreateButton("Enviar", 640, 376, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoControleFinanceiro = GUICtrlCreateGroup("Controle Financeiro", 584, 424, 185, 137)
$CompararNotasFiscais = GUICtrlCreateButton("Comparar Notas Fiscais", 600, 456, 155, 25)
$CompararApropHoras = GUICtrlCreateButton("Comparar Aprop. de Horas", 600, 488, 155, 25)
$CompararHorasNotasFisc = GUICtrlCreateButton("Comparar Horas/Notas Fisc.", 600, 520, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
$Banner = GUICtrlCreatePic("C:\Users\Admin\Desktop\Wellen Data Bank\bannerwellen.jpg", 0, 0, 786, 104)
$StatusBar = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetSimple($StatusBar)
_GUICtrlStatusBar_SetText($StatusBar, "Usuário:")
Dim $Form1_AccelTable[1][2] = [["{F2}", $TrocarUsuario]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $aInputID[100]
$j = 0
For $i = 0 To UBound($aInputID) - 1 ;map default text to IDs
    If __myCtrlGetClass($i) = "Input" Then
        $aInputID[$i] = $aDefault_Text[$j]
        $j += 1
    EndIf
Next

GUIRegisterMsg($WM_Command, 'WM_Check')

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $AlterarSenhaCliente
            If GUICtrlRead($ClienteAdmin2) = 'Cliente' Then
                MsgBox(4096+48, "", 'É necessário escolher um cliente')
            Else
                ; Now search the client array for the value in the combo
                $iIndex = _ArraySearch($aClients, GUICtrlRead($ClienteAdmin2))
                ; And display the corresponding element in the password array
                ReadData()
                _ReplaceStringInFile ( 'configuration.php', '"'&GUICtrlRead($ClienteAdmin2)&'", "password" => "'&$aPasswords[$iIndex]&'"', '"'&GUICtrlRead($ClienteAdmin2)&'", "password" => "'&GUICtrlRead($SenhaClientesAdmin)&'"')
                Sleep(100)
                ReadData()
            If GUICtrlRead($SenhaClientesAdmin)=$aPasswords[$iIndex] Then
                MsgBox(4096+64, "Alteração de Senha", "Senha alterada com sucesso!")
            Else
                MsgBox(4096+48, "Alteração de Senha", "Senha não alterada!")
                EndIf
            EndIf
        Case $AbrirModelo
            If GUICtrlRead($Cliente) = 'Cliente' Then
                MsgBox(4096+48, "", 'É necessário escolher um cliente')
            ElseIf GUICtrlRead($Servico) = 'Serviço' Then
                MsgBox(4096+48, "", 'É necessário escolher um serviço')
            Else
                MsgBox(4160, "box", GUICtrlRead($Cliente))
                MsgBox(4160, "box", GUICtrlRead($Servico))
            EndIf
        Case $BuscarArquivo
            $arquivo = FileOpenDialog("Escolha um arquivo para enviar", @DocumentsCommonDir & "\", "Todos Arquivos (*.*)", 1 + 4 )
            $arquivo = StringReplace($arquivo, "|", @CRLF)
            GUICtrlSetData($CaminhoArquivo, $arquivo)
        Case $Enviar
            If GUICtrlRead($CaminhoArquivo) = '' Then
                MsgBox(4096+48, "", 'É necessário escolher um arquivo para enviar')
            ElseIf GUICtrlRead($Cliente2) = 'Cliente' Then
                MsgBox(4096+48, "", 'É necessário escolher um cliente')
            Else
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivo))
                MsgBox(4160, "box", GUICtrlRead($Cliente2))
            EndIf
        Case $BuscarArquivoAdmin
            $arquivo = FileOpenDialog("Escolha um arquivo para enviar", @DocumentsCommonDir & "\", "Todos Arquivos (*.*)", 1 + 4 )
            $arquivo = StringReplace($arquivo, "|", @CRLF)
            GUICtrlSetData($CaminhoArquivoAdmin, $arquivo)
        Case $EnviarAdmin
            If GUICtrlRead($CaminhoArquivoAdmin) = '' Then
                MsgBox(4096+48, "", 'É necessário escolher um arquivo para enviar')
            Else
            If GUICtrlRead($EnvioTodosClientesLaudos) = $GUI_CHECKED Then
                MsgBox(4160, "O arquivo será enviado para:", "Todos os clientes (Laudos)")
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivoAdmin))
            ElseIf GUICtrlRead($EnvioTodosClientesOrcamentos) = $GUI_CHECKED Then
                MsgBox(4160, "O arquivo será enviado para:", "Todos os clientes (Orçamentos)")
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivoAdmin))
            ElseIf GUICtrlRead($EnvioTodosClientesNotasFiscais) = $GUI_CHECKED Then
                MsgBox(4160, "O arquivo será enviado para:", "Todos os clientes (Notas Fiscais)")
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivoAdmin))
            ElseIf GUICtrlRead($EnvioTodosClientes) = $GUI_CHECKED Then
                MsgBox(4160, "O arquivo será enviado para:", "Todos os clientes (Usuários)")
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivoAdmin))
            EndIf
            EndIf
        Case $Cliente1
            _GUICtrlComboBox_Destroy($NumeroLaudoGrupoAbrir)
            $NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Número de Laudo", 232, 280, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
            GUICtrlSetState(-1, $GUI_ENABLE)
            _GUICtrlComboBox_Destroy($AnoEmissao)
            $AnoEmissao = GUICtrlCreateCombo("Ano de Emissão", 232, 232, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
            GUICtrlSetState(-1, $GUI_ENABLE)
            If GUICtrlRead($Cliente1) = 'Cliente' Then
                _GUICtrlComboBox_Destroy($NumeroLaudoGrupoAbrir)
                $NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Número de Laudo", 232, 280, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
                GUICtrlSetState(-1, $GUI_ENABLE)
            Else
                $FileYearList=_FileListToArray($WellenPath&GUICtrlRead($Cliente1)&'\','*',2)
                GUICtrlSetData($AnoEmissao, _ArrayToString($FileYearList,"|",1))
            EndIf
        Case $AnoEmissao
            If GUICtrlRead($AnoEmissao) = 'Ano de Emissão' Then
                _GUICtrlComboBox_Destroy($NumeroLaudoGrupoAbrir)
                $NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Número de Laudo", 232, 280, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
                GUICtrlSetState(-1, $GUI_ENABLE)
            Else
                $FileList =_FileListToArray($WellenPath&GUICtrlRead($Cliente1)&'\'&GUICtrlRead($AnoEmissao)&'\','*.docx',1)
                _ArrayTrim($FileList, 5, 1)
                GUICtrlSetData($NumeroLaudoGrupoAbrir, _ArrayToString($FileList,"|",1))
            EndIf
        Case $AbrirLaudo
            If GUICtrlRead($Cliente1) = 'Cliente' Then
                MsgBox(4096+48, "", 'É necessário escolher um cliente')
            ElseIf GUICtrlRead($AnoEmissao) = 'Ano de Emissão' Then
                MsgBox(4096+48, "", 'É necessário escolher o ano de emissão')
            ElseIf GUICtrlRead($NumeroLaudoGrupoAbrir) = 'Número de Laudo' Then
                MsgBox(4096+48, "", 'É necessário escolher número de laudo')
            Else
                $objWord = Objcreate("Word.Application")
                $objword.visible = true
                _WordDocOpen($objWord, $WellenPath&GUICtrlRead($Cliente1)&'\'&GUICtrlRead($AnoEmissao)&'\'&GUICtrlRead($NumeroLaudoGrupoAbrir)&'.docx')
            EndIf
        EndSwitch
WEnd

; FUNÇÃO READDATA()
Func ReadData()
    ; Read file
    $sFile = FileRead("configuration.php")
    $aFilter = StringRegExp($sFile, '"path" => "/(.+?)["|/]', 3)
    $aFilter = _ArrayUnique($aFilter)
    _ArrayDelete($aFilter, 0)
    _ArraySort($aFilter)
For $i = 0 To UBound($aFilter) - 1
    $aFilter[$i] = _StringProper($aFilter[$I])
Next
$sComboValue = _ArrayToString($aFilter)
    ; Extract the client names
    $aClients = StringRegExp($sFile, "(?i)(?U)\x22name\x22 => \x22(.*)\x22, \x22password", 3)
    $aClients2 = StringRegExp($sFile, "(?i)(?U)\x22path\x22 => \x22(.*)\x2F\x22", 3)
    $aClients3 = StringRegExp($aClients2, "(?i)(?U)\x2F(.*)", 3)
    ; Extract the passwords
    $aPasswords = StringRegExp($sFile, "(?i)(?U)\x22password\x22 => \x22(.*)\x22, \x22default_permission", 3)
EndFunc   ;==>ReadData

Func WM_Check($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iCode
    Local Static $iIDFrom, $sOld
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $iCode
        Case $EN_SETFOCUS
            $iIDFrom = _WinAPI_LoWord($iwParam)
            $sOld = GUICtrlRead($iIDFrom)
            If GUICtrlRead($iIDFrom) = $aInputID[$iIDFrom] Then GUICtrlSetData($iIDFrom, "")
        Case $EN_KILLFOCUS
            If GUICtrlRead($iIDFrom) = "" Then GUICtrlSetData($iIDFrom, $sOld)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func __myCtrlGetClass($hHandle) ;code by SmOke_N, modified by Guiness
    Local Const $GWL_STYLE = -16
    Local $iLong, $sClass
    If IsHWnd($hHandle) = 0 Then
        $hHandle = GUICtrlGetHandle($hHandle)
        If IsHWnd($hHandle) = 0 Then
            Return SetError(1, 0, "Unknown")
        EndIf
    EndIf

    $sClass = _WinAPI_GetClassName($hHandle)
    If @error Then
        Return "Unknown"
    EndIf

    $iLong = _WinAPI_GetWindowLong($hHandle, $GWL_STYLE)
    If @error Then
        Return SetError(2, 0, 0)
    EndIf

    Switch $sClass
        Case "Button"
            Select
                Case BitAND($iLong, $BS_GROUPBOX) = $BS_GROUPBOX
                    Return "Group"
                Case BitAND($iLong, $BS_CHECKBOX) = $BS_CHECKBOX
                    Return "Checkbox"
                Case BitAND($iLong, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX
                    Return "Checkbox"
                Case BitAND($iLong, $BS_RADIOBUTTON) = $BS_RADIOBUTTON
                    Return "Radio"
                Case BitAND($iLong, $BS_AUTORADIOBUTTON) = $BS_AUTORADIOBUTTON
                    Return "Radio"
            EndSelect

        Case "Edit"
            Select
                Case BitAND($iLong, $ES_WANTRETURN) = $ES_WANTRETURN
                    Return "Edit"
                Case Else
                    Return "Input"
            EndSelect

        Case "Static"
            Select
                Case BitAND($iLong, $SS_BITMAP) = $SS_BITMAP
                    Return "Pic"
                Case BitAND($iLong, $SS_ICON) = $SS_ICON
                    Return "Icon"
                Case BitAND($iLong, $SS_LEFT) = $SS_LEFT
                    If BitAND($iLong, $SS_NOTIFY) = $SS_NOTIFY Then
                        Return "Label"
                    EndIf
                    Return "Graphic"
            EndSelect

        Case "ComboBox"
            Return "Combo"
        Case "ListBox"
            Return "List"
        Case "msctls_progress32"
            Return "Progress"
        Case "msctls_trackbar32"
            Return "Slider"
        Case "SysDateTimePick32"
            Return "Date"
        Case "SysListView32"
            Return "ListView"
        Case "SysMonthCal32"
            Return "MonthCal"
        Case "SysTabControl32"
            Return "Tab"
        Case "SysTreeView32"
            Return "TreeView"

    EndSwitch
    Return $sClass
EndFunc
Edited by pintas

Share this post


Link to post
Share on other sites

$aInputID[$i] = $aDefault_Text[$j]

(161) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

The main issue is to sychronize the $aDefault_Text[] array with $aInputID[] array. You have 2 more input boxes defined which did not have a default text and thus the calculation did not work properly.

The amount of input boxes and default textes should be the same although you have no value for them - just use dummy values.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include<File.au3>
#include <String.au3>
#include <Word.au3>
#include <GUIComboBox.au3>
#include <WinAPI.au3>

Global $aClients, $aPasswords, $sComboValue, $aFilter, $arquivo, $FileList, $WellenPath
Global $aDefault_Text[20] = ["Nome de Empresa / Cliente", "Nome de Usuário (Laudo)", "Senha (Laudo)", "Email", "Telefone", "Nome de Contato", "Função / Área", "Endereço (Rua, Nº, Bairro, Cidade, Estado)", "dummy", "Introduza Nova Senha", "Nome de Usuário", "Senha", "Email", "Telefone", "Nome de Contato", "Função / Área", "Nome de Usuário", "Senha", "Introduza Nova Senha", "dummy"]
ReadData()
$WellenPath = 'D:\WELLEN\LAUDOS\'
#Region ### START Koda GUI section ### Form=C:\Users\Admin\Desktop\Wellen Data Bank\Wellen DB GUI.kxf
$Form1 = GUICreate("Wellen Data Bank", 789, 613)
$MenuItem1 = GUICtrlCreateMenu("&Programa")
$TrocarUsuario = GUICtrlCreateMenuItem("Trocar Usuário"&@TAB&"F2", $MenuItem1)
$Sair = GUICtrlCreateMenuItem("Sair", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Ajuda")
$TABS = GUICtrlCreateTab(0, 104, 785, 465)
$LaudosDadosClientes = GUICtrlCreateTabItem("Laudos / Dados Cliente")
$GrupoListaClientes1 = GUICtrlCreateGroup("Lista de Clientes", 16, 144, 185, 65)
$AbrirListaContato = GUICtrlCreateButton("Abrir Lista de Contatos", 32, 168, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoCriacaoLaudo = GUICtrlCreateGroup("Criação de Laudo", 16, 216, 185, 169)
$NumeroLaudo = GUICtrlCreateLabel("Número de Laudo:", 32, 240, 92, 17)
$AbrirModelo = GUICtrlCreateButton("Abrir Modelo", 32, 344, 155, 25)
$Cliente = GUICtrlCreateCombo("Cliente", 32, 272, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $sComboValue, "")
$Servico = GUICtrlCreateCombo("Serviço", 32, 312, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Ultrassom|Partículas Magnéticas|Liquido Penetrante|Laudo Misto","")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoGraficos = GUICtrlCreateGroup("Gráficos", 16, 400, 185, 153)
$Criar3DSketchup = GUICtrlCreateButton("Criar 3D Sketchup", 32, 496, 155, 25)
$BuscarImagensUS = GUICtrlCreateButton("Buscar Imagens US", 32, 440, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoNovoCliente = GUICtrlCreateGroup("Novo Cliente", 416, 144, 353, 241)
$NomeCliente = GUICtrlCreateInput($aDefault_Text[0], 432, 176, 153, 21)
$NomeUsuario = GUICtrlCreateInput($aDefault_Text[1], 432, 256, 153, 21)
$SenhaLaudo = GUICtrlCreateInput($aDefault_Text[2], 432, 296, 153, 21)
$Email = GUICtrlCreateInput($aDefault_Text[3], 432, 336, 153, 21)
$Telefone = GUICtrlCreateInput($aDefault_Text[4], 600, 296, 153, 21)
$CriarCliente = GUICtrlCreateButton("Criar Cliente", 600, 336, 75, 25)
$LimparInputNovoCliente = GUICtrlCreateButton("Limpar Tudo", 680, 336, 75, 25)
$NomeContato = GUICtrlCreateInput($aDefault_Text[5], 600, 176, 153, 21)
$FuncaoArea = GUICtrlCreateInput($aDefault_Text[6], 600, 256, 153, 21)
$EnderecoNovoCliente = GUICtrlCreateInput($aDefault_Text[7], 432, 216, 321, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoEnviarArquivoCliente = GUICtrlCreateGroup("Envio Arquivo Para Cliente", 216, 400, 553, 153)
$BuscarArquivoCaption = GUICtrlCreateLabel("Arquivo:", 264, 424, 43, 17)
$CaminhoArquivo = GUICtrlCreateInput($aDefault_Text[8], 264, 448, 289, 21) ;8 = dummy
$BuscarArquivo = GUICtrlCreateButton("Buscar Arquivo", 568, 448, 155, 25)
$ListaClientes = GUICtrlCreateLabel("Cliente:", 264, 480, 39, 17)
$Cliente2 = GUICtrlCreateCombo("Cliente", 264, 504, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $sComboValue, "")
$Enviar = GUICtrlCreateButton("Enviar Arquivo", 568, 504, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoAbrirEditarLaudo = GUICtrlCreateGroup("Abrir/Editar Laudo", 216, 144, 185, 241)
$Cliente1 = GUICtrlCreateCombo("Cliente", 232, 184, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $sComboValue, "")
$AnoEmissao = GUICtrlCreateCombo("Ano de Emissão", 232, 232, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Número de Laudo", 232, 280, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$AbrirLaudo = GUICtrlCreateButton("Abrir Laudo", 256, 336, 107, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Financeiro = GUICtrlCreateTabItem("Financeiro")
$GrupoNotaFiscal = GUICtrlCreateGroup("Nota Fiscal", 16, 144, 753, 193)
$Label1 = GUICtrlCreateLabel("Abrir Proposta Comercial", 112, 200, 119, 17)
$Label2 = GUICtrlCreateLabel("Abrir Apropriação de Horas", 368, 216, 131, 17)
$Label3 = GUICtrlCreateLabel("Abrir Nota Fiscal", 112, 264, 81, 17)
$Label5 = GUICtrlCreateLabel("Criar Proposta Comercial", 272, 248, 119, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoOrcamento = GUICtrlCreateGroup("Proposta Comercial / Orçamento", 16, 344, 753, 209)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Admin = GUICtrlCreateTabItem("Admin")
$GrupoSenhaClientes = GUICtrlCreateGroup("Alterar Senha de Clientes", 384, 208, 185, 121)
$ClienteAdmin2 = GUICtrlCreateCombo("Cliente", 400, 232, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, _ArrayToString($aClients))
$SenhaClientesAdmin = GUICtrlCreateInput($aDefault_Text[9], 400, 264, 153, 21)
$AlterarSenhaCliente = GUICtrlCreateButton("Alterar", 440, 296, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoNovoLoginClienteAdmin = GUICtrlCreateGroup("Novo Login de Cliente", 16, 144, 353, 185)
$ClienteAdmin = GUICtrlCreateCombo("Cliente", 32, 168, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, _ArrayToString($aClients))
$NovoUsuarioAdmin = GUICtrlCreateInput($aDefault_Text[10], 32, 232, 153, 21)
$NovoSenhaAdmin = GUICtrlCreateInput($aDefault_Text[11], 32, 264, 153, 21)
$NovoEmailAdmin = GUICtrlCreateInput($aDefault_Text[12], 200, 168, 153, 21)
$NovoTelefoneAdmin = GUICtrlCreateInput($aDefault_Text[13], 200, 200, 153, 21)
$NovoContatoAdmin = GUICtrlCreateInput($aDefault_Text[14], 200, 232, 153, 21)
$NovoFuncaoAdmin = GUICtrlCreateInput($aDefault_Text[15], 200, 264, 153, 21)
$CriarLoginAdmin = GUICtrlCreateButton("Criar Login", 152, 296, 75, 25)
$TipoLogin = GUICtrlCreateCombo("Escolha Tipo", 32, 200, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoNovoUsuarioWellen = GUICtrlCreateGroup("Criar Usuário Wellen DB", 16, 344, 161, 217)
$NovoUsuarioWellen = GUICtrlCreateInput($aDefault_Text[16], 32, 368, 129, 21)
$SenhaNovoUsuarioWellen = GUICtrlCreateInput($aDefault_Text[17], 32, 400, 129, 21)
$PermissaoUsuarioCaption = GUICtrlCreateLabel("Permissões de Usuário:", 32, 432, 114, 17)
$PermissaoInspetor = GUICtrlCreateRadio("Inspetor / Control Téc.", 32, 456, 129, 17)
$PermissaoFinanceiro = GUICtrlCreateRadio("Financeiro", 32, 480, 113, 17)
$PermissaoAdministrador = GUICtrlCreateRadio("Administrador", 32, 504, 113, 17)
GUICtrlSetState($PermissaoInspetor, $GUI_CHECKED)
$CriarUsuarioWellen = GUICtrlCreateButton("Criar Usuário", 56, 528, 83, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoGestaoOnline = GUICtrlCreateGroup("Gestão Clientes Online", 384, 144, 185, 57)
$AbrirGestaoOnline = GUICtrlCreateButton("Abrir Gestão Online", 416, 168, 123, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoSenhaUsuarioWellen = GUICtrlCreateGroup("Senha Usuário Wellen DB", 384, 344, 185, 121)
$SelecioneUsuarioSenha = GUICtrlCreateCombo("Selecione Usuário", 400, 368, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$NovaSenhaUsuario = GUICtrlCreateInput($aDefault_Text[18], 400, 400, 153, 21)
$AlterarSenhaUsuario = GUICtrlCreateButton("Alterar", 440, 432, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoPermissoesUsuarioWellen = GUICtrlCreateGroup("Alterar Permissões Usuário", 192, 344, 177, 217)
$SelecioneUsuarioPermissoes = GUICtrlCreateCombo("Selecione Usuário", 208, 368, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$PermissaoUsuarioCaption2 = GUICtrlCreateLabel("Permissões de Usuário:", 208, 400, 114, 17)
$PermissaoInspetor2 = GUICtrlCreateRadio("Inspetor / Control Téc.", 208, 424, 129, 17)
$PermissaoFinanceiro2 = GUICtrlCreateRadio("Financeiro", 208, 448, 113, 17)
$PermissaoAdministrador2 = GUICtrlCreateRadio("Administrador", 208, 472, 113, 17)
GUICtrlSetState($PermissaoInspetor2, $GUI_CHECKED)
$AlterarPermissaoUsuario = GUICtrlCreateButton("Alterar", 240, 528, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupoRemoverUsuarioWellen = GUICtrlCreateGroup("Remover Usuário Wellen DB", 384, 472, 185, 89)
$SelecioneUsuarioRemover = GUICtrlCreateCombo("Selecione Usuário", 400, 496, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$RemoverUsuarioWellen = GUICtrlCreateButton("Remover", 440, 528, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoEnvioDocsAdmin = GUICtrlCreateGroup("Envio de Documentos", 584, 136, 185, 273)
$CaminhoArquivoAdmin = GUICtrlCreateInput($aDefault_Text[19], 600, 184, 153, 21) ;dummy
$EnvioArquivoAdmin = GUICtrlCreateLabel("Arquivo:", 600, 160, 43, 17)
$BuscarArquivoAdmin = GUICtrlCreateButton("Buscar Arquivo", 632, 208, 91, 25)
$DestinatarioArquivoAdmin = GUICtrlCreateLabel("Destinatário:", 600, 248, 63, 17)
$EnvioTodosClientesLaudos = GUICtrlCreateRadio("Todos Clientes (Laudos)", 600, 272, 145, 17)
$EnvioTodosClientesOrcamentos = GUICtrlCreateRadio("Todos Clientes (Orçamentos)", 600, 296, 153, 17)
$EnvioTodosClientesNotasFiscais = GUICtrlCreateRadio("Todos Clientes (Notas Fiscais)", 600, 320, 161, 17)
$EnvioTodosClientes = GUICtrlCreateRadio("Todos Clientes/Usuários", 600, 344, 153, 17)
GUICtrlSetState($EnvioTodosClientesLaudos, $GUI_CHECKED)
$EnviarAdmin = GUICtrlCreateButton("Enviar", 640, 376, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrupoControleFinanceiro = GUICtrlCreateGroup("Controle Financeiro", 584, 424, 185, 137)
$CompararNotasFiscais = GUICtrlCreateButton("Comparar Notas Fiscais", 600, 456, 155, 25)
$CompararApropHoras = GUICtrlCreateButton("Comparar Aprop. de Horas", 600, 488, 155, 25)
$CompararHorasNotasFisc = GUICtrlCreateButton("Comparar Horas/Notas Fisc.", 600, 520, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
$Banner = GUICtrlCreatePic("C:\Users\Admin\Desktop\Wellen Data Bank\bannerwellen.jpg", 0, 0, 786, 104)
$StatusBar = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetSimple($StatusBar)
_GUICtrlStatusBar_SetText($StatusBar, "Usuário:")
Dim $Form1_AccelTable[1][2] = [["{F2}", $TrocarUsuario]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $aInputID[200] ;space for 200 control IDs (not only input box ids)! Can be increased accordingly ;-)
$j = 0
For $i = 0 To UBound($aInputID) - 1 ;map default text to IDs
    If __myCtrlGetClass($i) = "Input" Then
        $aInputID[$i] = $aDefault_Text[$j]
        $j += 1
    EndIf
Next
;~ _ArrayDisplay($aInputID)

GUIRegisterMsg($WM_Command, 'WM_Check')

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $AlterarSenhaCliente
            If GUICtrlRead($ClienteAdmin2) = 'Cliente' Then
                MsgBox(4096+48, "", 'É necessário escolher um cliente')
            Else
                ; Now search the client array for the value in the combo
                $iIndex = _ArraySearch($aClients, GUICtrlRead($ClienteAdmin2))
                ; And display the corresponding element in the password array
                ReadData()
                _ReplaceStringInFile ( 'configuration.php', '"'&GUICtrlRead($ClienteAdmin2)&'", "password" => "'&$aPasswords[$iIndex]&'"', '"'&GUICtrlRead($ClienteAdmin2)&'", "password" => "'&GUICtrlRead($SenhaClientesAdmin)&'"')
                Sleep(100)
                ReadData()
            If GUICtrlRead($SenhaClientesAdmin)=$aPasswords[$iIndex] Then
                MsgBox(4096+64, "Alteração de Senha", "Senha alterada com sucesso!")
            Else
                MsgBox(4096+48, "Alteração de Senha", "Senha não alterada!")
                EndIf
            EndIf
        Case $AbrirModelo
            If GUICtrlRead($Cliente) = 'Cliente' Then
                MsgBox(4096+48, "", 'É necessário escolher um cliente')
            ElseIf GUICtrlRead($Servico) = 'Serviço' Then
                MsgBox(4096+48, "", 'É necessário escolher um serviço')
            Else
                MsgBox(4160, "box", GUICtrlRead($Cliente))
                MsgBox(4160, "box", GUICtrlRead($Servico))
            EndIf
        Case $BuscarArquivo
            $arquivo = FileOpenDialog("Escolha um arquivo para enviar", @DocumentsCommonDir & "\", "Todos Arquivos (*.*)", 1 + 4 )
            $arquivo = StringReplace($arquivo, "|", @CRLF)
            GUICtrlSetData($CaminhoArquivo, $arquivo)
        Case $Enviar
            If GUICtrlRead($CaminhoArquivo) = '' Then
                MsgBox(4096+48, "", 'É necessário escolher um arquivo para enviar')
            ElseIf GUICtrlRead($Cliente2) = 'Cliente' Then
                MsgBox(4096+48, "", 'É necessário escolher um cliente')
            Else
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivo))
                MsgBox(4160, "box", GUICtrlRead($Cliente2))
            EndIf
        Case $BuscarArquivoAdmin
            $arquivo = FileOpenDialog("Escolha um arquivo para enviar", @DocumentsCommonDir & "\", "Todos Arquivos (*.*)", 1 + 4 )
            $arquivo = StringReplace($arquivo, "|", @CRLF)
            GUICtrlSetData($CaminhoArquivoAdmin, $arquivo)
        Case $EnviarAdmin
            If GUICtrlRead($CaminhoArquivoAdmin) = '' Then
                MsgBox(4096+48, "", 'É necessário escolher um arquivo para enviar')
            Else
            If GUICtrlRead($EnvioTodosClientesLaudos) = $GUI_CHECKED Then
                MsgBox(4160, "O arquivo será enviado para:", "Todos os clientes (Laudos)")
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivoAdmin))
            ElseIf GUICtrlRead($EnvioTodosClientesOrcamentos) = $GUI_CHECKED Then
                MsgBox(4160, "O arquivo será enviado para:", "Todos os clientes (Orçamentos)")
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivoAdmin))
            ElseIf GUICtrlRead($EnvioTodosClientesNotasFiscais) = $GUI_CHECKED Then
                MsgBox(4160, "O arquivo será enviado para:", "Todos os clientes (Notas Fiscais)")
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivoAdmin))
            ElseIf GUICtrlRead($EnvioTodosClientes) = $GUI_CHECKED Then
                MsgBox(4160, "O arquivo será enviado para:", "Todos os clientes (Usuários)")
                MsgBox(4160, "Este arquivo será enviado", GUICtrlRead($CaminhoArquivoAdmin))
            EndIf
            EndIf
        Case $Cliente1
            _GUICtrlComboBox_Destroy($NumeroLaudoGrupoAbrir)
            $NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Número de Laudo", 232, 280, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
            GUICtrlSetState(-1, $GUI_ENABLE)
            _GUICtrlComboBox_Destroy($AnoEmissao)
            $AnoEmissao = GUICtrlCreateCombo("Ano de Emissão", 232, 232, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
            GUICtrlSetState(-1, $GUI_ENABLE)
            If GUICtrlRead($Cliente1) = 'Cliente' Then
                _GUICtrlComboBox_Destroy($NumeroLaudoGrupoAbrir)
                $NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Número de Laudo", 232, 280, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
                GUICtrlSetState(-1, $GUI_ENABLE)
            Else
                $FileYearList=_FileListToArray($WellenPath&GUICtrlRead($Cliente1)&'\','*',2)
                GUICtrlSetData($AnoEmissao, _ArrayToString($FileYearList,"|",1))
            EndIf
        Case $AnoEmissao
            If GUICtrlRead($AnoEmissao) = 'Ano de Emissão' Then
                _GUICtrlComboBox_Destroy($NumeroLaudoGrupoAbrir)
                $NumeroLaudoGrupoAbrir = GUICtrlCreateCombo("Número de Laudo", 232, 280, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
                GUICtrlSetState(-1, $GUI_ENABLE)
            Else
                $FileList =_FileListToArray($WellenPath&GUICtrlRead($Cliente1)&'\'&GUICtrlRead($AnoEmissao)&'\','*.docx',1)
                _ArrayTrim($FileList, 5, 1)
                GUICtrlSetData($NumeroLaudoGrupoAbrir, _ArrayToString($FileList,"|",1))
            EndIf
        Case $AbrirLaudo
            If GUICtrlRead($Cliente1) = 'Cliente' Then
                MsgBox(4096+48, "", 'É necessário escolher um cliente')
            ElseIf GUICtrlRead($AnoEmissao) = 'Ano de Emissão' Then
                MsgBox(4096+48, "", 'É necessário escolher o ano de emissão')
            ElseIf GUICtrlRead($NumeroLaudoGrupoAbrir) = 'Número de Laudo' Then
                MsgBox(4096+48, "", 'É necessário escolher número de laudo')
            Else
                $objWord = Objcreate("Word.Application")
                $objword.visible = true
                _WordDocOpen($objWord, $WellenPath&GUICtrlRead($Cliente1)&'\'&GUICtrlRead($AnoEmissao)&'\'&GUICtrlRead($NumeroLaudoGrupoAbrir)&'.docx')
            EndIf
        EndSwitch
WEnd

; FUNÇÃO READDATA()
Func ReadData()
    ; Read file
    $sFile = FileRead("configuration.php")
    $aFilter = StringRegExp($sFile, '"path" => "/(.+?)["|/]', 3)
    $aFilter = _ArrayUnique($aFilter)
    _ArrayDelete($aFilter, 0)
    _ArraySort($aFilter)
For $i = 0 To UBound($aFilter) - 1
    $aFilter[$i] = _StringProper($aFilter[$I])
Next
$sComboValue = _ArrayToString($aFilter)
    ; Extract the client names
    $aClients = StringRegExp($sFile, "(?i)(?U)\x22name\x22 => \x22(.*)\x22, \x22password", 3)
    $aClients2 = StringRegExp($sFile, "(?i)(?U)\x22path\x22 => \x22(.*)\x2F\x22", 3)
    $aClients3 = StringRegExp($aClients2, "(?i)(?U)\x2F(.*)", 3)
    ; Extract the passwords
    $aPasswords = StringRegExp($sFile, "(?i)(?U)\x22password\x22 => \x22(.*)\x22, \x22default_permission", 3)
EndFunc   ;==>ReadData

Func WM_Check($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iCode
    Local Static $iIDFrom, $sOld
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $iCode
        Case $EN_SETFOCUS
            $iIDFrom = _WinAPI_LoWord($iwParam)
;~          ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iIDFrom = ' & $iIDFrom & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
            $sOld = GUICtrlRead($iIDFrom)
;~          ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sOld = ' & $sOld & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
            If GUICtrlRead($iIDFrom) = $aInputID[$iIDFrom] Then GUICtrlSetData($iIDFrom, "")
        Case $EN_KILLFOCUS
            If GUICtrlRead($iIDFrom) = "" Then GUICtrlSetData($iIDFrom, $sOld)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func __myCtrlGetClass($hHandle) ;code by SmOke_N, modified by Guiness
    Local Const $GWL_STYLE = -16
    Local $iLong, $sClass
    If IsHWnd($hHandle) = 0 Then
        $hHandle = GUICtrlGetHandle($hHandle)
        If IsHWnd($hHandle) = 0 Then
            Return SetError(1, 0, "Unknown")
        EndIf
    EndIf

    $sClass = _WinAPI_GetClassName($hHandle)
    If @error Then
        Return "Unknown"
    EndIf

    $iLong = _WinAPI_GetWindowLong($hHandle, $GWL_STYLE)
    If @error Then
        Return SetError(2, 0, 0)
    EndIf

    Switch $sClass
        Case "Button"
            Select
                Case BitAND($iLong, $BS_GROUPBOX) = $BS_GROUPBOX
                    Return "Group"
                Case BitAND($iLong, $BS_CHECKBOX) = $BS_CHECKBOX
                    Return "Checkbox"
                Case BitAND($iLong, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX
                    Return "Checkbox"
                Case BitAND($iLong, $BS_RADIOBUTTON) = $BS_RADIOBUTTON
                    Return "Radio"
                Case BitAND($iLong, $BS_AUTORADIOBUTTON) = $BS_AUTORADIOBUTTON
                    Return "Radio"
            EndSelect

        Case "Edit"
            Select
                Case BitAND($iLong, $ES_WANTRETURN) = $ES_WANTRETURN
                    Return "Edit"
                Case Else
                    Return "Input"
            EndSelect

        Case "Static"
            Select
                Case BitAND($iLong, $SS_BITMAP) = $SS_BITMAP
                    Return "Pic"
                Case BitAND($iLong, $SS_ICON) = $SS_ICON
                    Return "Icon"
                Case BitAND($iLong, $SS_LEFT) = $SS_LEFT
                    If BitAND($iLong, $SS_NOTIFY) = $SS_NOTIFY Then
                        Return "Label"
                    EndIf
                    Return "Graphic"
            EndSelect

        Case "ComboBox"
            Return "Combo"
        Case "ListBox"
            Return "List"
        Case "msctls_progress32"
            Return "Progress"
        Case "msctls_trackbar32"
            Return "Slider"
        Case "SysDateTimePick32"
            Return "Date"
        Case "SysListView32"
            Return "ListView"
        Case "SysMonthCal32"
            Return "MonthCal"
        Case "SysTabControl32"
            Return "Tab"
        Case "SysTreeView32"
            Return "TreeView"

    EndSwitch
    Return $sClass
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Oh, ok. Now i understand.

That WinAPI is still a mystery to me.

I can simply change the colors of that dummy text and it works perfect.

Thanks again. You've been very very helpful. :huh2:

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
Sign in to follow this  
Followers 0