Biatu

Tabbing between controls on child gui

4 posts in this topic

#1 ·  Posted (edited)

I have tried everything I could find in the forums, but have not had any luck.

I have tried setting MDI property, and even WS_CHILD, but that just makes child disappear.

The child is supposed to accept Tabs between controls and accept enter on the "Continue" button, but no go.

Here is code:

Func PromptCreds($iUser,$iPass,$iPass2,$iSave=1)
    GUISetOnEvent($GUI_EVENT_CLOSE,"")
    Opt("GUIOnEventMode",0)
    $hLogon=GUICreate("Login", 210, 128,-1,-1,$WS_CAPTION, $WS_EX_CONTROLPARENT,$hWnd)
    GUISetFont(8.5,400,0,"Consolas")
    GUICtrlCreateLabel("Please Enter your credentials...", 4, 4, 210, 17)
    $idUser=GUICtrlCreateInput("",4,24,210-8,21,$WS_TABSTOP)
    _GUICtrlEdit_SetCueBanner(GUICtrlGetHandle(-1),"Username",1)
    $idPass=GUICtrlCreateInput("",4,48,210-8,21,BitOR($WS_TABSTOP,$ES_PASSWORD))
    $sDefaultPassChar=GUICtrlSendMsg(-1,$EM_GETPASSWORDCHAR,0,0)
    GUICtrlSendMsg(-1,$EM_SETPASSWORDCHAR,0,0)
    _GUICtrlEdit_SetCueBanner(GUICtrlGetHandle(-1),"Password",1)
    $idPass2=GUICtrlCreateInput("",4,72,210-8,21,BitOR($WS_TABSTOP,$ES_PASSWORD))
    GUICtrlSendMsg(-1,$EM_SETPASSWORDCHAR,0,0)
    _GUICtrlEdit_SetCueBanner(GUICtrlGetHandle(-1),"Password 2",1)
    $idDone=GUICtrlCreateButton("Continue",210/2-(75/2),98,75,25,$BS_DEFPUSHBUTTON)
    GUIRegisterMsg($WM_COMMAND,"WM_COMMAND")
    GUISwitch($hLogon)
    GUISetState(@SW_SHOW,$hLogon)
    While Sleep(1)
        $nMsg = GUIGetMsg(1)
        If $nMsg[1]<>$hLogon Then ContinueLoop
        Switch $nMsg[0]
            Case $idDone
                $sNTUser=GUICtrlRead($idUser)
                $sNTPass=GUICtrlRead($idPass)
                $sNTPass2=GUICtrlRead($idPass2)
                If $sNTUser="" Or $sNTPass="" Then
                    MsgBox(32,"Error","A Username and Password are required to continue.")
                    ContinueLoop
                EndIf
                If $iSave Then
                    $sRet=MsgBox(64+4,"Question","Would you like to save these credentials for later?"&@CRLF&"NOTE: Your password(s) will be encrypted, however you will need to take caution if other users will be accessing your profile.")
                    If $sRet=6 Then
                        FileClose(FileOpen($sLogonData,8+2))
                        IniWrite($sLogonData,"Citrix","NT.User",$sNTUser)
                        $sCryptPass=_protect($sNTPass)
                        IniWrite($sLogonData,"Citrix","NT.Password",$sCryptPass)
                        If $sNTPass2<>"" Then
                            $sCryptPass2=_protect($sNTPass2)
                            IniWrite($sLogonData,"Citrix","NT.Password2",$sCryptPass2)
                        EndIf
                        If IniRead($sLogonData,"Citrix","NT.User","NaN")=$sNTUser And (IniRead($sLogonData,"Citrix","NT.Password","NaN")=$sNTPass Or IniRead($sLogonData,"Citrix","NT.Password","NaN")=$sCryptPass) And (IniRead($sLogonData,"Citrix","NT.Password2","NaN")=$sNTPass2 Or IniRead($sLogonData,"Citrix","NT.Password2","NaN")=$sCryptPass2) Then
                            MsgBox(64,"Success","Your Credentials Have been Stored.")
                            ExitLoop
                        Else
                            MsgBox(16,"Error","Some or none of your credentials have been stored!"&@CRLF&"NOTE: Please ensure that "&$sLogonData&" is not read only, and you have write permissions and try again.")
                            ContinueLoop
                        EndIf
                    ElseIf $sRet=6 Then
                        ExitLoop
                    EndIf
                EndIf
                ExitLoop
        EndSwitch
    WEnd
    GUISetState(@SW_HIDE,$hLogon)
    GUIRegisterMsg($WM_COMMAND,"")
    GUIDelete($hLogon)
    $hLogon=""
    $idUser=""
    $idPass=""
    $idPass2=""
    $idDone=""
    $sDefaultPassChar=""
    Opt("GUIOnEventMode",1)
    GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
    GUISwitch($hWnd)
