|
-
Aug 26th, 2001, 12:48 PM
#1
Thread Starter
Member
Get all the active windows
Alright this is making me mad...I've been going into other posts for some time now and they ALL havent answer my question, or didnt work!
How can I get a window's text when its opened?C:\Windows\System\1~guard.txt)
e.g: [8-26-01] -Window opened here-
Thank you!
Last edited by PunK; Aug 26th, 2001 at 01:18 PM.
-
Aug 26th, 2001, 01:45 PM
#2
Frenzied Member
Maybe it is not the replies you get, but the question you ask.
This line is confusing. What is the path at the end of the question for?
How can I get a window's text when its opened?C:\Windows\System\1~guard.txt)
What are you trying to convey here?
e.g: [8-26-01] -Window opened here-
What do these lines mean?
Are you trying to capture the window text JUST as the window is opened?
Is this for every window in the os?
Is it just for windows in your program?
What exactly are you trying to do?
Greg
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
-
Aug 26th, 2001, 02:12 PM
#3
Thread Starter
Member
-
Aug 26th, 2001, 05:38 PM
#4
I would suggest you use a WH_SHELL hook, and take action when the HSHELL_WINDOWCREATED code is recieved.
-
Aug 27th, 2001, 03:45 PM
#5
Thread Starter
Member
.
rrrrrrright.. Sorry, I'm not that good at VB
-
Aug 27th, 2001, 04:24 PM
#6
Well, since we want it to respond globally, you need to put your procedure in a standard DLL. But since VB cannot create standard DLLs, you need to use C++ or Delphi.
Here is some C++ should that should work.
Code:
#include <windows.h>
#include <fstream.h>
HHOOK hHook;
extern "C" __declspec(dllexport) LRESULT CALLBACK ShellProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if( nCode == HSHELL_WINDOWCREATED )
{
LPSTR lpBuff;
if(GetWindowText( (HWND)wParam, lpBuff, GetWindowTextLength((HWND)wParam)+1))
{
ofstream file("C:\\MyLog.txt", ios::app);
file << "'" << lpBuff << "'" << " OPENED AT: " << __DATE__ << endl;
file.close();
}
}
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
-
Aug 27th, 2001, 04:33 PM
#7
Now create a new VB project, and add the following code to it.
VB Code:
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Const WH_SHELL = 10
Private hHook As Long
Private hModule As Long
Private Sub Form_Load()
Dim lpfn As Long
'Change path to path of the ShellProc Dll.
hModule = LoadLibrary("C:\Windows\Desktop\ShellProcDll")
If hModule <> 0 Then
lpfn = GetProcAddress(hModule, "_ShellProc@12")
If lpfn <> 0 Then hHook = SetWindowsHookEx(WH_SHELL, lpfn, hModule, 0)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If hHook <> 0 Then UnhookWindowsHookEx (hHook)
End Sub
-
Aug 27th, 2001, 08:05 PM
#8
Thread Starter
Member
asdf
I dont mean to be rude or anything..but.........WHAT THE ****!?
-
Aug 27th, 2001, 10:05 PM
#9
Registered User
The hook is there so that everytime a new window is created, you can respond to it.
VB cannot create such a hook, so he used C++ and then showed you how to implement with VB.
-
Aug 28th, 2001, 08:44 AM
#10
Re: asdf
Originally posted by PunK
I dont mean to be rude or anything..but.........WHAT THE ****!?
What part don't you get? The C++ part?
Want me to just send you the projects? (and you can modify them where necessary)
-
Aug 28th, 2001, 03:56 PM
#11
Thread Starter
Member
asdf
Sure, just send the project files to this email address
-
Aug 28th, 2001, 05:02 PM
#12
Ok.
I didn't know whether you had C++ installed, so I sent the source files as well as the compiled DLL.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|