Sign in to follow this  
Followers 0
Kaso

having problems manipulating controls in a GUI

11 posts in this topic

Here is a script I wrote that works fine as a script but I would like to have it in a GUI as I want to add some text and change fonts and so on. I can not get the manipulation of the input to work in the GUI.

A second issue, I'd like to able to have the password update without having to press the go button. Not a big deal if it can not be done, i'll leave it there and figure out how to use the enter hotkey to display the password control.

#include <GUIConstants.au3>

GUICreate("Admin Logon Credentials...") ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)    ; will display an empty dialog box
$id1 = GUICtrlCreateInput("",27,30,100)
GUICtrlSetTip($id1,"User ID")
GUICtrlSetState($id1,$GUI_FOCUS)
$btn1 = GUICtrlCreateButton("Go!",130,30,25,21)

Func _StringReverse($sString)
  ;==============================================
  ; Local Constant/Variable Declaration Section
  ;==============================================
   Local $sReverse
   Local $iCount

   If StringLen($sString) >= 1 Then
      For $iCount = 1 To StringLen($sString)
         $sReverse = StringMid($sString, $iCount, 1) & $sReverse
      Next

      Return $sReverse
   Else
      SetError(1)
      Return ""
   EndIf
EndFunc  ;==>_StringReverse
#cs
***********************************************************************************************
AutoIt Version: 3.1.0
Author: CodeMaster Rapture

Script Function:
    Remove ASCII characters from a string.

Usage:
    StringStrip( String, Chars [,Occurrances, Case Sensitive])
Parameters:
    String ------------------ The string you want stripped.
    Chars ------------------- The Characters you want removed. I.E. "aAz34!@4"
    Occurrances ------------- How many occurrances of each character to remove. Default is
    ------------------------- 0 which removes all. If a negative number is entered it is
    ------------------------- treated as 0.
    Case Sensitive ---------- 1 will remove only the case of the letters the user specifies
    ------------------------- 0 remove both lowercase and uppercase letters. 0 is default.
***********************************************************************************************
#ce

Func StringStrip($String, $Chars, $Count = 0, $CaseSensitive = 0)

;Error Checking
    If ($String == "") Then      Return $String
    If ($Chars == "") Then          Return $String
    If NOT (IsInt($CaseSensitive)) Then $CaseSensitive = Number($CaseSensitive);Returns 0 or the number
    If ($CaseSensitive > 1) Then        $CaseSensitive = 1
    If NOT (IsInt($Count)) Then     $Count = Number($Count);Returns 0 or the number

;Let's make this into an array for looping
    $Chars = StringSplit($Chars,"")

    For $loop = 1 To $Chars[0]
        $String = StringReplace($String, $Chars[$loop],"", $Count, $CaseSensitive)
    Next

    Return $String
EndFunc

$id = StringLower($id1)
$idstrip = StringStrip($id, "abcdefghijklmnopqrstuvwxyz!@#$%^&*()[]{}\|`~';:?><.,")
$array = StringSplit($idstrip, "")

If $array[0] = 6 Then
    $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6]
ElseIf $array[0] = 5 Then
    $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5]
ElseIf $array[0] = 4 Then
    $arrayadd = $array[1] + $array[2] + $array[3] + $array[4]
ElseIf $array[0] = 3 Then
    $arrayadd = $array[1] + $array[2] + $array[3]
ElseIf $array[0] = 2 Then
    $arrayadd = $array[1] + $array[2]
ElseIf $array[0] = 1 Then
    $arrayadd = $array[1]
ElseIf $array[0] = 0 Then
    Exit
EndIf

$arrayid = StringSplit($id, "")
$idprecap = $arrayid[1]
$idcap = StringUpper($idprecap)
$arrayrev = _StringReverse($arrayadd)
$adminpass = $idcap & StringTrimLeft($id, 1) & $arrayrev


While 1
    $msg = GUIGetMsg()
    if $msg = $btn1 Then GUICtrlCreateInput(GUICtrlRead($adminpass),160,30,100,"",$ES_READONLY) 
        
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Share this post


Link to post
Share on other sites



getting headach trying to sort thru this code, so just decided to show how easy to update as input changes