EndFunc


Func WM_COMMAND($hWnd,$iMsg,$wParam,$lParam)
    Local Static $sLastGood,$sLastGoodBTN,$sLastGoodCBR
    #forceref $hWnd,$iMsg,$lParam
    $iCode=_WinAPI_HiWord($wParam)
    $iID=_WinAPI_LoWord($wParam)
    If $iID=$idPass Or $iID=$idPass2 Then
        If $iCode=$EN_CHANGE Then
            If GUICtrlRead($iID)<>"" Then
                GUICtrlSendMsg($iID,$EM_SETPASSWORDCHAR,$sDefaultPassChar,0)
            Else
                GUICtrlSendMsg($iID,$EM_SETPASSWORDCHAR,0,0)
            EndIf
        EndIf
    EndIf
EndFunc

 

Edited by Biatu

What is what? What is what.

Share this post


Link to post
Share on other sites



#2 ·  Posted

Biatu,

Tabbing works fine for me on this modified version (modified so that it actually runs):

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

#include <WinAPI.au3>

Global $idPass, $idPass2, $sDefaultPassChar

$hGUI = GUICreate("Test", 500, 500)

$cChild = GUICtrlCreateButton("Child", 10, 10, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cChild
            PromptCreds()
    EndSwitch
WEnd

Func PromptCreds()

    $hLogon = GUICreate("Login", 210, 128, -1, -1, $WS_CAPTION, $WS_EX_CONTROLPARENT, $hGUI)

    GUICtrlCreateLabel("Please Enter your credentials...", 4, 4, 210, 17)

    $idUser = GUICtrlCreateInput("", 4, 24, 210 - 8, 21, $WS_TABSTOP)
    $idPass = GUICtrlCreateInput("", 4, 48, 210 - 8, 21, BitOR($WS_TABSTOP, $ES_PASSWORD))
    $sDefaultPassChar = GUICtrlSendMsg(-1, $EM_GETPASSWORDCHAR, 0, 0)
    GUICtrlSendMsg(-1, $EM_SETPASSWORDCHAR, 0, 0)

    $idPass2 = GUICtrlCreateInput("", 4, 72, 210 - 8, 21, BitOR($WS_TABSTOP, $ES_PASSWORD))
    GUICtrlSendMsg(-1, $EM_SETPASSWORDCHAR, 0, 0)

    $idDone = GUICtrlCreateButton("Continue", 210 / 2 - (75 / 2), 98, 75, 25, $BS_DEFPUSHBUTTON)

    GUISetState(@SW_SHOW, $hLogon)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    While Sleep(1)
        $nMsg = GUIGetMsg(1)
        If $nMsg[1] <> $hLogon Then ContinueLoop
        Switch $nMsg[0]
            Case $idDone
                $sNTUser = GUICtrlRead($idUser)
                $sNTPass = GUICtrlRead($idPass)
                $sNTPass2 = GUICtrlRead($idPass2)
                If $sNTUser = "" Or $sNTPass = "" Then
                    MsgBox(32, "Error", "A Username and Password are required to continue.")
                    ContinueLoop
                EndIf
                ExitLoop
        EndSwitch
    WEnd
    GUISetState(@SW_HIDE, $hLogon)
    GUIRegisterMsg($WM_COMMAND, "")
    GUIDelete($hLogon)
    $hLogon = ""
    $idUser = ""
    $idPass = ""
    $idPass2 = ""
    $idDone = ""
    $sDefaultPassChar = ""
    GUISwitch($hGUI)
EndFunc   ;==>PromptCreds


Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local Static $sLastGood, $sLastGoodBTN, $sLastGoodCBR
    #forceref $hWnd, $iMsg, $lParam
    $iCode = _WinAPI_HiWord($wParam)
    $iID = _WinAPI_LoWord($wParam)
    If $iID = $idPass Or $iID = $idPass2 Then
        If $iCode = $EN_CHANGE Then
            If GUICtrlRead($iID) <> "" Then
                GUICtrlSendMsg($iID, $EM_SETPASSWORDCHAR, $sDefaultPassChar, 0)
            Else
                GUICtrlSendMsg($iID, $EM_SETPASSWORDCHAR, 0, 0)
            EndIf
        EndIf
    EndIf
EndFunc   ;==>WM_COMMAND

It does help if you produce a runnable reproducer script as now you cannot tell which of my changes has made the difference. If you do post a simplified runnable script which shows the problem, I would be happy to take another look.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

In that case, it has to be the other bits of my script... here is the full source

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Resources\TP2.ico
#AutoIt3Wrapper_Outfile=..\CitrixAutomata.exe
#AutoIt3Wrapper_Outfile_x64=..\CitrixAutomata.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=AutoLogon for Citrix
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=InfinityResearchAndDevelopment 2016
#AutoIt3Wrapper_Run_Before=T:\Services\wwwRoot\priv\Infinity.UpdateManager\InfinityUpdate2.exe "%scriptdir%" "%out%"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         BiatuAutMiahn [@outlook.com]

 -Needs to Handle password expiration
 -Needs to Handle Citrix Reciever Download.

 :Recent Changes
     -Updated Updater/Main GUI to have only close button.
     -Fixed password decrypt error after initiallty setting password
     -Moved logon data file to Appdata dir
     -Fixed program exit
#ce ----------------------------------------------------------------------------

Opt("TrayAutoPause",0)
Opt("TrayIconHide",1)
Opt("GUIOnEventMode",1)
;Opt("GUIOnEventMode",1)
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <Date.au3>
#include "Includes\CryptProtect.au3"

Local $sTitle="Citrix AutoLogon v1.0"
#include "Includes\Updater.au3"
Local $iDebug=false, $iDelay=false, $iUpdate=True
If StringInStr($CmdLineRaw,"~!Debug") Then $iDebug=true
Local $sLogonData=@AppDataDir&"\InfinityRND\CitrixAutomata\Logon.ini";@ScriptDir&"\Logon.ini"
$sTitle="Citrix AutoLogon v1.0 (Build: "&$_sInfinityProgram_Version&")"
Local $iWidth, $iHeight, $g_idError_Message, $idProgress, $iProgressStep=100/5, $oIE, $iTry=0
Local $hLogon, $idUser, $idPass, $idPass2, $idDone, $sDefaultPassChar, $iTempLogon
Do
    $oIE=_IECreateEmbedded()
    If Not IsObj($oIE) Or @error Then
        If $iTry=5 Then
            MsgBox(64,"Error "&@Error,"Failure creating IE Instance.")
            Exit 1
        EndIf
        $iTry+=1
    Else
        ExitLoop
    EndIf
Until False
Local $sNTUser="NaN", $sNTPass="NaN", $sNTPass2="NaN"
If $iDebug Then
    $sTitle&=" (Debug)"
    $iWidth=(@DesktopWidth) / 2
    $iHeight=(@DesktopHeight) / 2
Else
    $iWidth=256+128
    $iHeight=32
EndIf
$hWnd=GUICreate($sTitle,$iWidth,$iHeight*1.90,-1,-1,$WS_SYSMENU)
;_WinAPI_SetWindowLong($hWnd,$GWL_STYLE,BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), BitNOT($WS_TABSTOP)))
GUICtrlCreateObj($oIE,0,16,$iWidth,$iHeight-16)
If Not $iDebug Then GUICtrlSetState(-1,32)
If $iDebug Then
    $g_idError_Message = GUICtrlCreateLabel("Status: ",0,0,$iWidth,16)
    GUICtrlSetColor(-1, 0xff0000)
