Hey everyone!
I need a help with application, i wanna to my application tells me if let's say Spider Solitaire window is maximized!
I was found one code on internet but i have problem with that! Maybe you can help me.
Error 1:'Option' statements must precede any declarations or 'Imports' statements.
Error 2:'Public Property Left() As Integer' has no parameters and its return type cannot be indexed.
I need a help with application, i wanna to my application tells me if let's say Spider Solitaire window is maximized!
I was found one code on internet but i have problem with that! Maybe you can help me.
Public Class Form1
option Explicit 'ERROR 1
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim hwnd As Long, r As Long
Dim sWindowText As String
hwnd = GetForegroundWindow ' get forground window
sWindowText = Space$(255) ' get window text
r = GetWindowText(hwnd, sWindowText, 255)
sWindowText = Left(sWindowText, r) ERROR 2
If InStr(1, sWindowText, " - Microsoft Internet Explorer") Then ' check text for IE string.
If IsZoomed(hwnd) = 1 Then MsgBox("IE is foreground and maximized!", vbSystemModal) ' if maximized then display msgbox.
End If
End Sub
End Class
Error 1:'Option' statements must precede any declarations or 'Imports' statements.
Error 2:'Public Property Left() As Integer' has no parameters and its return type cannot be indexed.