PDA

View Full Version : Solved: IE WindowsSize ??



omnibuster
06-15-2009, 05:44 PM
Hi.
I Cant control Minimize/Normal protcess.
How control: if IE WindowsSize Minimized then do something.


Option Explicit
Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Enum apiShowWindowSize
SW_MAXIMIZE = 3
SW_SHOWNORMAL = 1
SW_sHOWMINIMIZED = 2
End Enum
Sub test()
Dim strSavePath As String
Dim URL As String, ext As String
Dim buf, Ret As Long
Dim objIE As Object
'Close All opened IE Windows??
Set objIE = CreateObject("InternetExplorer.Application")
'On Error GoTo errHandler
With objIE
.Navigate "http://somesite.com"
Do While .Busy: DoEvents: Loop
objIE.Visible = True

apiShowWindow objIE.hwnd, SW_SHOWNORMAL

'IE NormalSize, because need insert capthasymbols.
' If symbols inserted and website end loading then user should click IE MINIMIZE i.e. this trigered: go to next operation

Do While .ReadyState <> 4: DoEvents: Loop

End With

10
With objIE

If objIE.hwnd = SW_SHOWNORMAL Or objIE.hwnd = SW_MAXIMIZE Then
GoTo 10
Else
Call GETinfo

End If
End With
Set objIE Nothing
IE Quit
End Sub

omnibuster
06-16-2009, 01:05 PM
Thanks for Google & http://p2p.wrox.com/vb-how/27964-internet-explorer.html (http://p2p.wrox.com/vb-how/27964-internet-explorer.html)


Option Explicit
Dim IE As InternetExplorer
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Const SW_MAXIMIZE = 3
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Sub CommandButton1_Click()

Dim ip As WINDOWPLACEMENT
ip.Length = Len(ip)
Set IE = CreateObject("InternetExplorer.Application")

With IE
.Navigate "www.google.com"
Do Until IE.ReadyState = 4
Loop

GetWindowPlacement .hwnd, ip
ip.showCmd = 1 ' SW_SHOWNORMAL
SetWindowPlacement .hwnd, ip
10
Do Until IE.ReadyState = 4
Loop

GetWindowPlacement .hwnd, ip
If ip.showCmd = 3 Or ip.showCmd = 1 Then
GoTo 10
' Else
' Range("B1").Value = 1
End If
End With
' Call GETinfo
MsgBox "Done"

IE.Quit: Set IE = Nothing
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub