anyone know?
anyone know?
*bump*
is this window in u'r application?Quote:
Originally posted by qpabani
anyone know?
Or is it any external window apart from u'r application?
anita
the windows are outside my program..
im sure there was some code that would close or minimize programs based on its text..
yes, you can use the sendmessage api to change the windowstate...
does anyone have the code?
Here is an example . . .
http://www.vbforums.com/showthread.p...hreadid=150572
is it possible to do that without timers? that is, when a command button is click, it closes (or minimizes - depending on the button clicked) all windows if their title contains certain text?
is it possible to do that without timers? that is, when a command button is click, it closes (or minimizes - depending on the button clicked) all windows if their title contains certain text?
In a ModuleIn a FormVB Code:
Option Explicit Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Private Declare Function CloseWindow Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Public Sub MinimizeAllIE() Call EnumWindows(AddressOf EnumWindowProc, 0) End Sub Private Function EnumWindowProc(ByVal hWnd As Long, ByVal lParam As Long) As Long Dim sBuffer As String sBuffer = Space(256) sBuffer = Left(sBuffer, GetClassName(hWnd, ByVal sBuffer, 256)) If InStr(LCase(sBuffer), "ieframe") > 0 Then Call CloseWindow(hWnd) End If EnumWindowProc = hWnd End FunctionYou can alter the code to check the Windows "Caption" if you want to just target Windows with certain text in the Caption.VB Code:
Option Explicit Private Sub Command1_Click() MinimizeAllIE End Sub
how about other programs?
is there no way to close all windows with a certain text in their title?
You know the best way to learn is to Try some things:VB Code:
Option Explicit Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Public Sub MinimizeAllIE() Call EnumWindows(AddressOf EnumWindowProc, 0) End Sub Private Function EnumWindowProc(ByVal hwnd As Long, ByVal lParam As Long) As Long Dim sBuffer As String sBuffer = Space(256) sBuffer = Left(sBuffer, GetWindowText(hwnd, ByVal sBuffer, 256)) If InStr(LCase(sBuffer), "internet explorer") > 0 Then Call CloseWindow(hwnd) End If EnumWindowProc = hwnd End Function
so far so good.. i get the hwnds of all the IE windows, however it wont close em..
call closewindow hwnd does nothing.. the window still exists :(
anyone know how to close this window?
: I Know this is quite an old thread but:
I get the following error
when i come to this with my codeQuote:
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:
Invalid use of AddressOf operator
---------------------------
OK Help
---------------------------
VB Code:
Public Sub MinimizeAllIE() Call EnumWindows(AddressOf EnumWindowProc, 0) End Sub
I dont know Y Tho, i added the code above, and it dont work or dat....
Is the code in a module?
yeah, it was... & I tried it in the form too [just in case] and it's the same error.