怎么样往屏幕上一个任意的文本框中输入数字,关键在怎么样找(指定)这个任意的文本框。

解决方案 »

  1.   

    用鼠标点击你想要输入的文本框。:)好像没有这么简单!我想你是想让某文本框自动获得焦点,比如想在Text3文本框输入,可以在输入按钮的代码中加入:
    Text3.SetFocus
    这样Text3文本框就获得了焦点。
      

  2.   

    FindWindow
    The FindWindow function retrieves the handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows.FindWindowEx
    The FindWindowEx function retrieves the handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the given child window.Then ...Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As LongPrivate Const WM_SETTEXT = &HCPrivate Sub Command1_Click()
        Dim strText As String
        strText = "New Text"
        SendMessage Text1.hwnd, WM_SETTEXT, 0, strText
    End Sub
      

  3.   

    Private Declare Function WindowFromPoint Lib "user32" ( _
        ByVal xPoint As Long, _
        ByVal yPoint As Long) As LongPrivate Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long先用GetCursorPos取得光标当前所在的位置
    然后调用WindowFromPoint取得所指定位置下面窗口(Text,CommandButton,...)的句柄。
    然后再根据返回的有效句柄进行所要指定的动作。