找回密码
 加入
搜索
查看: 1443|回复: 8

控件顺序问题

[复制链接]
发表于 2008-12-25 11:06:11 | 显示全部楼层 |阅读模式
用AU3编写的界面,其控件顺序是靠Tab控制的。能否用键盘上的回车键进行控制,也就是说:“当我输完用户名后,按一下键盘上的回车键后,输入的焦点就会跳转到密码区”

[ 本帖最后由 silvay22 于 2008-12-26 19:24 编辑 ]
发表于 2008-12-25 16:19:54 | 显示全部楼层
GUICtrlSetState ( $button,$GUI_DEFBUTTON )
case $button
GUICtrlSetState ( $password, $GUI_FOCUS )
 楼主| 发表于 2008-12-26 16:59:53 | 显示全部楼层

回复 2# sxd 的帖子

兄弟能否详细些?
 楼主| 发表于 2008-12-26 18:10:05 | 显示全部楼层
经过了一段时间,请教朋友 范统.贾 后给出以下代码,但是问题是当输入框超过2个后,就无法使用了,不知哪位兄弟有好的思路,先谢谢啦
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 481, 154, 192, 114)
$Input1 = GUICtrlCreateInput("", 128, 40, 209, 21)
$Input2 = GUICtrlCreateInput("", 128, 80, 209, 21)
GUISetState(@SW_SHOW)


While 1
       
        If WinActive ($Form1) Then
                HotKeySet("{ENTER}", "_Enter")
        Else
                HotKeySet("{ENTER}")
        EndIf  ;==>热键只在软件窗口有效
       
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func _Enter()   
        ControlFocus("Form1", "", "Edit2")   ;==>设置焦点到密码输入框   
EndFunc
发表于 2008-12-26 18:38:30 | 显示全部楼层
#include <WindowsConstants.au3>
Dim $Input[4]
HotKeySet("{Enter}","_Enter")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 327, 223, 192, 124)
$Input[1] = GUICtrlCreateInput("", 96, 40, 121, 21)
$Input[2] = GUICtrlCreateInput("", 96, 72, 121, 21)
$Input[3] = GUICtrlCreateInput("", 96, 104, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 112, 136, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func _Enter() 
  $r = StringTrimLeft(ControlGetFocus($Form1),4)
Switch $r 
Case 1 To 2
        ControlClick ($Form1, "", "Edit"&$r+1, "left",2)
Case 3
        ControlClick ($Form1, "", "Edit1", "left",2)
EndSwitch
EndFunc
你要的是不是这种效果?





发表于 2008-12-26 18:41:04 | 显示全部楼层
超过2个 应该设置不同的group吧
 楼主| 发表于 2008-12-26 18:48:15 | 显示全部楼层

回复 5# gto250 的帖子

麻烦问下gto250兄弟,StringTrimLeft(ControlGetFocus($Form1),4)这句的意思什么?对了,如果将Button1也加入到其中,怎么写程序?
发表于 2008-12-26 18:54:29 | 显示全部楼层
你 MsgBox(0,"",ControlGetFocus($Form1))就知道了
 楼主| 发表于 2008-12-26 19:02:59 | 显示全部楼层
好的谢谢gto250兄弟!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 03:58 , Processed in 0.076920 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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