#include <GUIConstants.au3>

GUICreate("Admin Logon Credentials..."); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)    ; will display an empty dialog box
$id1 = GUICtrlCreateInput("", 27, 30, 100)
$input_pass = GUICtrlCreateInput("", 160, 30, 100, "", $ES_READONLY)
GUICtrlSetTip($id1, "User ID")
GUICtrlSetState($id1, $GUI_FOCUS)
$btn1 = GUICtrlCreateButton("Go!", 130, 30, 25, 21)

Func _StringReverse($sString)
  ;==============================================
  ; Local Constant/Variable Declaration Section
  ;==============================================
   Local $sReverse
   Local $iCount
   
   If StringLen($sString) >= 1 Then
      For $iCount = 1 To StringLen($sString)
         $sReverse = StringMid($sString, $iCount, 1) & $sReverse
      Next
      
      Return $sReverse
   Else
      SetError(1)
      Return ""
   EndIf
EndFunc  ;==>_StringReverse
#cs
   ***********************************************************************************************
   AutoIt Version: 3.1.0
   Author: CodeMaster Rapture
   
   Script Function:
   Remove ASCII characters from a string.
   
   Usage:
   StringStrip( String, Chars [,Occurrances, Case Sensitive])
   Parameters:
   String ------------------ The string you want stripped.
   Chars ------------------- The Characters you want removed. I.E. "[email="aAz34!@4"]aAz34!@4[/email]"
   Occurrances ------------- How many occurrances of each character to remove. Default is
   ------------------------- 0 which removes all. If a negative number is entered it is
   ------------------------- treated as 0.
   Case Sensitive ---------- 1 will remove only the case of the letters the user specifies
   ------------------------- 0 remove both lowercase and uppercase letters. 0 is default.
   ***********************************************************************************************
#ce

Func StringStrip($String, $Chars, $Count = 0, $CaseSensitive = 0)
   
  ;Error Checking
   If ($String == "") Then Return $String
   If ($Chars == "") Then Return $String
   If NOT (IsInt($CaseSensitive)) Then $CaseSensitive = Number($CaseSensitive);Returns 0 or the number
   If ($CaseSensitive > 1) Then $CaseSensitive = 1
   If NOT (IsInt($Count)) Then $Count = Number($Count);Returns 0 or the number
   
  ;Let's make this into an array for looping
   $Chars = StringSplit($Chars, "")
   
   For $loop = 1 To $Chars[0]
      $String = StringReplace($String, $Chars[$loop], "", $Count, $CaseSensitive)
   Next
   
   Return $String
EndFunc  ;==>StringStrip

$id = StringLower($id1)
$idstrip = StringStrip($id, "[email="abcdefghijklmnopqrstuvwxyz!@#$%^&*()[]{}\|`~"]abcdefghijklmnopqrstuvwxyz!@#$%^&*()[]{}\|`~'[/email];:?><.,")
$array = StringSplit($idstrip, "")

If $array[0] = 6 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6]
ElseIf $array[0] = 5 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5]
ElseIf $array[0] = 4 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4]
ElseIf $array[0] = 3 Then
   $arrayadd = $array[1] + $array[2] + $array[3]
ElseIf $array[0] = 2 Then
   $arrayadd = $array[1] + $array[2]
ElseIf $array[0] = 1 Then
   $arrayadd = $array[1]
ElseIf $array[0] = 0 Then
   Exit
EndIf

$arrayid = StringSplit($id, "")
$idprecap = $arrayid[1]
$idcap = StringUpper($idprecap)
$arrayrev = _StringReverse($arrayadd)
$adminpass = $idcap & StringTrimLeft($id, 1) & $arrayrev

$tmp_pass = ""
While 1
   $msg = GUIGetMsg()
 If $tmp_pass <> GUICtrlRead($id1) Then
  $tmp_pass = GUICtrlRead($id1)
  GUICtrlSetData($input_pass,GUICtrlRead($id1))
 EndIf
  
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thank you for the help on the constant refreshing. I like that. Thats what I was hoping to have for the second part. Now I just need to figure how to manipulate the first input box and spit out the password to the second. for example the user name could be something like this

