AutoIt Forums: How do you make a text box that sets a variables value to what is typed? - AutoIt Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How do you make a text box that sets a variables value to what is typed? PLEASE HELP! Read thread for more info.

#1 User is offline   RacecarSoft 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 30
  • Joined: 13-April 08
  • Location:New Orleans LA

Post icon  Posted 26 November 2008 - 10:18 AM

I want to make a text box that pops up and asks what they want to be in the variable.
I tried this (oh and btw credit to the autoit examples because this is a copy off of some of it):

CODE:

Example()

Func Example()
Local $myedit, $msg, $TYPEME

$var = "foo"

GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered

$myedit = GUICtrlCreateEdit("" & $var & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)

GUISetState()

Send("{END}")

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
MsgBox(64, $var, "test to see if the change worked")
EndFunc ;==>Example

END CODE

But when I modify the text box, it reverts the variable to "foo" again, how do I make the text box actually EDIT it rather than ignoring the changes? Please help!

Racecar 56

#2 User is offline   skysel 

  • Advanced Member
  • PipPip
  • Group: Full Members
  • Posts: 124
  • Joined: 26-March 08

Posted 26 November 2008 - 10:32 AM

[ autoIt ]    ( Popup )
$input = InputBox("Window title", "Enter your variable:") MsgBox(0,"User input is..",$input)



:)

#3 User is offline   Zedna 

  • AutoIt rulez!
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 6,592
  • Joined: 17-June 05
  • Location:Czech republic

Posted 26 November 2008 - 10:34 AM

[ code='text' ]    ( ExpandCollapse - Popup )
Example() Func Example() Local $myedit, $msg, $TYPEME $var = "foo" GUICreate("My GUI edit"); will create a dialog box that when displayed is centered $myedit = GUICtrlCreateEdit("" & $var & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState() Send("{END}") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd $var = GUICtrlRead($myedit) GUIDelete() MsgBox(64, $var, "test to see if the change worked") EndFunc;==>Example

This post has been edited by Zedna: 26 November 2008 - 10:34 AM


#4 User is offline   RacecarSoft 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 30
  • Joined: 13-April 08
  • Location:New Orleans LA

Post icon  Posted 26 November 2008 - 10:41 AM

View PostZedna, on Nov 26 2008, 03:34 AM, said:

[ code='text' ]    ( ExpandCollapse - Popup )
Example() Func Example() Local $myedit, $msg, $TYPEME $var = "foo" GUICreate("My GUI edit"); will create a dialog box that when displayed is centered $myedit = GUICtrlCreateEdit("" & $var & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState() Send("{END}") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd $var = GUICtrlRead($myedit) GUIDelete() MsgBox(64, $var, "test to see if the change worked") EndFunc;==>Example


Thanks alot! :D

EDIT: Oh shoot! It puts 1's after it types! Here is the full code (to see if any of you out there can improve it :) ) :

CODE

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.1
Author: Racecar56

Script Function:
Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

;----------==Includes==----------
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
;----------==Options==-----------
Opt('MustDeclareVars', 1)
;----------==Local==-------------
Local $var
;----------==Script==------------
Global $oMyError

Example()
Func Example()
Local $myedit, $msg, $TYPEME

$var = "foo"

GUICreate("My GUI edit"); will create a dialog box that when displayed is centered

$myedit = GUICtrlCreateEdit("" & $var & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)

GUISetState()

Send("{END}")

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

$var = GUICtrlRead($myedit)
GUIDelete()

MsgBox(64, $var, "test to see if the change worked")

EndFunc;==>Example

Local $i
$i = 0
While $i <= 0
$var = Send( $var )
Sleep(05)
WEnd

END OF CODE

This post has been edited by RacecarSoft: 26 November 2008 - 10:48 AM


#5 User is offline   RacecarSoft 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 30
  • Joined: 13-April 08
  • Location:New Orleans LA

Posted 26 November 2008 - 11:03 AM

View PostRacecarSoft, on Nov 26 2008, 03:41 AM, said:

Thanks alot! :D

EDIT: Oh shoot! It puts 1's after it types! Here is the full code (to see if any of you out there can improve it :) ) :

CODE

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.1
Author: Racecar56

Script Function:
Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

;----------==Includes==----------
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
;----------==Options==-----------
Opt('MustDeclareVars', 1)
;----------==Local==-------------
Local $var
;----------==Script==------------
Global $oMyError

Example()
Func Example()
Local $myedit, $msg, $TYPEME

$var = "foo"

GUICreate("My GUI edit"); will create a dialog box that when displayed is centered

$myedit = GUICtrlCreateEdit("" & $var & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)

GUISetState()

Send("{END}")

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

$var = GUICtrlRead($myedit)
GUIDelete()

MsgBox(64, $var, "test to see if the change worked")

EndFunc;==>Example

Local $i
$i = 0
While $i <= 0
$var = Send( $var )
Sleep(05)
WEnd

END OF CODE


Anybody there? (sorry for dubble post)

#6 User is offline   BrettF 

  • My Drunk Monkey Guerilla is gonna getcha!
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 7,644
  • Joined: 02-October 06
  • Gender:Male
  • Location:Brisbane, Australia

Posted 26 November 2008 - 11:22 AM

Please wait 24 hours before bumping your post.

You might want to look here specifically.

Local $i
$i = 0
While $i <= 0
$var = Send( $var )
Sleep(05)
WEnd

You reset $var to be the return value of send.... :)

Cheers,

Brett

#7 User is offline   RacecarSoft 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 30
  • Joined: 13-April 08
  • Location:New Orleans LA

Posted 26 November 2008 - 11:40 AM

View PostBrettF, on Nov 26 2008, 04:22 AM, said:

Please wait 24 hours before bumping your post.

You might want to look here specifically.

Local $i
$i = 0
While $i <= 0
$var = Send( $var )
Sleep(05)
WEnd

You reset $var to be the return value of send.... :)

Cheers,

Brett


Oh, thanks!

#8 User is offline   Zedna 

  • AutoIt rulez!
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 6,592
  • Joined: 17-June 05
  • Location:Czech republic

Posted 26 November 2008 - 01:25 PM

Also use

[ code='text' ]    ( Popup )
Send( $var, 1 )


In this case your text could contain also special characters like !,+,^,# without interpreting them as special characters (raw mode).

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users