Jump to content

Reading Tabs?


Rawox
 Share

Recommended Posts

  • Moderators

Rawox,

There appears to be no simple way of changing the $ES_PASSWORD style dynamically using GUICtrlSetStyle. The Help file for GUICtrlSetStyle does warn: "Some styles cannot be changed dynamically" - this appears to be one of them. So we have to do it the hard way:

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

GUICreate("Test", 400, 400)

 $PINInput1 = GUICtrlCreateInput ( "",  10, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
 $PINInput2 = GUICtrlCreateInput ( "", 110, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
 $PINInput3 = GUICtrlCreateInput ( "", 210, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
 $PINInput4 = GUICtrlCreateInput ( "", 310, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
 For $i = $PINInput1 To $PINInput4
     GUICtrlSetLimit ( $i, 4) 
 Next

$PINHideShowButton = GUICtrlCreateButton ( "Show", 140, 145, 120, 25 )

GUISetState()

$HideShowData = False

While 1

    Switch GUIGetMsg()
        Case -3
            Exit
        Case $PINHideShowButton
            $iCount = 1
            If $HideShowData = False Then
                GUICtrlSetData ( $PINHideShowButton, "Hide" )
                For $i = $PINInput1 To $PINInput4
                    $temp = GUICtrlRead($i)
                    GUICtrlDelete($i)
                    $CID = GUICtrlCreateInput ( "", ($iCount*100)-90, 112, 90, 22, $ES_CENTER )
                    GUICtrlSetData(-1, $temp)
                    Assign(Eval("PINInput" & $i), $CID)
                    $iCount += 1
                Next
                $HideShowData = True
            Else
                GUICtrlSetData ( $PINHideShowButton, "Show" )
                For $i = $PINInput1 To $PINInput4
                    $temp = GUICtrlRead($i)
                    GUICtrlDelete($i)
                    $CID = GUICtrlCreateInput ( "", ($iCount*100)-90, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
                    GUICtrlSetData(-1, $temp)
                    Assign(Eval("PINInput" & $i), $CID)
                    $iCount += 1
                Next
                $HideShowData = False
            EndIf
    EndSwitch

WEnd

You will see that the script reads the input, then deletes it and immediately recreates another with the same content but the correct style for the occasion. The use of Assign makes sure you can keep the same variables in the For...Next loop each time - which is pretty crucial to the whole thing!

If you want the inputs to move automatically to the next when all 4 characters have been entered, have a look at this post from earlier today.

I trust this does what you want.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Rawox,

There appears to be no simple way of changing the $ES_PASSWORD style dynamically using GUICtrlSetStyle. The Help file for GUICtrlSetStyle does warn: "Some styles cannot be changed dynamically" - this appears to be one of them. So we have to do it the hard way:

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

GUICreate("Test", 400, 400)

 $PINInput1 = GUICtrlCreateInput ( "",  10, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
 $PINInput2 = GUICtrlCreateInput ( "", 110, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
 $PINInput3 = GUICtrlCreateInput ( "", 210, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
 $PINInput4 = GUICtrlCreateInput ( "", 310, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
 For $i = $PINInput1 To $PINInput4
     GUICtrlSetLimit ( $i, 4) 
 Next

$PINHideShowButton = GUICtrlCreateButton ( "Show", 140, 145, 120, 25 )

GUISetState()

$HideShowData = False

While 1

    Switch GUIGetMsg()
        Case -3
            Exit
        Case $PINHideShowButton
            $iCount = 1
            If $HideShowData = False Then
                GUICtrlSetData ( $PINHideShowButton, "Hide" )
                For $i = $PINInput1 To $PINInput4
                    $temp = GUICtrlRead($i)
                    GUICtrlDelete($i)
                    $CID = GUICtrlCreateInput ( "", ($iCount*100)-90, 112, 90, 22, $ES_CENTER )
                    GUICtrlSetData(-1, $temp)
                    Assign(Eval("PINInput" & $i), $CID)
                    $iCount += 1
                Next
                $HideShowData = True
            Else
                GUICtrlSetData ( $PINHideShowButton, "Show" )
                For $i = $PINInput1 To $PINInput4
                    $temp = GUICtrlRead($i)
                    GUICtrlDelete($i)
                    $CID = GUICtrlCreateInput ( "", ($iCount*100)-90, 112, 90, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
                    GUICtrlSetData(-1, $temp)
                    Assign(Eval("PINInput" & $i), $CID)
                    $iCount += 1
                Next
                $HideShowData = False
            EndIf
    EndSwitch

WEnd

You will see that the script reads the input, then deletes it and immediately recreates another with the same content but the correct style for the occasion. The use of Assign makes sure you can keep the same variables in the For...Next loop each time - which is pretty crucial to the whole thing!

If you want the inputs to move automatically to the next when all 4 characters have been entered, have a look at this post from earlier today.

I trust this does what you want.

M23

Damn! Your Good!

And yes, I already asked it again but I already tried to copy that thing but I couldn't get it to work

Thnx! Melba23

Link to comment
Share on other sites

Does anyone know how to do this?? I want to read four Inputs of a GUI and then open notepad and then write them down there...

Anyone??

$ReadPINInput1 = GUICtrlRead ( $PINInput1 )
        $ReadPINInput2 = GUICtrlRead ( $PINInput2 )
        $ReadPINInput3 = GUICtrlRead ( $PINInput3 )
        $ReadPINInput4 = GUICtrlRead ( $PINInput4 )
        Run ( "notepad.exe", "", @SW_MAXIMIZE )
        WinWaitActive ( "Kladblok" )
        Send ( [$ReadPINInput1] )
        Send ( [$ReadPINInput2] )
        Send ( [$ReadPINInput3]  )
        Send ( [$ReadPINInput4]  )
Link to comment
Share on other sites

Something like

#include <GUIConstants.au3>

$GUI = GUICreate("Example...", 100, 70)
$Input = GUICtrlCreateInput("", 10, 10, 80, 20)
$Button = GUICtrlCreateButton("...", 10, 40, 80)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button
        $Read = GUICtrlRead($Input)
        Run("notepad.exe")
        WinWaitActive("[CLASS:Notepad]")
        Send($Read)
    EndSelect
WEnd

?

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

That worked!

Two questions...

1.How can I disable a button? (That it's greyed out)

2.Is it possible to do an action if another tab is clicked??

Tabs: (There are a total of 5 tabs)

$CreateTab = GUICtrlCreateTab ( 0, 0, 400, 250 )
        $Tab1 = GUICtrlCreateTabItem ( "Random" )

What I tried:

Case $msg = $Tab1
        MsgBox ( 0, "lol", "lol" )

Anything Possible??

Edited by Rawox
Link to comment
Share on other sites

Could someone please post examples?? I do understand what AdmiralAlkex said but don't know how to do it...

They are both in the helpfile. Open any script in SciTE and press on the menu "Help>Help" or the key "F1" and read about GuiCtrlCreateTabitem() and GuiCtrlRead().
Link to comment
Share on other sites

Why can't you just give me some examples?

I use autoit for more then a year now and I already have read the help file!

If you can't understand the examples in the helpfile then why would you understand what someone on the forum writes? You can't be serious here.....
Link to comment
Share on other sites

Ok! I tried it :unsure:

But...

I couldn't get it to work :P

$ReadTest = GUICtrlRead ( $AboutTab, 0 )
        MsgBox ( 0, "Information", "Tab is:" & $ReadTest )

Anyone??

Edited by Rawox
Link to comment
Share on other sites

Ok! I tried it :unsure:

But...

I couldn't get it to work :P

$ReadTest = GUICtrlRead ( $AboutTab, 0 )
        MsgBox ( 0, "Information", "Tab is:" & $ReadTest )

Anyone??

Since you can't understand the example in helpfile that uses MessageLoop mode, here is an example for OnEvent mode

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

Global $sAdvParam = 1

GUICreate("blabla", 300, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")

$hTab = GUICtrlCreateTab(5, 5, 150, 150)
GUICtrlSetOnEvent(-1, "_Bajs")
GUICtrlCreateTabItem("text1")
GUICtrlCreateTabItem("text2")
GUICtrlCreateTabItem("")

$hButt = GUICtrlCreateButton("Advanced mode is on, press to turn off", 5, 160, 200, 25)
GUICtrlSetOnEvent(-1, "_AdvMode")

GUISetState()

While 1
    Sleep(999999)
WEnd

Func _Bajs()
    If $sAdvParam = 1 Then
        ToolTip("You pressed on controlID: " & GUICtrlRead($hTab, $sAdvParam))
    ElseIf $sAdvParam = 0 Then
        ToolTip("You pressed on index: " & GUICtrlRead($hTab, $sAdvParam))
    EndIf
EndFunc

Func _AdvMode()
    If $sAdvParam = 1 Then
        $sAdvParam = 0
        GUICtrlSetData($hButt, "Advanced mode is off, press to turn on")
    ElseIf $sAdvParam = 0 Then
        $sAdvParam = 1
        GUICtrlSetData($hButt, "Advanced mode is on, press to turn off")
    EndIf
EndFunc

Func _Close()
    Exit
EndFunc
Edited by AdmiralAlkex
Link to comment
Share on other sites

Ok! Thanks! I'm starting to understand it :unsure:

But... I can't make it work with my script...

The Tabs:

$Tab1 = GUICtrlCreateTabItem ( "Random" )
$Tab2 = GUICtrlCreateTabItem ( "Email" )
$Tab3 = GUICtrlCreateTabItem ( "Word" )
$Tab4 = GUICtrlCreateTabItem ( "4 PINS" )
$AboutTab = GUICtrlCreateTabItem ( "About" )

I would like an example that pops up a msgbox when a tab is selected...

Dammn,, I sound stupid, don't I?

Sorry :P

Link to comment
Share on other sites

You have been given examples on both OnEvent Mode and MessageLoop Mode, if you still can't get it to work then I don't know how to help you. Can you post your script?

Link to comment
Share on other sites

#include<GuiTab.au3>

Then see _GUICtrlTab_GetItemText() in the help file.

User Defined Functions>>Tab Management

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

This is my GUI:

Func CreateGUI()
    Local $Small, $Capital, $Number, $Special
    
    GUICreate ( "RaGen", 400, 235 )
        $CreateTab = GUICtrlCreateTab ( 0, 0, 400, 250 )
        $Tab1 = GUICtrlCreateTabItem ( "Random" )
            $GenerateButton = GUICtrlCreateButton ( "Generate", 310, 169, 80, 24 )
            $Input1 = GUICtrlCreateInput ( "", 11, 170, 299, 22 )
            $QuitButton = GUICtrlCreateButton ( "Quit", 270, 200, 120, 25 )
            $DeleteButton = GUICtrlCreateButton ( "Clear", 10, 200, 120, 25 )
            $ResetButton = GUICtrlCreateButton ( "Reset", 140, 200, 120, 25 )
            $Small = GUICtrlCreateCheckbox ( "Small Characters", 30, 48, 110, 20 )
            $Capital = GUICtrlCreateCheckbox ( "Capital Characters", 30, 65, 110, 20 )
            $Number = GUICtrlCreateCheckbox ( "Numbers (0-9)", 200, 48, 110, 20 )
            $Special = GUICtrlCreateCheckbox ( "Special Symbols", 200, 65, 110, 20 )
            $Char1 = GUICtrlCreateRadio ( "1", 30, 118, 40, 20 )
            $Char2 = GUICtrlCreateRadio ( "2", 100, 118, 40, 20 )
            $Char3 = GUICtrlCreateRadio ( "3", 170, 118, 40, 20 )
            $Char4 = GUICtrlCreateRadio ( "4", 240, 118, 40, 20 )
            $Char5 = GUICtrlCreateRadio ( "5", 310, 118, 40, 20 )
            $Char6 = GUICtrlCreateRadio ( "6", 30, 135, 40, 20 )
            $Char7 = GUICtrlCreateRadio ( "7", 100, 135, 40, 20 )
            $Char8 = GUICtrlCreateRadio ( "8", 170, 135, 40, 20 )
            $Char9 = GUICtrlCreateRadio ( "9", 240, 135, 40, 20 )
            $Char10 = GUICtrlCreateRadio ( "10", 310, 135, 40, 20 )
            GUICtrlCreateGroup ( "Includes", 10, 30, 380, 60 )
            GUICtrlCreateGroup ( "Number of Characters", 10, 100, 380, 60 )
            GUICtrlSetState ( $Small, $GUI_CHECKED )
            GUICtrlSetState ( $Char8, $GUI_CHECKED )
            GUICtrlSetState ( $Input1, $GUI_FOCUS )
            
        $Tab2 = GUICtrlCreateTabItem ( "Email" )
            $EGenerateButton = GUICtrlCreateButton ( "Generate", 300, 53, 80, 24 )
            $EGenerateButton2 = GUICtrlCreateButton ( "Generate", 300, 123, 80, 24 )
            $ClearButton = GUICtrlCreateButton ( "Clear", 310, 169, 80, 24 )
            $EInput1 = GUICtrlCreateInput ( "", 21, 54, 279, 22 )
            $EInput2 = GUICtrlCreateInput ( "", 21, 124, 120, 22 )
            $EInput3 = GUICtrlCreateInput ( "", 55, 170, 250, 22 )
            GUICtrlCreateLabel ( "@", 145, 128 )
            GUICtrlCreateLabel ( "Copied:", 10, 173 )
            $EQuitButton = GUICtrlCreateButton ( "Quit", 270, 200, 120, 25 )
            GUICtrlCreateGroup ( "Full Address", 10, 30, 380, 60 )
            GUICtrlCreateGroup ( "Name Only", 10, 100, 380, 60 )
            GUICtrlSetState ( $EInput1, $GUI_FOCUS )
            $ECombo1 = GUICtrlCreateCombo ( "gmail", 161, 125, 70, 22 )
            GUICtrlSetData ( -1, "hotmail|yahoo", "GMail" )
            $ECombo2 = GUICtrlCreateCombo ( ".com", 235, 125, 60, 22 )
            GUICtrlSetData ( -1, ".co.uk|.nl", ".com" )
            $Copy1Button = GUICtrlCreateButton ( "Copy Address 1", 10, 200, 120, 25 )
            $Copy2Button = GUICtrlCreateButton ( "Copy Address 2", 140, 200, 120, 25 )
        
        $Tab3 = GUICtrlCreateTabItem ( "Word" )
            $WGenerateButton = GUICtrlCreateButton ( "Generate", 310, 169, 80, 24 )
            $WInput1 = GUICtrlCreateInput ( "", 11, 170, 299, 22 )
            $WQuitButton = GUICtrlCreateButton ( "Quit", 270, 200, 120, 25 )
            $WDeleteButton = GUICtrlCreateButton ( "Clear", 10, 200, 120, 25 )
            $WResetButton = GUICtrlCreateButton ( "Reset", 140, 200, 120, 25 )
            $WWords = GUICtrlCreateCheckbox ( "Random Words", 30, 48, 110, 20 )
            $WNames = GUICtrlCreateCheckbox ( "Random Names", 30, 65, 110, 20 )
            $WCountries = GUICtrlCreateCheckbox ( "Random Countries", 200, 48, 110, 20 )
            $WNumbers = GUICtrlCreateCheckbox ( "Random Numbers", 200, 65, 110, 20 )
            $WChar1 = GUICtrlCreateRadio ( "1 Word", 30, 118, 60, 20 )
            $WChar2 = GUICtrlCreateRadio ( "2 Words", 150, 118, 60, 20 )
            $WChar3 = GUICtrlCreateRadio ( "3 Words", 270, 118, 60, 20 )
            $WChar4 = GUICtrlCreateRadio ( "4 Words", 30, 135, 60, 20 )
            $WChar5 = GUICtrlCreateRadio ( "5 Words", 150, 135, 60, 20 )
            $WChar6 = GUICtrlCreateRadio ( "6 Words", 270, 135, 60, 20 )
            GUICtrlCreateGroup ( "Includes", 10, 30, 380, 60 )
            GUICtrlCreateGroup ( "Number of Words", 10, 100, 380, 60 )
            GUICtrlSetState ( $WWords, $GUI_CHECKED )
            GUICtrlSetState ( $WChar3, $GUI_CHECKED )
            GUICtrlSetState ( $WInput1, $GUI_FOCUS )
        
        $Tab4 = GUICtrlCreateTabItem ( "4 PINS" )
            GUICtrlCreateGroup( "About", 10, 30, 380, 75 )
            GUICtrlCreateLabel ( "This PIN generator generates a safe PIN. The PIN will not be stored to your", 20, 50 )
            GUICtrlCreateLabel ( "Computer until you click the 'Save' button. You can Hide/Show the PIN if", 20, 67 )
            GUICtrlCreateLabel ( "You are in a public area so no one cas see it.", 20, 84 )
            $PINInput1 = GUICtrlCreateInput ( "", 11, 112, 80, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
            $PINInput2 = GUICtrlCreateInput ( "", 111, 112, 80, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
            $PINInput3 = GUICtrlCreateInput ( "", 210, 112, 80, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
            $PINInput4 = GUICtrlCreateInput ( "", 309, 112, 80, 22, BitOr($ES_CENTER, $ES_PASSWORD) )
            GUICtrlSetLimit ( $PINInput1, 4, 4 )
            GUICtrlSetLimit ( $PINInput2, 4, 4 )
            GUICtrlSetLimit ( $PINInput3, 4, 4 )
            GUICtrlSetLimit ( $PINInput4, 4, 4 )
            $PINGenerateButton = GUICtrlCreateButton ( "Generate", 10, 145, 120, 25 )
            $PINEditButton = GUICtrlCreateButton ( "Edit", 270, 145, 120, 25 )
            $PINHideShowButton = GUICtrlCreateButton ( "Show", 140, 145, 120, 25 )
            $PINQuitButton = GUICtrlCreateButton ( "Quit", 270, 180, 120, 25 )
            $PINDeleteButton = GUICtrlCreateButton ( "Clear", 10, 180, 120, 25 )
            $PINHelpButton = GUICtrlCreateButton ( "Help", 140, 180, 120, 25 )

        $AboutTab = GUICtrlCreateTabItem ( "About" )
            GUICtrlCreateGroup ( "About", 10, 30, 380, 60 )
            GUICtrlCreateLabel ( "RaGen is Generator that generates random things, it was made to learn the", 20, 50 )
            GUICtrlCreateLabel ( "AutoIt V3 language by Rawox. ", 20, 67 )
            GUICtrlCreateGroup ( "Credits", 10, 95, 380, 60 )
            GUICtrlCreateLabel ( "Made by (Author):", 20, 115 )
            GUICtrlCreateLabel ( "Got help from:", 20, 132 )
            GUICtrlCreateLabel ( "Rawox", 110, 115 )
            GUICtrlCreateLabel ( "AutoIt Forums", 110, 132 )
            $AboutMyDeviantart = GUICtrlCreateButton ( "My DeviantArt", 210, 119, 170, 25 )
            $AboutHelpFile = GUICtrlCreateButton ( "Help File", 270, 184, 110, 25 )
            GUICtrlCreateGroup ( "Help", 10, 160, 380, 60 )
            GUICtrlCreateLabel ( "If you don't understand anything please use the", 20, 180 )
            GUICtrlCreateLabel ( "Help file, click the button at the right to open it.", 20, 197 )
        
    GUISetState ()
Edited by Rawox
Link to comment
Share on other sites

_GUICtrlTab_GetItemText($CreateTab, GUICtrlRead($CreateTab))

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...