a123456 and from the script it takes the username, strips anything not a number, adds the numbers, reverses it and attaches it to the end of the username with the first letter capitalized. like this

Username: a123456 Password: A12345612

I don't need help with the calculation, just an explanation as to why when I try something as simple as below. If I was to use the stringlower func in a script it would make all the letters lowercase, but it doesn't do it in the GUI. Of course I have more funcs to run on the $id1 but this is for simplicity. Keep in mind that the code above is rough. its not organized for read, my apologies.

#include <GUIConstants.au3>

GUICreate("Admin Logon Credentials..."); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)   ; will display an empty dialog box
$id1 = GUICtrlCreateInput("", 27, 30, 100)
$input_pass = GUICtrlCreateInput("", 160, 30, 100, "", $ES_READONLY)
GUICtrlSetTip($id1, "User ID")
GUICtrlSetState($id1, $GUI_FOCUS)

$id = StringLower($id1)

$tmp_pass = ""
While 1
   $msg = GUIGetMsg()
If $tmp_pass <> GUICtrlRead($id1) Then
  $tmp_pass = GUICtrlRead($id1)
  GUICtrlSetData($input_pass,GUICtrlRead($id))
EndIf
  
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Share this post


Link to post
Share on other sites

don't forget the read on the control

#include <GUIConstants.au3>

GUICreate("Admin Logon Credentials..."); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)   ; will display an empty dialog box
$id1 = GUICtrlCreateInput("", 27, 30, 100)
$input_pass = GUICtrlCreateInput("", 160, 30, 100, "", $ES_READONLY)
GUICtrlSetTip($id1, "User ID")
GUICtrlSetState($id1, $GUI_FOCUS)


$tmp_pass = ""
While 1
   $msg = GUIGetMsg()
If $tmp_pass <> StringLower(GUICtrlRead($id1)) Then
  $tmp_pass = StringLower(GUICtrlRead($id1))
  GUICtrlSetData($input_pass,$tmp_pass)
EndIf
  
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

OK I'm piecing it togther. I now have a problem with arrays. In my script the username input gets split into an array so I can maniplute the numbers. For some reason I can not get the same results when using it in the gui. Heres the simplified GUI. what the script would have done is add the numbers together from the input. and place it in the $tmp_pass. However if you see that is not what happens.

#include <GUIConstants.au3>

GUICreate("Admin Logon Credentials..."); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)  ; will display an empty dialog box
$id1 = GUICtrlCreateInput("", 27, 30, 100)
$input_pass = GUICtrlCreateInput("", 160, 30, 100, "", $ES_READONLY)
GUICtrlSetTip($id1, "User ID")
GUICtrlSetState($id1, $GUI_FOCUS)
Func _StringReverse($sString)
 ;==============================================
 ; Local Constant/Variable Declaration Section
 ;==============================================
   Local $sReverse
   Local $iCount
   
   If StringLen($sString) >= 1 Then
      For $iCount = 1 To StringLen($sString)
         $sReverse = StringMid($sString, $iCount, 1) & $sReverse
      Next
      
      Return $sReverse
   Else
      SetError(1)
      Return ""
   EndIf
EndFunc ;==>_StringReverSetError()
Func StringStrip($String, $Chars, $Count = 0, $CaseSensitive = 0)
   
 ;Error Checking
   If ($String == "") Then Return $String
   If ($Chars == "") Then Return $String
   If NOT (IsInt($CaseSensitive)) Then $CaseSensitive = Number($CaseSensitive);Returns 0 or the number
   If ($CaseSensitive > 1) Then $CaseSensitive = 1
   If NOT (IsInt($Count)) Then $Count = Number($Count);Returns 0 or the number
   
 ;Let's make this into an array for looping
   $Chars = StringSplit($Chars, "")
   
   For $loop = 1 To $Chars[0]
      $String = StringReplace($String, $Chars[$loop], "", $Count, $CaseSensitive)
   Next
   
   Return $String
EndFunc ;==>StringStrip

$tmp_pass = ""
While 1
   $msg = GUIGetMsg()
$array = StringSplit($id1, "")
If $array[0] = 6 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6]
ElseIf $array[0] = 5 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5]
ElseIf $array[0] = 4 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4]
ElseIf $array[0] = 3 Then
   $arrayadd = $array[1] + $array[2] + $array[3]
