Jump to content
Sign in to follow this  
GraaF1337

GUICtrlCreateInput

Recommended Posts

I might be totally doing this wrong, but im kinda out of ideas here, so if one of you have an idea why this does as it does, i would be happy if you would leave a comment.

I've been trying to read the nummer or letters typed into a Input, but it seems that i either get the wrong result or nothing at all.

What i've tried so far:

 

Worked but got wrong input:

If i type in "12" in the InputBox it writes "4" in the "set.ini"

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


$Form1 = GUICreate("ASSET", 615, 438, 192, 124)
GUISetState(@SW_SHOW)



$AB =   GUICtrlCreateButton("Apply", "200", "200")
$AS =   GUICtrlCreateInput("", "150", "150", "200")

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

                    Case $AB
            IniWrite("C:\Users\Toft\Desktop\set.ini", "AS", "ASSET", $AS)

    EndSwitch
WEnd

Didn't work at all:

No matter what i type in the InputBox it wont write it into the Set.ini

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


$Form1 = GUICreate("ASSET", 615, 438, 192, 124)
GUISetState(@SW_SHOW)



$AB =   GUICtrlCreateButton("Apply", "200", "200")
$AS =   GUICtrlCreateInput("", "150", "150", "200")
$ASRead = GUICtrlRead($AS)

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

                    Case $AB
            IniWrite("C:\Users\Toft\Desktop\set.ini", "AS", "ASSET", $ASRead)

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
 Case $AB
$ASRead = GUICtrlRead($AS)
            IniWrite("set.ini", "AS", "ASSET", "hola")

 

Saludos

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("ASSET", 615, 438, 192, 124)
GUISetState(@SW_SHOW)

$AB =   GUICtrlCreateButton("Apply", "200", "200")
$AS =   GUICtrlCreateInput("", "150", "150", "200")
$ASRead = GUICtrlRead($AS)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    Case $AB
        ConsoleWrite(GUICtrlRead($AS)&@CRLF)

    EndSwitch
WEnd

You need to do guictrlread when the button is pressed, not while initializing

Share this post


Link to post
Share on other sites

 

 Case $AB
$ASRead = GUICtrlRead($AS)
            IniWrite("set.ini", "AS", "ASSET", "hola")

 

Saludos

That dont work?

I think you might have misunderstod me ;)

It need to write the input from the InputBox, this way you just showed me just give me a "4" no matter what i type into the inputbox

 

 

 

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("ASSET", 615, 438, 192, 124)

GUISetState(@SW_SHOW)

$AB = GUICtrlCreateButton("Apply", "200", "200")

$AS = GUICtrlCreateInput("", "150", "150", "200")

$ASRead = GUICtrlRead($AS)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

    Case $AB

     ConsoleWrite(GUICtrlRead($AS)&@CRLF)

EndSwitch

WEnd

You need to do guictrlread when the button is pressed, not while initializing

Woaw i just tried doing the GUICtrlRead once the button is pressed still get "4" no matter what i type into the inputbox.

Edited by GraaF1337

Share this post


Link to post
Share on other sites

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


$Form1 = GUICreate("ASSET", 615, 438, 192, 124)
GUISetState(@SW_SHOW)



$AB =   GUICtrlCreateButton("Apply", "200", "200")
$AS =   GUICtrlCreateInput("", "150", "150", "200")


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

                    Case $AB
                        $ASRead = GUICtrlRead($AS)
                iniWrite("set.ini", "AS", "ASSET", $ASRead)

    EndSwitch
WEnd

:S

Share this post


Link to post
Share on other sites
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("ASSET", 615, 438, 192, 124)
GUISetState(@SW_SHOW)



$AB =   GUICtrlCreateButton("Apply", "200", "200")
$AS =   GUICtrlCreateInput("", "150", "150", "200")


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

                    Case $AB
                        $ASRead = GUICtrlRead($AS)
                iniWrite("set.ini", "AS", "ASSET", $ASRead)

    EndSwitch
WEnd

:S

Ohhh woaw i forgot to remove the old GUICtrlRead ^^

Thank you very much both of you! ;)

 

Can be marked as solved! ;)

Share this post


Link to post
Share on other sites

Good thing i didn't :D

Cuz i have a new problem now ;)

 

Now im working on making it give a error in the input is NOT 1 or 0 but i tried with "And" but it dont seem to work?.

Case $AB
                        $ASRead = GUICtrlRead($AS)
                        If NOT $ASRead = "1" And "0" Then
                            MsgBox("64", "ERROR:", "Error")
                            Else
                iniWrite("set.ini", "AS", "ASSET", $ASRead)
                    EndIf

Also tried with "Or":

Case $AB
                        $ASRead = GUICtrlRead($AS)
                        If NOT $ASRead = "1" Or "0" Then
                            MsgBox("64", "ERROR:", "Error")
                            Else
                iniWrite("set.ini", "AS", "ASSET", $ASRead)
                    EndIf

Share this post


Link to post
Share on other sites

Figured it out my self! ;)

Case $AB
                        $ASRead = GUICtrlRead($AS)
                        If $ASRead = "1" Then
                iniWrite("set.ini", "AS", "ASSET", $ASRead)
                        Else
                        If $ASRead = "0" Then
                iniWrite("set.ini", "AS", "ASSET", $ASRead)
                        Else
                            MsgBox("32", "Error:", "Error")
                        EndIf
                        EndIf

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  

×
×
  • Create New...