The MASM Forum

Miscellaneous => Miscellaneous Projects => Windows Projects => Topic started by: xiaolaba on May 23, 2018, 02:15:56 AM

Title: Win32 hookapi, mouse pointing and to get the text, did not work
Post by: xiaolaba on May 23, 2018, 02:15:56 AM
hello, this new comer to this forum, looking for help or advice.

The goal to make a simple program, pickup the text by mouse pointing and send to editbox, the next goal will do some simple lookup for required information, something like dictionary application sort of that, however to develops the very own lookup table indeed.

References, some very old code on some webpage and does corrected some build script, a win32 program is able to run successfully but it does not come to promise for our goal as nothing show up.

The original win32 asm code, came with errors and no way to be assembled. Upon some reading and try & error, my build script and done for dll & exe.

The code and inital build, copy to GITHUB, https://github.com/xiaolaba/masm32_win10_screen_capture_text (https://github.com/xiaolaba/masm32_win10_screen_capture_text)
Title: Re: Win32 hookapi, mouse pointing and to get the text, did not work
Post by: jj2007 on May 23, 2018, 02:57:45 AM
Hi xiaolaba,

Welcome to the forum :icon14:

GitHub is very clumsy for a small project. I have attached your source. It builds fine, but it does not run well.

Can you explain in a few words,
- what exactly the program should do?
- why you need the hook?

I suppose you use Google translate (http://translate.google.it/). Try to use short and simple phrases.

Greetings to Taiwan,
JJ
Title: Re: Win32 hookapi, mouse pointing and to get the text, did not work
Post by: HSE on May 23, 2018, 06:10:33 AM
Welcome xiaolaba!

But you must know that if forum members upload all our code with errors it's possible to down Github servers  :biggrin:
Title: Re: Win32 hookapi, mouse pointing and to get the text, did not work
Post by: xiaolaba on May 23, 2018, 10:57:56 AM
hi there, thanks for warm greeting. :t
we are trying the best to make thing better as life is short.
Title: Re: Win32 hookapi, mouse pointing and to get the text, did not work
Post by: xiaolaba on May 23, 2018, 10:59:57 AM
Quote from: HSE on May 23, 2018, 06:10:33 AM
Welcome xiaolaba!

But you must know that if forum members upload all our code with errors it's possible to down Github servers  :biggrin:

hi there, thanks for warm greeting. :t

we are trying the best to make thing better as life is short.
Title: Re: Win32 hookapi, mouse pointing and to get the text, did not work
Post by: xiaolaba on May 23, 2018, 11:11:42 AM
Quote from: jj2007 on May 23, 2018, 02:57:45 AMHi xiaolaba,

Welcome to the forum :icon14:

GitHub is very clumsy for a small project. I have attached your source. It builds fine, but it does not run well.

Can you explain in a few words,
- what exactly the program should do?
- why you need the hook?

I suppose you use Google translate (http://translate.google.it/). Try to use short and simple phrases.

Greetings to Taiwan,
JJ

hi JJ, thanks for warm greeting. :t
the original author was saying, run the program, moving mouse elsewhere at point of some text, then the edit box will show you the exact text. such technique involve hook api and some microsoft published API and some non-documented.

Microsoft has app named bing dictionary, i.e. https://play.google.com/store/apps/details?id=bingdic.android.activity&hl=en_US
you may try and to grap the idea of how screen to text

others and description,
https://www.mjtnet.com/blog/2007/12/12/capturing-screen-text/ (https://www.mjtnet.com/blog/2007/12/12/capturing-screen-text/)
https://scialert.net/fulltextmobile/?doi=itj.2013.1668.1672 (https://scialert.net/fulltextmobile/?doi=itj.2013.1668.1672)
Title: Re: Win32 hookapi, mouse pointing and to get the text, did not work
Post by: jj2007 on May 23, 2018, 04:46:39 PM
From one of your links (https://scialert.net/fulltextmobile/?doi=itj.2013.1668.1672):
QuoteInterception of character output through API
Basic thinking of code interception: In order to achieve the interception of API such as ExtTextOutA/Ext TextOutW, a dynamically generated "JMP<replacement function>" instruction should be placed at the function entry and the JMP operand is the address of an intercepted replacement function which is provided (Richter, 2000). When the API is called, the JMP instruction will be executed firstly, jumping to the replacement function. Replacement functions are responsible for works like getting parameter from stack, calculating coordinate of the string, siphoning off words at the mouse position. After the execution is c ompleted, intercepted function will be called again by replacement function to finish normal character outputting and then turn back.

All that is not impossible, but a simple GetWindowTextW should be sufficient if the control behaves normally.
If the control does not behave normally, it will be complicated. And most browsers use controls that have little resemblance to normal edit or static controls. Perhaps they use GetTextOut, perhaps they don't...