VB获得空格的窗口
- 提问者网友:你独家记忆
- 2021-04-21 22:18
- 五星知识达人网友:等灯
- 2021-04-21 23:17
给你个思路,用循环
for i = 1 to 100'还能超过一百个空格吗?
name = FindWindow(vbNullString, "连连看 v4.6" & space(i))
if name<>"" then exit for
next
- 1楼网友:人類模型
- 2021-04-22 01:15
枚举窗体得到的是窗体句柄
'放到窗体里面 Private Sub Form_Load() 'KPD-Team 2000 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net 'Set the form's graphics mode to persistent Me.AutoRedraw = True 'call the Enumwindows-function EnumWindows AddressOf EnumWindowsProc, ByVal 0& End Sub '放在模块里面 Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean Dim sSave As String, Ret As Long Ret = GetWindowTextLength(hwnd) sSave = Space(Ret) GetWindowText hwnd, sSave, Ret + 1 Form1.Print Str$(hwnd) + " " + sSave
'这里sSave就是窗体标题,只要用Instr()就可知道是不是你要的
If InStr(1, sSave, "连连看 v4.6") > 0 Then MsgBox "找到此窗口" 'continue enumeration EnumWindowsProc = True End Function
- 2楼网友:山有枢
- 2021-04-22 00:45
name = FindWindow(vbNullString, "连连看 v4.6" & space(i))
if name<>"" then exit for
next
print i 知道空格有多少个
- 3楼网友:逃夭
- 2021-04-21 23:48