Else
    $idProgress=GUICtrlCreateProgress(0,0,$iWidth,$iHeight/2,$PBS_SMOOTH)
    $g_idError_Message=GUICtrlCreateLabel("Status: ",0,$iHeight-($iHeight/2),$iWidth,$iHeight/2)
EndIf
GUISetState(@SW_SHOW) ;Show GUI
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
;HotKeySet("{ESC}","_Exit")

Logon()

While Sleep(10)
WEnd

Func _Exit()
    GUIDelete()
    Exit
EndFunc

Func Logon()
    GetCreds()
    Local $iDownloadDone=False
    Local $iSkipLogon=False
    If Not @Compiled Then $iSkipLogon=True
    GUICtrlSetData($g_idError_Message,"Connecting...")
    _IENavigate($oIE, "https://www.google.com/"); Changed for privacy
    _IELoadWait($oIE)
    GUICtrlSetData($g_idError_Message,"Connected")
    If Not $iDebug Then GUICtrlSetData($idProgress,$iProgressStep*1)
    If $iDelay Then Sleep(250)
    GUICtrlSetData($g_idError_Message,"Waiting for Logon Page...")
    Do
        If Not $iDownloadDone Then
            $oObj=_IEGetObjById($oIE, "downloadbutton")
            If IsObj($oObj) And Not @error Then
                If Not StringInStr($oObj.style.csstext,"display: none") Then
                    $sRet=MsgBox(64+4,"Software Download Required","The NetScaler Gateway Endpoint Application is Required"&@CRLF&@CRLF&"Would you like to download it now?")
                    Switch $sRet
                        Case 6
                            _IEAction($oObj,"click")
                            $iDownloadDone=true
                        Case Else
                            MsgBox(16,"Error","The NetScaler Gateway Endpoint Application is Required!"&@CRLF&"Unable to Continue.")
                            Return SetError(1,4,0)
                    EndSwitch
                EndIf
            EndIf
        EndIf
        $oObj=_IEGetObjById($oIE, "Access Denied")
        If IsObj($oObj) And Not @error Then
                GUICtrlSetData($g_idError_Message,"Waiting for Logon Page...Failed")
                MsgBox(16,"Error","Your device does not meet the requirements for logging on.")
                Return SetError(1,5,0)
        EndIf
        If $iDelay Then Sleep(250)
        ConsoleWrite(_IEPropertyGet($oIE,"locationurl")&@CRLF)
        If _IEPropertyGet($oIE,"locationurl")="https://www.google.com/" Then; Changed for privacy
            FileWrite("Test.html",_IEDocReadHTML($oIE))
            $iSkipLogon=True
            ExitLoop
        EndIf
    Until _IEPropertyGet($oIE,"locationurl")="https:/www.google.com/"; Changed for privacy
    _IELoadWait($oIE)
    If Not $iSkipLogon Then
        GUICtrlSetData($g_idError_Message,"Waiting for Logon Page...Done")
        If Not $iDebug Then GUICtrlSetData($idProgress,$iProgressStep*2)
        Local $oForm = _IEFormGetObjByName($oIE, "vpnForm")
        Local $oUser = _IEFormElementGetObjByName($oForm, "Enter user name")
        Local $oPass1 = _IEFormElementGetObjByName($oForm, "passwd")
        Local $oPass2 = _IEFormElementGetObjByName($oForm, "passwd1")
        Local $oLogon = _IEFormElementGetObjByName($oForm, "Log_On")
        _IEFormElementSetValue($oUser, $sNTUser)
        _IEFormElementSetValue($oPass1, _unprotect($sNTPass))
        _IEFormElementSetValue($oPass2, _unprotect($sNTPass2))
        _IEAction($oLogon,"click")
        If $iDelay Then Sleep(250)
        GUICtrlSetData($g_idError_Message,"Logging in...")
        _IELoadWait($oIE)
        GUICtrlSetData($g_idError_Message,"Logging in...Done")
        If Not $iDebug Then GUICtrlSetData($idProgress,$iProgressStep*3)
        If $iDelay Then Sleep(250)
        Local $oFeedback
        Local $oError
        $oFeedback = _IEGetObjById($oIE, "feedbackStyle")
        If IsObj($oFeedback) Then
            $oError=_IEGetObjById($oFeedback, "errorMessageLabel")
            If IsObj($oError) Then
                $sError=_IEPropertyGet($oError,"innertext")
                Switch $sError
                    Case "User not found."
                        GUICtrlSetData($g_idError_Message,"Logging in...Error, "&$sError)
                        Return SetError(1,6,$sError)
                    Case "Incorrect credentials. Try again."
                        GUICtrlSetData($g_idError_Message,"Logging in...Error, "&$sError)
                        Return SetError(1,7,0)
                    Case Else
                        GUICtrlSetData($g_idError_Message,"Logging in...Error, "&$sError)
                        ClipPut($sError)
                        Return SetError(1,8,0)
                EndSwitch
            EndIf
        EndIf
    EndIf
    GUICtrlSetData($g_idError_Message,"Waiting for Citrix StoreFront...")
    Do
        Sleep(250)
    Until _IEPropertyGet($oIE,"locationurl")="https://www.google.com/"; Changed for privacy
    _IELoadWait($oIE)
    ;Download Citrix
    If $iDebug Then
        $oObj=_IEGetObjById($oIE,"plugin-assistance-download")
        If IsObj($oObj) And Not @error Then
            $sHtml=_IEPropertyGet($oObj,"outerhtml")
            If StringInStr($sHTML,'id="plugin-assistance-download" style="display: block;"') Then
                $oObj=_IEGetObjById($oIE,"legalstatement-checkbox1")
                If IsObj($oObj) And Not @error Then
                    $iTmp=_IEAction($oObj,"click")
                    GUICtrlSetData($g_idError_Message,"Citrix Reciever Download Required...")
                        $sRet=MsgBox(64+4,"Download Required Software","Citrix Reciever is Required"&@CRLF&@CRLF&"Would you like to download it now?")
                        Switch $sRet
                            Case 6
                                _IELinkClickByText($oIE, "Install",0,1)
                                ;ProcessWait("Recevier.exe")
                                ;_IELinkClickByText($oIE, "Continue",0,1)
                            Case Else
                                GUICtrlSetData($g_idError_Message,"Citrix Reciever Download Required...Rejected")
                                MsgBox(16,"Error","Citrix Reciever is Required!"&@CRLF&"Unable to Continue.")
                                Return SetError(1,4,0)
                        EndSwitch
                EndIf
            EndIf
        EndIf
    EndIf
    GUICtrlSetData($g_idError_Message,"Waiting for Citrix StoreFront...Done")
    If Not $iDebug Then GUICtrlSetData($idProgress,$iProgressStep*4)
    While Sleep(250)
        If @Compiled Then _CitrixRun()
        GUISetState(@SW_RESTORE,$hWnd)
        GUICtrlSetData($g_idError_Message,"Citrix has closed")
        $iRet=MsgBox(32+4,"Warning","Citrix was closed, Restart it?")
        If $iRet=2 Or $iRet=7 Then ExitLoop
    WEnd
    If $iDebug Then Return SetError(0,0,1)
    Sleep(1000)
    Exit 0
