如何实现选中$Input输入$Button对应的数字(已解决)
本帖最后由 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 大侠们帮忙看下,谢谢!顶起! 书读得少,没看懂在说啥...
二○二五年十月三十日 盲猜是这样
#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
谢谢大侠!
如何实现选中$Input输入$Button对应的数字(已解决)
谢谢!如何实现选中$Input输入$Button对应的数字(已解决)
页:
[1]