ElseIf $array[0] = 2 Then
   $arrayadd = $array[1] + $array[2]
ElseIf $array[0] = 1 Then
   $arrayadd = $array[1]
EndIf

$tmp_pass = guictrlread($arrayadd)

GUICtrlSetData($input_pass,$tmp_pass)
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Share this post


Link to post
Share on other sites

Again, don't forget your read when working with the control.

$array = StringSplit($id1, "")

should be

$array = StringSplit(GuiCtrlRead($id1), "")


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

If BitAND(GUICtrlRead($Checkbox_1), $GUI_CHECKED) = $GUI_CHECKED Then
 MouseClick("right", 503, 330, 12)
 WinGetText("[System]Insufficient mana. You cannot cast that spell!")
 MouseClick("left", 688, 664, 1)
 Sleep(1200)
 MouseClick("right", 228, 729)
EndIf

change to:

If BitAND(GUICtrlRead($Checkbox_1), $GUI_CHECKED) = $GUI_CHECKED Then
 $ClickIt = 1
 While $ClickIt
  MouseClick("right", 503, 330)
  If WinGetText("[System]Insufficient mana. You cannot cast that spell!") Then ExitLoop
  MouseClick("left", 688, 664, 1)
  Sleep(1200)
  MouseClick("right", 228, 729)
 WEnd
 $ClickIt = 0
EndIf

For F7 to stop it

you'll need to set the HotKey

i.e.

HotKeySet("{F7}","_StopIt")

Func _StopIt()
   $ClickIt = 0
EndFun

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Again, don't forget your read when working with the control.

$array = StringSplit($id1, "")

should be

$array = StringSplit(GuiCtrlRead($id1), "")

Do I need to use the Read on the if part aswell?

this is what I used

$array = StringSplit(GUICtrlRead($id1), "")
If GUICtrlRead($array[0]) = 6 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2]) + GUICtrlRead($array[3]) + GUICtrlRead($array[4]) + GUICtrlRead($array[5]) + GUICtrlRead($array[6])
ElseIf GUICtrlRead($array[0]) = 5 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2]) + GUICtrlRead($array[3]) + GUICtrlRead($array[4]) + GUICtrlRead($array[5])
ElseIf GUICtrlRead($array[0]) = 4 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2]) + GUICtrlRead($array[3]) + GUICtrlRead($array[4])
ElseIf GUICtrlRead($array[0]) = 3 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2]) + GUICtrlRead($array[3])
ElseIf GUICtrlRead($array[0]) = 2 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2])
ElseIf GUICtrlRead($array[0]) = 1 Then
   $arrayadd = GUICtrlRead($array[1])
ElseIf GUICtrlRead($array[0]) = 0 Then
   $arrayadd = 1
EndIf

Share this post


Link to post
Share on other sites

Do I need to use the Read on the if part aswell?

this is what I used

$array = StringSplit(GUICtrlRead($id1), "")
If GUICtrlRead($array[0]) = 6 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2]) + GUICtrlRead($array[3]) + GUICtrlRead($array[4]) + GUICtrlRead($array[5]) + GUICtrlRead($array[6])
ElseIf GUICtrlRead($array[0]) = 5 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2]) + GUICtrlRead($array[3]) + GUICtrlRead($array[4]) + GUICtrlRead($array[5])
ElseIf GUICtrlRead($array[0]) = 4 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2]) + GUICtrlRead($array[3]) + GUICtrlRead($array[4])
ElseIf GUICtrlRead($array[0]) = 3 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2]) + GUICtrlRead($array[3])
ElseIf GUICtrlRead($array[0]) = 2 Then
   $arrayadd = GUICtrlRead($array[1]) + GUICtrlRead($array[2])
ElseIf GUICtrlRead($array[0]) = 1 Then
   $arrayadd = GUICtrlRead($array[1])
ElseIf GUICtrlRead($array[0]) = 0 Then
   $arrayadd = 1
EndIf

No, it's not the control id, $id1 is the control (control id)


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

