Now it supports Multiple Password Inputs. Before it was using a single Global Variable, but it has been optimised to use an Array to store the Input ControlID's and the respective state. See the Example for more details.
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
_Main
()
Func _Main
()
Local $hGUI, $iButton_1, $iButton_2, $iButton_3, $iInput_1, $iInput_2, $iInput_3, $iTab_1, $iTab_3
$hGUI = GUICreate("GUI", 220, 150)
GUICtrlCreateTab(10, 10, 200, 100)
$iTab_1 = GUICtrlCreateTabItem("Tab_1")
$iInput_1 = GUICtrlCreateInput("", 20, 52.5, 110, 20, 0x0020)
$iButton_1 = GUICtrlCreateButton("Show", 140, 50, 50)
GUICtrlCreateTabItem("Tab_2")
$iTab_3 = GUICtrlCreateTabItem("Tab_3")
GUICtrlSetState(-1, $GUI_SHOW)
$iInput_3 = GUICtrlCreateInput("", 20, 52.5, 110, 20, 0x0020)
$iButton_3 = GUICtrlCreateButton("Show", 140, 50, 50)
GUICtrlCreateTabItem("")
$iInput_2 = GUICtrlCreateInput("", 20, 117.5, 110, 20, 0x0020)
$iButton_2 = GUICtrlCreateButton("Show", 140, 115, 50)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $iButton_1
_DisplayPassword
($hGUI, $iInput_1, $iTab_1) ; Show/Hide Password Input.
Switch GUICtrlRead($iButton_1) ; Change Button Text.
Case "Show"
GUICtrlSetData($iButton_1, "Hide")
Case "Hide"
GUICtrlSetData($iButton_1, "Show")
EndSwitch
Case $iButton_2
_DisplayPassword
($hGUI, $iInput_2) ; Show/Hide Password Input. And Because It's Not In A Tab, We Don't Specify The Tab Variable.
Switch GUICtrlRead($iButton_2) ; Change Button Text.
Case "Show"
GUICtrlSetData($iButton_2, "Hide")
Case "Hide"
GUICtrlSetData($iButton_2, "Show")
EndSwitch
Case $iButton_3
_DisplayPassword
($hGUI, $iInput_3, $iTab_3) ; Show/Hide Password Input.
Switch GUICtrlRead($iButton_3) ; Change Button Text.
Case "Show"
GUICtrlSetData($iButton_3, "Hide")
Case "Hide"
GUICtrlSetData($iButton_3, "Show")
EndSwitch
EndSwitch
WEnd
EndFunc ;==>_Main
Func _DisplayPassword
($hHandle, $iControlID, $iTab = -1)
Local $aControlGetPos, $bExStyle = -1, $iIndex = -1, $iType = 0, $sRead
If IsDeclared("Global_DisplayPassword") = 0 Then
Global $Global_DisplayPassword[1][2] = [[0, 2]]
EndIf
For $A = 1 To $Global_DisplayPassword[0][0]
If @error Then
ExitLoop
EndIf
If $Global_DisplayPassword[$A][0] = $iControlID Then
$iIndex = $A
$iType = $Global_DisplayPassword[$iIndex][1]
ExitLoop
EndIf
Next
If $iIndex = -1 Then
If $Global_DisplayPassword[0][0] <= UBound($Global_DisplayPassword, 1) + 1 Then
ReDim $Global_DisplayPassword[($Global_DisplayPassword[0][0] + 1) * 2][$Global_DisplayPassword[0][1]]
EndIf
$Global_DisplayPassword[0][0] += 1
$iIndex = $Global_DisplayPassword[0][0]
$Global_DisplayPassword[$iIndex][0] = $iControlID
$Global_DisplayPassword[$iIndex][1] = $iType
EndIf
Switch $iType
Case 0
$Global_DisplayPassword[$iIndex][1] = 1
Case 1
$bExStyle = 0x0020
$Global_DisplayPassword[$iIndex][1] = 0
EndSwitch
$sRead = GUICtrlRead($iControlID)
$aControlGetPos = ControlGetPos($hHandle, "", $iControlID)
GUICtrlDelete($iControlID)
If $iTab <> -1 Then
GUISwitch($hHandle, $iTab)
EndIf
$iControlID = GUICtrlCreateInput("", $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], $bExStyle)
If $iTab <> -1 Then
GUICtrlCreateTabItem("")
GUISwitch($hHandle)
EndIf
GUICtrlSetData($iControlID, $sRead)
Return $Global_DisplayPassword[$iIndex][1]
EndFunc ;==>_DisplayPassword