EndFunc

Func _CitrixRun()
    GUICtrlSetData($g_idError_Message,"Starting FRONTIER-MCS...")
    If ProcessExists("wfica32.exe") Then
        ProcessClose("wfica32.exe")
    EndIf
    While Sleep(250)
        If Not $iDebug Then _IEImgClick($oIE,"FRONTIER-MCS","alt");
        If Not @error Then
            $iRet=ProcessWait("wfica32.exe",10000)
            If $iRet=0 Then
                If ProcessExists("wfica32.exe") Then
                    ProcessClose("wfica32.exe")
                EndIf
                ContinueLoop
            Else
                ExitLoop
            EndIf
        ElseIf @Error<>$_IEStatus_NoMatch Then
            FileWrite("Automata.Error.Log",@ScriptLineNumber&"|"&@ERROR)
        EndIf
    WEnd
    ;ProcessWait("wfcrun32.exe")
    ProcessWait("wfica32.exe")
    GUICtrlSetData($g_idError_Message,"Starting FRONTIER-MCS...Done")
    Sleep(250)
    GUICtrlSetData($g_idError_Message,"Citrix is Running")
    Sleep(2000)
    GUISetState(@SW_MINIMIZE,$hWnd)
    If Not $iDebug Then GUICtrlSetData($idProgress,$iProgressStep*5)
    $iRefresh=TimerInit()
    While Sleep(250)
        If ProcessExists("wfica32.exe") Then
            If TimerDiff($iRefresh)>=(1*60*1000) Then
                _IEAction($oIE, "refresh")
                $iRefresh=TimerInit()
            EndIf
        Else
            ExitLoop
        EndIf
    WEnd
