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

[GUI管理] GUICtrlCreateInput IF后的返回问题![已解决]

  [复制链接]
发表于 2012-7-7 14:16:22 | 显示全部楼层 |阅读模式
本帖最后由 chengjinn 于 2012-7-8 08:16 编辑

创建一个GUICtrlCreateInput
读取输入文本信息后
用IF去判别信息。
如果是空的或不是我要的信息。则给个提示。
问题是不知道提示后要怎么返回等待输入的状态?
发表于 2012-7-7 14:43:55 | 显示全部楼层
本帖最后由 user3000 于 2012-7-7 14:47 编辑

回复 1# chengjinn

你这问题描述得真拗口, 你的目的是想让INPUT控件获得输入焦点吧, 当输入错误时?GuiCtrlSetState($input, $GUI_FOCUS)  具体情形查看帮助吧
 楼主| 发表于 2012-7-7 16:27:16 | 显示全部楼层
不是的。
呵呵。表达能力可能不行。
我的意思是。
创建一个GUIINPUT后。
用户输入了信息 点击写入BUTTON建后。
脚本会用IF去对比一下用户输入的信息。看其是否输入了空。
如果是空的我脚本给出个提示。输入框不能为空。
这个时候要怎么返回到等待输入的状态。
发表于 2012-7-7 16:33:39 | 显示全部楼层
回复 3# chengjinn

把你弄好的代码放上来吧, 结合代码来说明, 也许大家就明白了你的意思了.
 楼主| 发表于 2012-7-7 18:12:29 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 341, 151, 192, 114)
$Input1 = GUICtrlCreateInput("Input1", 56, 24, 233, 21)
$Button1 = GUICtrlCreateButton("Button1", 128, 72, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $temp=GUICtrlRead($Input1)
                        If $temp='' Then
                                MsgBox(0,0,'输入框不能为空')
                        Else
                                MsgBox(0,0,$temp)
                                ;
                        EndIf
                       
        EndSwitch
WEnd


呵呵。自已脑子卡壳了。先前发烧傻了。
只要把CASE 之后整个语句套到IF里面就可以了。
先前总想着只把输入框是否为空放在IF里面。其他的放外面。所以傻掉了。不好意思。浪费大家时间!
发表于 2012-7-7 18:34:04 | 显示全部楼层
回复 5# chengjinn
优化了一点点
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 341, 151)
$Input1 = GUICtrlCreateInput("", 56, 24, 233, 21)
$Button1 = GUICtrlCreateButton("Button1", 128, 72, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $temp=GUICtrlRead($Input1)
                        If $temp='' Then
                                MsgBox(0,0,'输入框不能为空', '', $Form1)
                                GUICtrlSetState($Input1, $gui_focus)
                        Else
                                MsgBox(0,0,$temp, '', $Form1)
                        EndIf                        
        EndSwitch
WEnd
发表于 2014-10-28 15:01:54 | 显示全部楼层
感谢,正好用上,老是会忘记用guictrlread()  感谢,感谢。非常感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 16:36 , Processed in 0.076032 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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