I got my script totally done except that it does flicker because of the constant reading if $id1. I've read several posts about it but could not figure out out to fit it in mine. I know gafrost you had posted one one of the threads I read but I could not figure how to put it in.

Any help would be appreciated

#include <GUIConstants.au3>
; Default values for main gui
$title = "GUI"
$width = 420
$height = 100
$left = -1
$top = -1

GUICreate($title,$width,$height); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)  ; will display an empty dialog box
$id1 = GUICtrlCreateInput("",5,30, 100, 25)
GUICtrlSetTip($id1, "User ID")
GUICtrlSetState($id1, $GUI_FOCUS)
GUICtrlSetFont ($id1, 14)
$input_pass = GUICtrlCreateInput("", 260, 30, 151,25, $ES_READONLY)
GUICtrlSetFont ($input_pass, 14)
GUICtrlSetTip($input_pass, "Password")
$user = GUICtrlCreateLabel("Windows Id:",5,7,100)
GUICtrlSetFont ($user, 12,700,2)
$pass = GUICtrlCreateLabel("Password:",260,7,100)
GUICtrlSetFont ($pass, 12,700,2)
Func _StringReverse($sString)
 ;==============================================
 ; Local Constant/Variable Declaration Section
 ;==============================================
   Local $sReverse
   Local $iCount
   
   If StringLen($sString) >= 1 Then
      For $iCount = 1 To StringLen($sString)
         $sReverse = StringMid($sString, $iCount, 1) & $sReverse
      Next
      
      Return $sReverse
   Else
      SetError(1)
      Return ""
   EndIf
EndFunc ;==>_StringReverSetError()
Func StringStrip($String, $Chars, $Count = 0, $CaseSensitive = 0)
   
 ;Error Checking
   If ($String == "") Then Return $String
   If ($Chars == "") Then Return $String
   If NOT (IsInt($CaseSensitive)) Then $CaseSensitive = Number($CaseSensitive);Returns 0 or the number
   If ($CaseSensitive > 1) Then $CaseSensitive = 1
   If NOT (IsInt($Count)) Then $Count = Number($Count);Returns 0 or the number
   
 ;Let's make this into an array for looping
   $Chars = StringSplit($Chars, "")
   
   For $loop = 1 To $Chars[0]
      $String = StringReplace($String, $Chars[$loop], "", $Count, $CaseSensitive)
   Next
   
   Return $String
EndFunc ;==>StringStrip

$tmp_pass = ""
While 1
$msg = GUIGetMsg()
$id = StringLower(GUICtrlRead($id1))
$idstrip = StringStrip($id, "abcdefghijklmnopqrstuvwxyz!@#$%^&*()[]{}\|`~';:?><.,")
$array = StringSplit($idstrip, "")
If $array[0] = 10 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6] + $array[7] + $array[8] + $array[9] + $array[10]
ElseIf $array[0] = 9 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6] + $array[7] + $array[8] + $array[9]
ElseIf $array[0] = 8 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6] + $array[7] + $array[8]
ElseIf $array[0] = 7 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6] + $array[7]
ElseIf $array[0] = 6 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6]
ElseIf $array[0] = 5 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5]
ElseIf $array[0] = 4 Then
   $arrayadd = $array[1] + $array[2] + $array[3] + $array[4]
ElseIf $array[0] = 3 Then
   $arrayadd = $array[1] + $array[2] + $array[3]
ElseIf $array[0] = 2 Then
   $arrayadd = $array[1] + $array[2]
ElseIf $array[0] = 1 Then
   $arrayadd = $array[1]
EndIf
If $idstrip <> "" then $arrayid = StringSplit($id, "")
If $idstrip <> "" then $idprecap = $arrayid[1] & $arrayid[2]
If $idstrip <> "" then $idcap = StringUpper($idprecap)
If $idstrip <> "" then $arrayrev = _StringReverse($arrayadd)
if $id1 > "" Then $tmp_pass = GUICtrlRead($id1)
If $idstrip <> "" then $tmp_pass = $idcap & StringTrimLeft($id, 2) & $arrayrev
GUICtrlSetData($input_pass,$tmp_pass)
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