EndFunc

Func CheckError($sMsg, $iError, $iExtended)
    If $iError Then
        $sMsg = "Error using " & $sMsg & " button (" & $iExtended & ")"
    Else
        $sMsg = ""
    EndIf
    GUICtrlSetData($g_idError_Message, $sMsg)
EndFunc   ;==>CheckError

Func GetCreds()
    GUICtrlSetData($g_idError_Message,"Reading Logon.ini...")
    If FileExists($sLogonData) Then
        $sNTUser=IniRead($sLogonData,"Citrix","NT.User","NaN")
        $sNTPass=IniRead($sLogonData,"Citrix","NT.Password","NaN")
        $sNTPass2=IniRead($sLogonData,"Citrix","NT.Password2","NaN")
    Else
        Do
            $sRet=MsgBox(32+4,"Warning","No Credentials Stored, would you like to use new credentials?")
            Switch $sRet
                Case 6
                    PromptCreds(1,1,1)
                    If @error Then Return SetError(1,1,0)
                    ExitLoop
                Case 7
                    $sRet=MsgBox(32+4,"Question","Would you like to use tempoary credentials?")
                    Switch $sRet
                        Case 6
                            PromptCreds(1,1,1,0)
                            If @error Then Return SetError(1,1,0)
                            ExitLoop
                        Case Else
                            MsgBox(16,"Error","This application will not work without User Credentials.")
                            Return SetError(1,1,0)
                    EndSwitch
            EndSwitch
        Until False
    EndIf
    If $sNTUser="NaN" Then PromptCreds(1,0,0)
    If @error Then Return SetError(1,2,0)
    If $sNTPass="NaN" Then PromptCreds(0,1,0)
    If @error Then Return SetError(1,3,0)
    If $sNTPass2="NaN" Then PromptCreds(0,0,1)
