找回密码
 加入
搜索
查看: 2883|回复: 6

[AU3基础] 无法读取GUICtrlCreateInput里面的文本内容?

[复制链接]
发表于 2011-1-14 16:02:16 | 显示全部楼层 |阅读模式
本帖最后由 大建子1 于 2011-1-14 17:18 编辑

像题目所述,无法获取GUICtrlCreateInput里面输入的文本内容。源码如下:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 351, 162, 298, 126)
$Input1 = GUICtrlCreateInput("Input1", 120, 48, 185, 21)
$Button1 = GUICtrlCreateButton("Button1", 88, 96, 105, 41)
$ceshi = GUICtrlCreateLabel("ceshi", 72, 48, 37, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $a
$a=GUICtrlRead($Input1)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"ceshi",$a)

        EndSwitch
WEnd
点击Button1所得出的结果还是Input1   我想如果我在输入框里面输入12345,让读取出来的结果也是“12345”,无法实现,不知道是那里出了错。麻烦哪位大大如果知道的话教授一下。
发表于 2011-1-14 16:19:23 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 351, 162, 298, 126)
$Input1 = GUICtrlCreateInput("Input1", 120, 48, 185, 21)
$Button1 = GUICtrlCreateButton("Button1", 88, 96, 105, 41)
$ceshi = GUICtrlCreateLabel("ceshi", 72, 48, 37, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;Dim $a
;$a=GUICtrlRead($Input1)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"ceshi",GUICtrlRead($Input1))

        EndSwitch
WEnd
发表于 2011-1-14 16:21:01 | 显示全部楼层
这两句
Dim $a
$a=GUICtrlRead($Input1)
可能就让$a的值定死掉了
发表于 2011-1-14 16:26:45 | 显示全部楼层
本帖最后由 5i5wei 于 2011-1-14 16:27 编辑

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 351, 162, 298, 126)
$Input1 = GUICtrlCreateInput("", 120, 48, 185, 21)

$Button1 = GUICtrlCreateButton("Button1", 88, 96, 105, 41)
$ceshi = GUICtrlCreateLabel("ceshi", 72, 48, 37, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $a
While 1
        $nMsg = GUIGetMsg()
               
    $a=GUICtrlRead($Input1,0)

        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"ceshi",$a)

        EndSwitch
WEnd

把这句放在while里面 $a=GUICtrlRead($Input1,0)
发表于 2011-1-14 16:30:41 | 显示全部楼层
3楼正解 你如果非要定义的话 就用我这种方法
 楼主| 发表于 2011-1-14 17:17:13 | 显示全部楼层
回复 2# papapa314


    谢谢了,让我有学习到了。
 楼主| 发表于 2011-1-14 17:17:31 | 显示全部楼层
回复 5# 5i5wei


    谢谢。有学习到新知识了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 16:30 , Processed in 0.083860 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表