#include <GUIConstants.au3>
; Default values for main gui
$title = "GUI"
$width = 420
$height = 100
$left = -1
$top = -1
$tmp_id = ""
GUICreate($title, $width, $height); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW) ; will display an empty dialog box
$id1 = GUICtrlCreateInput("", 5, 30, 100, 25)
GUICtrlSetTip($id1, "User ID")
GUICtrlSetState($id1, $GUI_FOCUS)
GUICtrlSetFont($id1, 14)
$input_pass = GUICtrlCreateInput("", 260, 30, 151, 25, $ES_READONLY)
GUICtrlSetFont($input_pass, 14)
GUICtrlSetTip($input_pass, "Password")
$user = GUICtrlCreateLabel("Windows Id:", 5, 7, 100)
GUICtrlSetFont($user, 12, 700, 2)
$pass = GUICtrlCreateLabel("Password:", 260, 7, 100)
GUICtrlSetFont($pass, 12, 700, 2)

$tmp_pass = ""
While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $tmp_id <> GUICtrlRead($id1) Then
        $tmp_id = GUICtrlRead($id1)
        $id = StringLower($tmp_id)
        $idstrip = StringStrip($id, "abcdefghijklmnopqrstuvwxyz!@#$%^&*()[]{}\|`~';:?><.,")
        $array = StringSplit($idstrip, "")
        If $array[0] = 10 Then
            $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6] + $array[7] + $array[8] + $array[9] + $array[10]
        ElseIf $array[0] = 9 Then
            $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6] + $array[7] + $array[8] + $array[9]
        ElseIf $array[0] = 8 Then
            $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6] + $array[7] + $array[8]
        ElseIf $array[0] = 7 Then
            $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6] + $array[7]
        ElseIf $array[0] = 6 Then
            $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5] + $array[6]
        ElseIf $array[0] = 5 Then
            $arrayadd = $array[1] + $array[2] + $array[3] + $array[4] + $array[5]
        ElseIf $array[0] = 4 Then
            $arrayadd = $array[1] + $array[2] + $array[3] + $array[4]
        ElseIf $array[0] = 3 Then
            $arrayadd = $array[1] + $array[2] + $array[3]
        ElseIf $array[0] = 2 Then
            $arrayadd = $array[1] + $array[2]
        ElseIf $array[0] = 1 Then
            $arrayadd = $array[1]
        EndIf
        If $idstrip <> "" Then $arrayid = StringSplit($id, "")
        If $idstrip <> "" Then $idprecap = $arrayid[1] & $arrayid[2]
        If $idstrip <> "" Then $idcap = StringUpper($idprecap)
        If $idstrip <> "" Then $arrayrev = _StringReverse($arrayadd)
        If $id1 > "" Then $tmp_pass = GUICtrlRead($id1)
        If $idstrip <> "" Then $tmp_pass = $idcap & StringTrimLeft($id, 2) & $arrayrev
        GUICtrlSetData($input_pass, $tmp_pass)
    EndIf
WEnd

Func _StringReverse($sString)
  ;==============================================
  ; Local Constant/Variable Declaration Section
  ;==============================================
   Local $sReverse
   Local $iCount
   
   If StringLen($sString) >= 1 Then
      For $iCount = 1 To StringLen($sString)
         $sReverse = StringMid($sString, $iCount, 1) & $sReverse
      Next
      
      Return $sReverse
   Else
      SetError(1)
      Return ""
   EndIf
EndFunc  ;==>_StringReverse
Func StringStrip($String, $Chars, $Count = 0, $CaseSensitive = 0)
   
  ;Error Checking
   If ($String == "") Then Return $String
   If ($Chars == "") Then Return $String
   If NOT (IsInt($CaseSensitive)) Then $CaseSensitive = Number($CaseSensitive);Returns 0 or the number
   If ($CaseSensitive > 1) Then $CaseSensitive = 1
   If NOT (IsInt($Count)) Then $Count = Number($Count);Returns 0 or the number
   
  ;Let's make this into an array for looping
   $Chars = StringSplit($Chars, "")
   
   For $loop = 1 To $Chars[0]
      $String = StringReplace($String, $Chars[$loop], "", $Count, $CaseSensitive)
   Next
   
   Return $String
EndFunc  ;==>StringStrip

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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