EndFunc

Func PromptCreds($iUser,$iPass,$iPass2,$iSave=1)
    GUISetOnEvent($GUI_EVENT_CLOSE,"")
    Opt("GUIOnEventMode",0)
    $hLogon=GUICreate("Login", 210, 128,-1,-1,$WS_CAPTION, $WS_EX_CONTROLPARENT,$hWnd)
    GUISetFont(8.5,400,0,"Consolas")
    GUIStartGroup()
    GUICtrlCreateLabel("Please Enter your credentials...", 4, 4, 210, 17)
    $idUser=GUICtrlCreateInput("",4,24,210-8,21,$WS_TABSTOP)
    _GUICtrlEdit_SetCueBanner(GUICtrlGetHandle(-1),"Username",1)
    $idPass=GUICtrlCreateInput("",4,48,210-8,21,BitOR($WS_TABSTOP,$ES_PASSWORD))
    $sDefaultPassChar=GUICtrlSendMsg(-1,$EM_GETPASSWORDCHAR,0,0)
    GUICtrlSendMsg(-1,$EM_SETPASSWORDCHAR,0,0)
    _GUICtrlEdit_SetCueBanner(GUICtrlGetHandle(-1),"Password",1)
    $idPass2=GUICtrlCreateInput("",4,72,210-8,21,BitOR($WS_TABSTOP,$ES_PASSWORD))
    GUICtrlSendMsg(-1,$EM_SETPASSWORDCHAR,0,0)
    _GUICtrlEdit_SetCueBanner(GUICtrlGetHandle(-1),"Password 2",1)
    $idDone=GUICtrlCreateButton("Continue",210/2-(75/2),98,75,25,$BS_DEFPUSHBUTTON)
    GUIRegisterMsg($WM_COMMAND,"WM_COMMAND")
    GUISwitch($hLogon)
    GUISetState(@SW_SHOW,$hLogon)
    While Sleep(1)
        $nMsg = GUIGetMsg(1)
        If $nMsg[1]<>$hLogon Then ContinueLoop
        Switch $nMsg[0]
            Case $idUser
                GUICtrlSetState($idPass,$GUI_FOCUS)
            Case $idDone
                $sNTUser=GUICtrlRead($idUser)
                $sNTPass=GUICtrlRead($idPass)
                $sNTPass2=GUICtrlRead($idPass2)
                If $sNTUser="" Or $sNTPass="" Then
                    MsgBox(32,"Error","A Username and Password are required to continue.")
                    ContinueLoop
                EndIf
                If $iSave Then
                    $sRet=MsgBox(64+4,"Question","Would you like to save these credentials for later?"&@CRLF&"NOTE: Your password(s) will be encrypted, however you will need to take caution if other users will be accessing your profile.")
                    If $sRet=6 Then
                        FileClose(FileOpen($sLogonData,8+2))
                        IniWrite($sLogonData,"Citrix","NT.User",$sNTUser)
                        $sCryptPass=_protect($sNTPass)
                        IniWrite($sLogonData,"Citrix","NT.Password",$sCryptPass)
                        If $sNTPass2<>"" Then
                            $sCryptPass2=_protect($sNTPass2)
                            IniWrite($sLogonData,"Citrix","NT.Password2",$sCryptPass2)
                        EndIf
                        If IniRead($sLogonData,"Citrix","NT.User","NaN")=$sNTUser And (IniRead($sLogonData,"Citrix","NT.Password","NaN")=$sNTPass Or IniRead($sLogonData,"Citrix","NT.Password","NaN")=$sCryptPass) And (IniRead($sLogonData,"Citrix","NT.Password2","NaN")=$sNTPass2 Or IniRead($sLogonData,"Citrix","NT.Password2","NaN")=$sCryptPass2) Then
                            MsgBox(64,"Success","Your Credentials Have been Stored.")
                            ExitLoop
                        Else
                            MsgBox(16,"Error","Some or none of your credentials have been stored!"&@CRLF&"NOTE: Please ensure that "&$sLogonData&" is not read only, and you have write permissions and try again.")
                            ContinueLoop
                        EndIf
                    ElseIf $sRet=6 Then
                        ExitLoop
                    EndIf
                EndIf
                ExitLoop
        EndSwitch
    WEnd
    GUISetState(@SW_HIDE,$hLogon)
    GUIRegisterMsg($WM_COMMAND,"")
    GUIDelete($hLogon)
    $hLogon=""
    $idUser=""
    $idPass=""
    $idPass2=""
    $idDone=""
    $sDefaultPassChar=""
    Opt("GUIOnEventMode",1)
    GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
    GUISwitch($hWnd)
EndFunc

Func WM_COMMAND($hWnd,$iMsg,$wParam,$lParam)
    Local Static $sLastGood,$sLastGoodBTN,$sLastGoodCBR
    #forceref $hWnd,$iMsg,$lParam
    $iCode=_WinAPI_HiWord($wParam)
    $iID=_WinAPI_LoWord($wParam)
    If $iID=$idPass Or $iID=$idPass2 Then
        If $iCode=$EN_CHANGE Then
            If GUICtrlRead($iID)<>"" Then
                GUICtrlSendMsg($iID,$EM_SETPASSWORDCHAR,$sDefaultPassChar,0)
            Else
                GUICtrlSendMsg($iID,$EM_SETPASSWORDCHAR,0,0)
            EndIf
        EndIf
    EndIf
EndFunc


Func _unprotect($data)
    If $data <> '' Then
        Local $sDesc = '', $iError2, $iExtended2
        $data = _CryptUnprotectData($data, $sDesc)
        $iError2 = @error
        $iExtended2 = @extended
        If $iError2 > 0 Or $iExtended2 > 0 Then
            MsgBox(0, 'error', "Error protecting: " & $iError2 & @LF & "Windows error protecting: " & $iExtended2)
            Exit
        EndIf
        Return $data
    Else
        Return ''
    EndIf
EndFunc   ;==>_unprotect

Func _protect($data)
    Local $iError1, $iExtended1
    Local $tCur = _Date_Time_GetLocalTime()
    $tCur = _Date_Time_SystemTimeToDateTimeStr($tCur)
    ConsoleWrite($tCur & @CRLF)
    $data = _CryptProtectData($data, $tCur)
    $iError1 = @error
    $iExtended1 = @extended
    If $iError1 > 0 Or $iExtended1 > 0 Then
        MsgBox(0, 'error', "Error protecting: " & $iError1 & @LF & "Windows error protecting: " & $iExtended1)
        Exit
    EndIf
    Return $data
EndFunc   ;==>_protect

Includes.zip

Edited by Biatu

What is what? What is what.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It's GuiCtrlCreateObj that is interfering with my controls, and I cannot disable or hide it to allow the child controls to function. Any ideas?

Edit: 

 

 

Edited by Biatu

What is what? What is what.

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