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

[AU3基础] 如何实现选中$Input输入$Button对应的数字(已解决)

[复制链接]
发表于 2025-10-30 13:23:16 | 显示全部楼层 |阅读模式
本帖最后由 cfs43210 于 2025-10-30 22:39 编辑

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("", 152, 32, 97, 21)
$Input2 = GUICtrlCreateInput("", 152, 68, 97, 21)
$Input3 = GUICtrlCreateInput("", 152, 105, 97, 21)
$Input4 = GUICtrlCreateInput("", 152, 141, 97, 21)
$Input5 = GUICtrlCreateInput("", 375, 40, 97, 21)
$Input6 = GUICtrlCreateInput("", 375, 76, 97, 21)
$Input7 = GUICtrlCreateInput("", 375, 113, 97, 21)
$Input8 = GUICtrlCreateInput("", 375, 149, 97, 21)
$Button1 = GUICtrlCreateButton("1", 152, 192, 49, 33)
$Button2 = GUICtrlCreateButton("2", 206, 192, 49, 33)
$Button3 = GUICtrlCreateButton("3", 260, 192, 49, 33)
$Button4 = GUICtrlCreateButton("4", 315, 192, 49, 33)
$Button5 = GUICtrlCreateButton("5", 369, 192, 49, 33)
$Button6 = GUICtrlCreateButton("退格", 423, 192, 49, 33)
$Button7 = GUICtrlCreateButton("6", 152, 245, 49, 33)
$Button8 = GUICtrlCreateButton("7", 206, 245, 49, 33)
$Button9 = GUICtrlCreateButton("8", 260, 245, 49, 33)
$Button10 = GUICtrlCreateButton("9", 315, 245, 49, 33)
$Button11 = GUICtrlCreateButton("0", 369, 245, 49, 33)
$Button12 = GUICtrlCreateButton("清除", 423, 245, 49, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        EndSwitch
WEnd

评分

参与人数 1金钱 -20 收起 理由
afan -20

查看全部评分

 楼主| 发表于 2025-10-30 15:15:42 | 显示全部楼层
大侠们帮忙看下,谢谢!顶起!
发表于 2025-10-30 15:57:19 | 显示全部楼层
书读得少,没看懂在说啥...


二○二五年十月三十日
发表于 2025-10-30 20:19:06 | 显示全部楼层
盲猜是这样


#include <WindowsConstants.au3>
Global $LastInputID

$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("", 152, 32, 97, 21)
$Input2 = GUICtrlCreateInput("", 152, 68, 97, 21)
$Input3 = GUICtrlCreateInput("", 152, 105, 97, 21)
$Input4 = GUICtrlCreateInput("", 152, 141, 97, 21)
$Input5 = GUICtrlCreateInput("", 375, 40, 97, 21)
$Input6 = GUICtrlCreateInput("", 375, 76, 97, 21)
$Input7 = GUICtrlCreateInput("", 375, 113, 97, 21)
$Input8 = GUICtrlCreateInput("", 375, 149, 97, 21)
$Button1 = GUICtrlCreateButton("1", 152, 192, 49, 33)
$Button2 = GUICtrlCreateButton("2", 206, 192, 49, 33)
$Button3 = GUICtrlCreateButton("3", 260, 192, 49, 33)
$Button4 = GUICtrlCreateButton("4", 315, 192, 49, 33)
$Button5 = GUICtrlCreateButton("5", 369, 192, 49, 33)
$Button6 = GUICtrlCreateButton("退格", 423, 192, 49, 33)
$Button7 = GUICtrlCreateButton("6", 152, 245, 49, 33)
$Button8 = GUICtrlCreateButton("7", 206, 245, 49, 33)
$Button9 = GUICtrlCreateButton("8", 260, 245, 49, 33)
$Button10 = GUICtrlCreateButton("9", 315, 245, 49, 33)
$Button11 = GUICtrlCreateButton("0", 369, 245, 49, 33)
$Button12 = GUICtrlCreateButton("清除", 423, 245, 49, 33)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit

                Case $Button1 To $Button5, $Button7 To $Button11
                        If $LastInputID > 0 Then GUICtrlSetData($LastInputID, GUICtrlRead($LastInputID) & GUICtrlRead($nMsg))

                Case $Button6
                        If $LastInputID > 0 Then GUICtrlSetData($LastInputID, StringTrimRight(GUICtrlRead($LastInputID), 1))

                Case $Button12
                        If $LastInputID > 0 Then GUICtrlSetData($LastInputID, "")

        EndSwitch
WEnd

;全局按钮
Func WM_COMMAND($hWnd, $msg, $wParam, $lParam)
        Local $nID = BitAND($wParam, 0x0000FFFF)
        Switch $nID
                Case $Input1 To $Input8
                        $LastInputID = $nID
        EndSwitch
EndFunc   ;==>WM_COMMAND


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2025-10-30 22:37:28 | 显示全部楼层
如何实现选中$Input输入$Button对应的数字(已解决)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2025-11-19 09:22 , Processed in 1.227373 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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