【已解决】询问一个在指定地方插入指定的字符
本帖最后由 aassddffgg961 于 2013-3-13 12:48 编辑有三个问题,一起问了,如下:
第一个:想做两个窗口,供用户根据提示输入自己想要的数据,然后把这段数据插入到一个文本的某个地方。
第二个:就是一个代码里面是否不能有两个InputBox定义?我写的这些代码为何只有一个窗口出现。
第三个:InputBox宽度和高度用—1是默认的,那左方和顶部用什么表示才是默认的?因涉及到要用到超时的参数,所以一定要搞懂才行。
不胜感激。Local $passwd = InputBox("密码","密码","","",-1,-1,-1,-1,30)
$answer = InputBox("选择", "输入”", "1","",250,250,",",30)
$file = FileOpen("1.txt", 1)
If @error = 1 Then
MsgBox(4096, "", "已退出")
Exit
EndIf
FileWrite($file,“密码:”&$passwd “选择:”&$answer) {:face (394):}咋没人回答呢?高手们呢?问题太幼稚不屑回答吗? 回复 1# aassddffgg961
1.用GUICreate 自定义窗口, 再用GUICtrlCreateInput 创立输入框.
2.同上
3.-1,-1 默认值是-1,没有默认值的使用关键词default。
楼主你自己看下你的代码,整齐与否不说,起码写标准了啊。
还有写代码不要凭想当然,你那个@error值哪里来的?怎么帮助里面没看到。麻烦解释一下。 第一个,InputBox的返回值就是输入的值
第二个,可以有2个InputBox,但1次只能执行一个,串行
第三个,没有找到默认宽度高度, 参考这个凑合用吧~$sRtn = InputBox("Title", "This is prompt", "default", "", "-1", "-1", @DesktopWidth/2, @DesktopHeight/2, 30) 本帖最后由 netegg 于 2013-3-2 17:54 编辑
Local $answer = InputBox("问题", "你在哪里出生?", "地球", "", - 1, -1, 0, 0)
Local $passwd = InputBox("安全检查", "输入您的密码.", "", "*")
不能设置超时,否则返回空串,帮助里@error有说明 回复 3# henry10423
不好意思,我真的很笨,已经创建了输入框,如下面的代码,想在输入框有个默认的数据,又可供人更改,最后用GUICtrlRead读取的都是我默认的数据。不知道哪里出错。还有就是如何才能设置点击确定后再显示一个窗口输入另外的文字?#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Example1()
Func Example1()
Local $msg,$Button_1,$Button_2,$open,$answer
GUICreate("123",550,200)
GUISetFont(25)
GUICtrlCreateLabel("abc",-1,-1)
$open=GUICtrlCreateInput("C:,",25,95, 300, 35)
GUISetFont(10)
Opt("GUICoordMode", 2)
$Button_1 =GUICtrlCreateButton("确定", -1, 25, 70, 40)
GUICtrlSetState(-1, $GUI_FOCUS)
$Button_2 =GUICtrlCreateButton("取消", 0,-1)
GUISetState()
GUISetState(@SW_SHOW)
$answer=GUICtrlRead($open)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
FileDelete(@ScriptDir&"\test.txt")
FileOpen("test.cmd", 1)
FileWrite("test.cmd",$answer)
ExitLoop
Case $msg = $Button_2
ExitLoop
EndSelect
WEnd
GUIDelete()
EndFunc
20句插到26句后。 回复 9# shqf
请帮忙看看下面的代码哪里错了?为何在第二个窗口出来后就一部分不显示,输入框和确定取消都不见了。谢谢。#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Example1()
Example2()
Func Example1()
Local $msg,$Button_1,$Button_2,$open,$answer
GUICreate("abcc",650,200)
GUISetFont(25)
GUICtrlCreateLabel("1234567890",-1,-1)
GUICtrlCreateLabel("321",205,35)
$open=GUICtrlCreateInput("",185,85, 300, 35)
GUISetFont(10)
Opt("GUICoordMode", 2)
$Button_1 =GUICtrlCreateButton("确定", -1, 25, 70, 40)
GUICtrlSetState(-1, $GUI_FOCUS)
$Button_2 =GUICtrlCreateButton("取消", 0,-1)
GUISetState()
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Button_2
Exit
Case $msg = $Button_1
$answer=GUICtrlRead($open)
FileDelete(@ScriptDir&"\test.txt")
FileOpen("test.txt", 1)
FileWrite("test.txt","999")
FileWrite("test.txt",$answer)
ExitLoop
EndSelect
WEnd
GUIDelete()
EndFunc;==>Example
Func Example2()
Local $msg2,$Button_3,$Button_4,$open2,$answer2
GUICreate("1234566",650,200)
GUISetFont(25)
GUICtrlCreateLabel("2222",-1,-1)
GUICtrlCreateLabel("333",205,35)
$open2=GUICtrlCreateInput("12345",185,85, 300, 35)
GUISetFont(10)
Opt("GUICoordMode", 2)
$Button_3 =GUICtrlCreateButton("确定", -1, 25, 70, 40)
GUICtrlSetState(-1, $GUI_FOCUS)
$Button_4 =GUICtrlCreateButton("取消", 0,-1)
GUISetState()
GUISetState(@SW_SHOW)
While 1
$msg2= GUIGetMsg()
Select
Case $msg2= $GUI_EVENT_CLOSE
Exit
Case $msg2= $Button_3
$answer2=GUICtrlRead($open2)
FileOpen("test.cmd", 1)
FileWrite("test.txt"," 222")
FileWrite("test.txt",$answer2)
ExitLoop
Case $msg2= $Button_4
Exit
EndSelect
WEnd
GUIDelete()
EndFunc 来学习。。。。。。 本帖最后由 shqf 于 2013-3-5 10:29 编辑
回复 10# aassddffgg961
48、49、53、55句怎么位置或大小都用缺少参数。可缺省参数的值是多少你知道吗?这么搞,两个按钮都不知放到哪里去了?还有控件可能会互相重叠了。没有这么写程序的。
创建窗口和控件,还是用“工具”-“窗口设计(Koda)”这个工具吧 。 万分感谢。已经搞懂了,好像有两个gui的时候第一个不能含有默认的参数,两个gui都要设置位置和大小,不能用默认的。 万分感谢。已经搞懂了,好像有两个gui的时候第一个不能含有默认的参数,两个gui都要设置位置和大小,不能用默认的。
页:
[1]