Jump to content

how to reed


Recommended Posts

how to read what was entered into GuiCtrlCreateInput ?

#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>
Opt('MustDeclareVars', 0)
GUI()
Func GUI()
GuiCreate("Sample GUI", 210, 50)
$key1 = GuiCtrlCreateInput("", 10, 0,40)

While 1
$var = GUIGetMsg()
If $var = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc

Thanks

Link to comment
Share on other sites

I know, GUICtrlRead() is difficult to find in the help file.

Try

$sResult = GUICtrlRead($key1)

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

lighting speed reply

Thanks

Next time ill try to use this technique to search help file with first few letters of the code to see what else there is, but it seems like when i search for a code only few show up but not all that start same

for example if i search for GUICtrlRead, i would get it in the middle of _GUICtrlMonthCal and _GUICtrlRebar Weird :D

Link to comment
Share on other sites

exactly what i was going to do

thanks

Now that i've got that i am still confused (trying very hard) about how to push text from GuiCtrlCreateInput with a press of GuiCtrlCreateButton into IniWrite

So here is what i tried but i am stuck with my limited knowledge of scripting (understanding in general)

In this script i completely lost my self understanding use of While/Case the whole Func/EndFunc thing i just dont get it. (i coded to much with CMD lol)

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Button_1, $key1, $msg
    GuiCreate("Sample GUI", 210, 50)

    Opt("GUICoordMode", 2)
    $key1 = GuiCtrlCreateInput("", 10, 0,40)
$key1 = GuiCtrlCreateButton("Save CD key to key.ini file",35,20,140,20)

    GUISetState()    ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $key1
                MsgBox(0, 'Testing', 'Button 2 was pressed')
        EndSelect
    WEnd
EndFunc

Code came from help file and i trimmed it down to one button but still dont understand how to get text typed into input box passed into file.ini with press of a button.

Thank u all, you guys are quick in reply and very helpfull

Link to comment
Share on other sites

exactly what i was going to do

thanks

Now that i've got that i am still confused (trying very hard) about how to push text from GuiCtrlCreateInput with a press of GuiCtrlCreateButton into IniWrite

So here is what i tried but i am stuck with my limited knowledge of scripting (understanding in general)

In this script i completely lost my self understanding use of While/Case the whole Func/EndFunc thing i just dont get it. (i coded to much with CMD lol)

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Button_1, $key1, $msg
    GuiCreate("Sample GUI", 210, 50)

    Opt("GUICoordMode", 2)
    $key1 = GuiCtrlCreateInput("", 10, 0,40)
$key1 = GuiCtrlCreateButton("Save CD key to key.ini file",35,20,140,20)

    GUISetState(); will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $key1
                MsgBox(0, 'Testing', 'Button 2 was pressed')
        EndSelect
    WEnd
EndFunc

Code came from help file and i trimmed it down to one button but still dont understand how to get text typed into input box passed into file.ini with press of a button.

Thank u all, you guys are quick in reply and very helpfull

You can't use the same variable for both controls

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Button1, $Input1, $msg, $hIni = @ScriptDir & "\MyIni.ini"
    GuiCreate("Sample GUI", 210, 50)
    
    Opt("GUICoordMode", 2)
    $Input1 = GuiCtrlCreateInput("", 10, 0,40)
    $Button1 = GuiCtrlCreateButton("Save CD key to key.ini file",35,20,140,20)
    
    GUISetState(); will display an  dialog box with 2 button
    
; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Button1
                $sVal = GUICtrlRead($Input1)
                MsgBox(0, 'Testing', $sVal)
                IniWrite($hIni, "Returned", "Value", $sVal)
        EndSwitch
    WEnd
EndFunc
Edited by GEOSoft

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

you forgot to declare $sVal. Took me a while to figure it out lol but it worked. :P

Thanks allot. :D

I still dont understand the use of While 1, i learned If,Else, ElseIF,Then,EndIf but not While, Case, Switch so thats maybe why i was not able to figure that out. :D

Thanks again ;)

Link to comment
Share on other sites

I noticed GuiCtrlCreateInput does not limit input number and i cant find anything in helpfile that will set the limit of input characters.

I would also want to increase font size somehow.

Just tell me where to look

thanks

Link to comment
Share on other sites

guictrlsetlimit()

Link to comment
Share on other sites

Thanks it worked.

You guys are so quick with replying i could not avoid asking more questions as i go.

I have 2 codes that work just the way i need it.

1st reads inserted KEY and outputs it into key.ini.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Button1, $Input1, $Input2, $Input3, $Input4, $msg, $hIni, $sVal1, $sVal2, $sVal3, $sVal4 = @ScriptDir & "\Key.ini"
    GuiCreate("Sample GUI", 170, 50)
    
    Opt("GUICoordMode", 1)
    $Input1 = GuiCtrlCreateInput("", 10, 0,30)
    guictrlsetlimit (-1, 4)
     $Input2 = GuiCtrlCreateInput("", 50, 0,30)
    guictrlsetlimit (-1, 4)
     $Input3 = GuiCtrlCreateInput("", 90, 0,30)
    guictrlsetlimit (-1, 4)
     $Input4 = GuiCtrlCreateInput("", 130, 0,30)
    guictrlsetlimit (-1, 4)
    $Button1 = GuiCtrlCreateButton("Save CD key to key.ini file",15,20,140,20)
    
    GUISetState(); will display an  dialog box with 2 button
    
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Button1
                $sVal1 = GUICtrlRead($Input1)
                $sVal2 = GUICtrlRead($Input2)
                $sVal3 = GUICtrlRead($Input3)
                $sVal4 = GUICtrlRead($Input4)
                MsgBox(0, 'Key input', '       DONE')
                IniWrite("Key.ini", "begining of CD key", "part1", $sVal1)
                IniWrite("Key.ini", "begining of CD key", "part2", $sVal2)
                IniWrite("Key.ini", "begining of CD key", "part3", $sVal3)
                IniWrite("Key.ini", "begining of CD key", "part4", $sVal4)
        EndSwitch
    WEnd
EndFunc
Exit

Second reads the saved data and outputs it into game

$gamecheck = WinActivate ("Unreal Tournament 3")
If $gamecheck = 1 then
$var1 = IniRead ("Key.ini","begining of CD key","part1","")
$var2 = IniRead ("Key.ini","begining of CD key","part2","")
$var3 = IniRead ("Key.ini","begining of CD key","part3","")
$var4 = IniRead ("Key.ini","begining of CD key","part4","")
Send ($var1)
Send ("{TAB}")

Send ($var2)
Send ("{TAB}")

Send ($var3)
Send ("{TAB}")

Send ($var4)
Send ("{TAB}")

Send ("{ENTER}")
ElseIf $gamecheck = 0 then
    MsgBox (0,"ERROR","Game must be running" & @CRLF & "Please start the game and try again")
    EndIf
Exit

I tried to combine those to into 1 file but its not working as i expect it.

Once GUI exits, second part is not executed so i guess i need to work on While 1 but i am clueless how it works

THanks

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...