MsgBox SendMessage(Hndl, BM_GETSTATE, 0, 0)
otras constantes para aprovechar
Private Const BM_GETSTATE = &HF2
Private Const WM_SETFOCUS = &H7
Private Const WM_KILLFOCUS = &H8
Private Const WM_ENABLE = &HA
Código:
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const BM_GETSTATE = &HF2
Private Sub Form_Load()
' cierro las calculadodas abiertas
While FindWindow("SciCalc", vbNullString) <> 0
Call SendMessage(FindWindow("SciCalc", vbNullString), &H112, &HF060&, 0)
Wend
Shell "calc"
Timer1.Interval = 100
End Sub
Private Sub Form_Unload(Cancel As Integer)
' cierro las calculadodas abiertas
While FindWindow("SciCalc", vbNullString) <> 0
Call SendMessage(FindWindow("SciCalc", vbNullString), &H112, &HF060&, 0)
Wend
End Sub
Private Sub Form_DblClick()
Shell "calc"
End Sub
Private Sub Timer1_Timer()
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1)
Dim Hndl As Long: Dim i As Long: Dim x As Long
Dim H(0 To 9) As Long: Dim ch(0 To 9) As Long
Hndl = FindWindow("scicalc", vbNullString)
If Hndl <> 0 Then
For i = 0 To 9
H(i) = FindWindowEx(Hndl, 0, vbNullString, i)
ch(i) = SendMessage(H(i), BM_GETSTATE, 0, 0)
If ch(i) = 512 Then Me.Cls: Me.Print "FOCO BOTON " & i
If ch(i) = 620 Then
Me.Cls: Me.Print "CLICK EN BOTON " & i
x = GetTickCount: While GetTickCount < x + 450: DoEvents: Wend
End If
DoEvents
Next i
If ch(0) = 0 And ch(1) = 0 And ch(2) = 0 And ch(3) = 0 And ch(4) = 0 _
And ch(5) = 0 And ch(6) = 0 And ch(7) = 0 And ch(8) = 0 And ch(9) = 0 _
Then Me.Cls: Me.Print "NINGUN BOTON NUMÉRICO TIENE FOCO"
Else
Me.Cls: Me.Print "CALCULADORA CERRADA"
End If
End Sub
Saludos