找回密码
 加入
搜索
楼主: hyrl5190

外部程序Edit框有字符限制,如何强制写入?

[复制链接]
 楼主| 发表于 2009-7-29 14:54:09 | 显示全部楼层
如果你有时间,不嫌麻烦,可以拷贝我的模拟代码一试
不管是复制粘贴
controlsettext
controlsend
_GUICtrlButton_SetText()
等命令都无法输入
发表于 2009-7-29 15:11:10 | 显示全部楼层
是呀,与原始设计有关呀,如果原程序像你这么设计,永远也别想输入多余三个字符。是不是?
既然人家可以用其他方法输入字符,就说明人家有判断标准,能输入但是方法没找到。

下面这个代码,你用键盘输入将永远失败:
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 485, 90, -1, -1)
$Input1 = GUICtrlCreateInput("", 40, 32, 417, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibRegister("_check",10)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func _check()
        If stringlen(GUICtrlRead($Input1))=1 Then 
                Global $T0=TimerInit ()
        ElseIf stringlen(GUICtrlRead($Input1))=3 Then
                Global $T1=TimerDiff($T0)
                if $T1>30 Then
                        GUICtrlSetData($Input1,"")
                EndIf
        EndIf
EndFunc
而用下面这段代码就可以输入:
WinWaitActive("Form1")
ControlSetText("Form1","","Edit1","111111111111")
下面这个类似于你的代码,是永远没法输入的:
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 485, 90, -1, -1)
$Input1 = GUICtrlCreateInput("", 40, 32, 417, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibRegister("_check",10)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func _check()
        If stringlen(GUICtrlRead($Input1))=>3 Then 
                GUICtrlSetData($Input1,"")
        EndIf
EndFunc
发表于 2009-7-29 15:11:29 | 显示全部楼层
本帖最后由 顽固不化 于 2009-7-29 15:13 编辑

是呀,与原始设计有关呀,如果原程序像你这么设计,永远也别想输入多余三个字符。是不是?
既然人家可以用其他方法输入字符,就说明人家有判断标准,能输入但是方法没找到。

下面这个代码,你用键盘输入将永远失败:
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 485, 90, -1, -1)
$Input1 = GUICtrlCreateInput("", 40, 32, 417, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibRegister("_check",10)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func _check()
        If stringlen(GUICtrlRead($Input1))=1 Then 
                Global $T0=TimerInit ()
        ElseIf stringlen(GUICtrlRead($Input1))=3 Then
                Global $T1=TimerDiff($T0)
                if $T1>30 Then
                        GUICtrlSetData($Input1,"")
                EndIf
        EndIf
EndFunc
而用下面这段代码就可以输入:
WinWaitActive("Form1")
ControlSetText("Form1","","Edit1","111111111111")
下面这个类似于你的代码,是永远没法输入的:
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 485, 90, -1, -1)
$Input1 = GUICtrlCreateInput("", 40, 32, 417, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibRegister("_check",10)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func _check()
        If stringlen(GUICtrlRead($Input1))>3 Then 
                GUICtrlSetData($Input1,"")
        EndIf
EndFunc
发表于 2009-7-29 15:17:51 | 显示全部楼层
我试了一下,你1楼的判断是=3,所以,用上面的第二段代码是可以输入多于3字符的。
 楼主| 发表于 2009-7-29 22:38:01 | 显示全部楼层
很感谢大家积极帮我解决问题
尤其是顽固不化,既然你这样说
那就此结贴吧,再次感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-2 09:14 , Processed in 0.072598 second(s), 13 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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