🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10460

Re: How to catch mouseclicks from another application?

#10460
From: Henk
Date: Fri, 09 Apr 2004 12:50
86 lines
4775 bytes
Well, I feel very stupid. I thoroughly studied this CreateFileMapping() and
MapViewOfFile() stuff but I feel like having a box with nuts and bolts but
having no idea what to construct with it.

This is how I see it (may be totally wrong)
My Borland-Builder generated MainApplication loads a MouseHook-DLL file and
puts MouseHook-DLL functions somewhere in computer memory. Using
'SetWindowHookEx' function from my MainApplication combined with the
'MouseProc' function in my MouseHook-DLL makes the windows operating system
call this DLL-'MouseProc' function when mouse messages occur, no matter
where I mouseclick on my desktop, no matter on which eventually
desktop-residing window. So far so good.
Now I start to derail. (I know you must be right) talking about: >"of other
instances of the DLL that are injected into other processes"
I do not have the slightest idea what is ment by this. I see an 'instance of
the DLL' as my MouseHook-DLL functions that are loaded by my MainApplication
somewhere into computer memory. So what is ment by these 'other instances'
and what is ment by these 'other processes'?

If , for example, I mouse-click somewhere in an Excel-Application residing
somewhere on my desktop, does that create another 'instance of my
MouseHook-DLL' meaning does it create a copy of my MouseHook-DLL in memory
and execute it? Or does it connect my MouseHook-DLL function somehow to this
Excel-process????

What is the main difference between a mouse-click on my Borland-Builder
generated MainApplication window (which has 'hooked' the 'MouseProc'
function) and a mouse-click on any other window available-on-my-desktop?

I hope to be on track soon.

greetings,

Henk


> Yes.  You are trying to intercept events from an external process, which
> means that a separate and independant instance of your DLL must be
injected
> into that process in order to hook that process.  Setting the HWND for the
> instance of the DLL that is injected into your own application will have
no
> effect on the values of other instances of the DLL that are injected into
> other processes.  Thus the need to set asside a block of shared memory so
> that they can all share the same HWND and HHOOK values.
>
> > As to me I think I don't use more than this one instance being
> > loaded by my application. Am I right?
>
> Your application has an instance loaded, but so does every other process
> have its own instance automatically loaded by the OS.
>
> > So I tried another idea
>
> I already told you what you need to do - use shared memory via
> CreateFileMapping() and MapViewOfFile().
>
> > by creating a callback function in my main application
> > that is called from the DLL's GetMsgProc function.
>
> That will not solve the problem.  That will only effect the DLL instance
> that is loaded by your own application.  It will have no effect on the
other
> instances loaded by other processes at all.
>
> > I first hand over the callback function address to the static
> > DLL variable 'MyMouseCallbackFunction'. This works fine.
>
> You are still missing the point.  Static values are NOT global across
> multiple processes.  Every process will get its own separate and
independant
> instance of the DLL loaded, each with its own local variables.  Setting
the
> variables of one instance will have no effect on the other instances at
all.
>
> > Now when I mouseclick OUTSIDE my Borland application
> > the 'MyMouseCallbackFunction' value inside the DLL is NULL.
>
> Correct, for the reasons explained above.
>
>
> Gambit
>
>
Technical Details
Message-ID: <40769c18$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <407421ef@newsgroups.borland.com> <40743aad$1@newsgroups.borland.com> <40754399$1@newsgroups.borland.com> <40758801$1@newsgroups.borland.com> <4075a4df$1@newsgroups.borland.com> <4075b6bd$1@newsgroups.borland.com> <4076476e$1@newsgroups.borland.com> <40764eac$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e0858ea1c0821ca
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-09 06:10:10 PST
From: "Henk" <h.van.winkoop@wxs.nl>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <407421ef@newsgroups.borland.com> <40743aad$1@newsgroups.borland.com> <40754399$1@newsgroups.borland.com> <40758801$1@newsgroups.borland.com> <4075a4df$1@newsgroups.borland.com> <4075b6bd$1@newsgroups.borland.com> <4076476e$1@newsgroups.borland.com> <40764eac$1@newsgroups.borland.com>
Subject: Re: How to catch mouseclicks from another application?
Date: Fri, 9 Apr 2004 14:50:30 +0200
Lines: 88
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2727.1300
NNTP-Posting-Host: 62.131.145.60
Message-ID: <40769c18$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081515032 62.131.145.60 (9 Apr 2004 05:50:32 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail