|
|
Hi everybody,
I've asked this question before, and I'M NOW WILLING TO PAY (with PayPal) for a solution that fits my needs because time is not a thing I have in abundance and I need this thing quickly!
Here's, from a user point of view, what I want the resulting solution app to do:
####
When pressing a modifier key (ctrl for example), clicking (right or left mouse) ANY text-based string in ANY application or object (folder names, titles, list items, etc) in the operating system (win95+), a small window should appear next to the clicked-on text informing the user what text he/she has clicked on.
####
Two approaches (as far as I know) are possible: Either you can go the OCR (Optical Character Recognition) way where you actually capture and analyze what the screen pixels look like. An OCR engine is hard to develop yourself and expensive to license or buy. Or you can use the MS Accessibility API to do this... (fairly undocumented but supposed to do the trick). This is an API used for developing apps that for instance can read text on the screen out loud.
Anyone with the appropriate knowledge and skills who want to take this on?
We can discuss the details more privately when a first contact has been established. Thx everybody and thx for a great forum!
/Tommy
|
|
|
|
|
Can mouse hooking, then using WindowFromPoint() and ChildWindowFromPoint() help in what you want?
|
|
|
|
|
How to Rotate the EmfFile With out using SetWorldTransform?
|
|
|
|
|
I want to use the internet explorer inside my application. This works fine:
AtlAxWinInit();
HWND hwndChild=::CreateWindow( "AtlAxWin",
"Shell.Explorer.1",
WS_CHILD|WS_VISIBLE,
0,0,0,0,
hwnd,NULL,
::GetModuleHandle(NULL),
NULL);
IUnknown *pUnk=NULL;
AtlAxGetControl(hwndChild,&pUnk);
CComPtr<IWebBrowser2> spBrowser;
pUnk->QueryInterface(IID_IWebBrowser2,(void**)&spBrowser);
if(spBrowser)
spBrowser->put_Visible(VARIANT_TRUE);
But, I want this to be more abstract. How can I use the interface IDispatch instead.
My attempt to abstract it, returned a DISP_E_UNKNOWNNAME while calling GetIDsOfNames with "Visible" (it IS a member of IWebBrowser2). It has to be something like that...
using: [VISUAL STUDIO 6.0] [WIN98/2]
|
|
|
|
|
Hello all !
I want to compare two bitmaps.I already use GetPixel() to get all pixels of bitmaps but it very very too slow (because i search bitmap in whole page).
i want to use CRC but it seems hard. you know an easy way to use CRC ?
thx in advance
|
|
|
|
|
You want to compare whether two bitmaps are the same? There are enough CRC classes out here on codeproject, and they are very easy to use.
Alternatively, you could try a memcmp on your loaded bitmaps, but I don't know whether this will work.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Gregor S. wrote:
You want to compare whether two bitmaps are the same?
yes exactly !
Gregor S. wrote:
There are enough CRC classes out here on codeproject
I have already find something but it's hard for me, I continue to seek !
thx
|
|
|
|
|
This is a way to do it using membmp() , might be usefull.
HBITMAP hbmp1 = NULL, hbmp2 = NULL;
BITMAP bmp1, bmp2;
.
.
.
.
GetObject(hbmp1, sizeof(BITMAP), &bmp1);
GetObject(hbmp2, sizeof(BITMAP), &bmp2);
if(bmp1.bmBitsPixel != bmp2.bmBitsPixel ||
bmp1.bmHeight != bmp2.bmHeight || bmp1.bmWidth != bmp2.bmWidth)
return 0;
else
{
LPBYTE data1 = (LPBYTE)bmp1.bmBits,
data2 = (LPBYTE)bmp2.bmBits;
DWORD bmWidth = bmp1.bmWidth * (bmp1.bmBitsPixel / 8);
DWORD bmWidthBytes = bmWidth + (4 - bmWidth % 4) * bool(bmWidth % 4);
DWORD bytesize = bmp1.bmHeight * bmWidthBytes;
if(memcmp(data1, data2, bytesize) == 0)
return 1;
}
I tried it with 600x600 bitmaps and worked well and with good performance.
However there is one problem, if the bitmaps are indexed and they have same bits but different color tables, they will still match as there is no comparision between the color tables here.
If you need it, it should be easy using GetDIBColorTable() function then comparing the two color tables' arrays before comparing the bits.
If you are using VC++.Net and CImage class the whole thing will be much easier.
|
|
|
|
|
ok thank you for your answer !!
i'm going to try and understand your code.
i hope it is fast, because i will compare a lot of bitmap
MAAK wrote:
However there is one problem, if the bitmaps are indexed and they have same bits but different color tables, they will still match as there is no comparision between the color tables here.
all my image will have same nbr of bit, i think i will have to use
GetDIBColorTable()
thx !
I keeps you informed
|
|
|
|
|
Just to ensure there is no confusion. The bits I mean are the values of pixels, sorry for that term, but it's used in the BITMAP structure.
What I do mean, that if you are comparing images with true colors (24-bit color depth or more) there will be no problem, but for indexed images(16-bit, 8-bit etc) the problem of color table arise.
If all pixel values match in an indexed bitmaps that does not mean their color tables match.
I just wanted to be clearer.
|
|
|
|
|
AH ok ok, sorry I had not understood !
so i shouldn't have probleme with that.
thank you to take your time to explain me.
|
|
|
|
|
ok, i try your example, but i have a problem with :
if(memcmp(data1, data2, bytesize) == 0)
i have always windows error, i think it's because bytesize
you know how can i find the problem?
thx in advance
|
|
|
|
|
I assume that the error is a crash due to access viloation, so firstly check if either pointers are not null, this method works only with DIB bitmaps (i.e. you can't try it with bitmaps of a Client area DC or a Window DC) otherwise the pixels array is null.
If they are not null then I need to know the winodws version you use and the bitmaps dimensions and color depth to identiy the problem.
You my also try to replace the 4 with 2 in this line
DWORD bmWidthBytes = bmWidth + (4 - bmWidth % 4) * bool(bmWidth % 4);
|
|
|
|
|
Thx to help me !
MAAK wrote:
I assume that the error is a crash due to access viloation
completely !
this is what i do :
1 - I do a snapshot and save the bitmap in Clipboard
CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame();
CRect WndRect;
CWnd* pMDIClientWnd = CWnd::FromHandle(pFrame->m_hWndMDIClient);
GetClientRect(WndRect);
CBitmap bitmap;
CDC *dcP;
CDC memDC;
CRect rect;
dcP = GetWindowDC();
memDC.CreateCompatibleDC(dcP);
bitmap.CreateCompatibleBitmap(dcP,WndRect.right, WndRect.bottom);
CBitmap *pOldBitmap = memDC.SelectObject(&bitmap);
memDC.BitBlt(0, 0, WndRect.right,WndRect.bottom, dcP,2 , 2, SRCCOPY);
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_BITMAP, bitmap.GetSafeHandle());
CloseClipboard();
memDC.SelectObject(pOldBitmap);
2 - i want to compare tw bitmap
HBITMAP hbmp1 = (HBITMAP) SignatureBitmap;
HBITMAP hbmp2 = (HBITMAP) bitmap;
BITMAP bmp1, bmp2;
GetObject(hbmp1, sizeof(BITMAP), &bmp1);
GetObject(hbmp2, sizeof(BITMAP), &bmp2);
if(bmp1.bmBitsPixel != bmp2.bmBitsPixel || bmp1.bmHeight != bmp2.bmHeight || bmp1.bmWidth != bmp2.bmWidth)
AfxMessageBox("prob");
else
{
LPBYTE data1 = (LPBYTE)bmp1.bmBits,
data2 = (LPBYTE)bmp2.bmBits;
DWORD bmWidth = bmp1.bmWidth * (bmp1.bmBitsPixel / 8);
DWORD bmWidthBytes = bmWidth + (2 - bmWidth % 2) * bool(bmWidth % 2);
DWORD bytesize = bmp1.bmHeight * bmWidthBytes;
if(memcmp(data1, data2, bytesize) == 0)
AfxMessageBox("goooooood");
bitmap.Detach();
}
P.S : Two Bitmaps are two snapshot with few second interval (they have same confoguration).
i'm work with VC7, Windows XP with color definition 32bits.
|
|
|
|
|
The problem is as I expected in the previous reply. You are working with DDBs (Decive Dependent Bitmaps) and not DIB (Decive Independent Bitmaps). As far as I know there is no easy way (if exist) to get the bits of DDBs, and the BITMAP structure returned from them points to NULL memory address.
To be more clear any bitmaps got from windows DC , clients DC or any bitmaps created compatible with them are DDBs, and I think, but not sure, that they have variable size.
DIBs are the bitmaps that are normally used in file saving and it has a definit size.
More information about DDBs and DIBs
Hope you are not disappointed, but there is an easy solution, especially since you use VC++7 and have the CImage class.
All you have to do is, instead of bliting into a memory DC compatible with the window DC, you should create a CImage object and blit int it the window DC;
this is how to be get a DIB from DDB using CImage.
CDC *dcP;
CDC memDC;
CRect WndRect;
dcP = GetWindowDC();
GetWindowRect(WndRect);
CImage im;
im.Create(WndRect.Width(), WndRect.Height(), 24);
memDC.Attach(im.GetDC());
memDC.BitBlt(0, 0, WndRect.right,WndRect.bottom, dcP,2 , 2, SRCCOPY);
memDC.Detach();
im.ReleaseDC();
HBITMAP hbmp = im.Detach();
The CImage is included in <atlimage.h> and please note that it needs the GDI+ runtimes. The GDI+ is inlcude in a file named gdiplus.dll, it comes already with WinXP and VS.Net, but if you are going to use it at any system other than WinXP then the DLL should be put with the application file.
For the clipboard part, copying DIBs to clipboard is more complicated than copying DDBs, you may refer to this page in the msdn, SetClipboardData Function .
However if think that you can just copy DDBs to clipboard then convert them to DIB when pasting.
I hope you are not bored from that lecture;)
|
|
|
|
|
MAAK wrote:
Hope you are not disappointed
arf... a litlle bit
MAAK wrote:
HBITMAP hbmp = im.Detach(); //you now have handle to DIB ready for use
ok now i can work with hbmp and it will work fine?
i try to compare the same bitmap :
BITMAP bmp1, bmp2;
GetObject(hbmp, sizeof(hbmp), &bmp1);
GetObject(hbmp, sizeof(hbmp), &bmp2);
if(memcmp(&bmp1, &bmp2, sizeof(bmp1) - sizeof(bmp1.bmBits)))
{
AfxMessageBox("Prob");
}
else
{
LPBYTE data1 = (LPBYTE)bmp1.bmBits, data2 = (LPBYTE)bmp2.bmBits;
DWORD bmWidth = bmp1.bmWidth * (bmp1.bmBitsPixel / 8);
DWORD bmWidthBytes = bmWidth + (2 - bmWidth % 2) * bool(bmWidth % 2);
DWORD bytesize = bmp1.bmHeight * bmWidthBytes;
if(memcmp(data1, data2, bytesize) == 0)
AfxMessageBox("gooooooooooooooood");
}
but i have the same error
there is something which I did not understand?
|
|
|
|
|
You wrote in the last reply the code for obtaining one of the bitmaps, but you did not wrote how the other is obtained (and did not say if it was the same way or not).
Any way put this diagnositc lines of code before the if(memcmp(...
if(data1 == 0)
AfxMessageBox("Error in bitmap 1");
if(data2 == 0)
AfxMessageBox("Error in bitmap 2");
if the data of an HBITMAP is NULL then it should be either a DDB or and invalid handle, however if it's invalid handle the BITMAP structure won't be obtain in the first place. So, if the BITMAP structure is obtained successfully and the data is NULL then it's probably a DDB. If you debugged the program and stepped after the two calls to GetObject() you may check the values of the bmp1 and bmp2 , if the HBITMAP is for a DDB you'll see all the members have normal values except the bmBits, which will contain 0.
By the way, do not compare the BITMAP structure using memcmp() because if both are inavalid you may obtain unexpected reults
|
|
|
|
|
hi,
in degug i see data1 & data2 are not good :
data1 = 0xcccccccc <Ptr> incorrect
data2 = 0xcccccccc <Ptr> incorrect
now i try to convert DDB to DIB....
but it is very confused for me.
|
|
|
|
|
You know how get pointer on the bitmap which is in clipboard ??
THX
|
|
|
|
|
very confused: u want to compare a lots bitmaps, but last request sounds that there are lots of bitmaps on clipboard.
the key for fast comparing is if u can get bitmap buffer properly (BITMAP structure does not work always), where are those bitmaps? in files? VC resource?
includeh10
|
|
|
|
|
Hi,
I have an MFC app with ActiveX controls as child views.
The frame's accelerator handling seems to catch hotkeys and translate them into menu commands (e.g. Ctrl-C --> ID_EDIT_COPY), even though the ActiveX has the focus.
One of the controls needs a fairly extensive keyboard handling, that might in certain cases even interfere with the "application" hotkeys.
Now I see three solutions, and am looking for recommendations which route to take:
a) adding all accelerators to the MFC application, and handling the WM_COMMAND's. Doesn't sound like a good design though (as the ActiveX'es should be allowed to define their own hotkeys)
b) "somehow" separate the accelerator tables - the nicest would be one for the applicaiton, and one provided by the ActiveX - is this possible?
c) Usign a keyboard hook as long as one of activeX has focus.
d) Other ideas?
TIA
Peter
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
hi,
i want to send a message from a thread to my Dialog, but how do i get the HWND value from my dialog? I created the dialog by doing DoModal()
thanks in advance,
[]D [] []D []
|
|
|
|
|
does GetSafeHwnd() not work?
Bryce
|
|
|
|
|
nope, it gives back a NULL value... so i need to get it in another way...
i don't even know if the dialog has its own HWND, maybe i need to get it in a different way.
[]D [] []D []
|
|
|
|
|