Image Image Image




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Get information from Internet Explorer_Server
PostPosted: Sun Jan 10, 2010 2:50 pm 
Offline
New member
User avatar

Posts: 3
Favourite Bot: my planning bot
Hi, I'm new in online botting, now trying to create iPoker bot. I'm a C# programmer and know little about c++ and COM objects. I need to get info from window with class Internet Explorer_Server. Standard sending WM_GETTEXT or GetWindowText() return empty string. Detouring TextOut() API functions maybe can do the job, but i feel I can get this info easier, because this is common window class. Maybe someone could help me how can i get info from Internet Explorer_Server class window, which is inside Shell DocObject View class window, which is inside Shell Embedding class window, which is inside PTIODEVICE (poker table) class window. Solutions on c# is preffered, but if you know how do it using c++, it is good to.


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Sun Jan 10, 2010 4:24 pm 
Offline
Senior member
User avatar

Posts: 138
Favourite Bot: the one I'm building
Targetting iPoker are we? ;)

http://www.codeproject.com/KB/cpp/yahoochattext.aspx


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Sun Jan 10, 2010 6:13 pm 
Offline
Senior member
User avatar

Posts: 200
Favourite Bot: T-X Terminator
Don't want to post my complete class here,
"dealer_msg" is the output, it is a class member.
Probably almost the sameas posted in that link :)

Code:
   bool CChatParser::g_chat_msg(HWND hwnd)
   {
         int s_len;
         BSTR dealer_msgB;

         CoInitialize(NULL);

         HINSTANCE hInst = LoadLibrary(_T("OLEACC.DLL"));
         CComPtr<IHTMLDocument2> spDoc;
         LRESULT lRes;   
         LPFNOBJECTFROMLRESULT pfObjectFromLresult = NULL;

         UINT nMsg = RegisterWindowMessage(_T("WM_HTML_GETOBJECT"));
         SendMessageTimeout(hwnd, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes);
         pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)GetProcAddress(hInst, "ObjectFromLresult");

         if(pfObjectFromLresult != NULL)
         {
            HRESULT hr;

            hr = (*pfObjectFromLresult)(lRes, IID_IHTMLDocument2, 0, (void**)&spDoc);

            if(SUCCEEDED(hr))
            {
               CComPtr<IHTMLElement> pHTMLElement;
               hr=spDoc->get_body(&pHTMLElement);         
               pHTMLElement->get_innerText(&dealer_msgB);
               s_len = SysStringLen(dealer_msgB);
            }
            else
            {
               s_len = 0;
            }
         }

         FreeLibrary(hInst);

         if(s_len > 1 && s_len < 100000)
         {
            dealer_msg_len = s_len+1;

            // sloppy conversion but in this case works, not needed depending on what you use
            for(int j=0;j<s_len;j++) dealer_msg[j] = dealer_msgB[j];
            dealer_msg[s_len] = '\0';
         }
         else
         {
            return false;
         }

         SysFreeString(dealer_msgB);

         return (pfObjectFromLresult != NULL);
   }


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Mon Jan 11, 2010 6:00 pm 
Offline
New member
User avatar

Posts: 3
Favourite Bot: my planning bot
Thank you. Your answers took me to the right way:) And I could do it using c#, so if somebody is interested, i can post my code here.


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Sat Jan 16, 2010 4:00 pm 
Offline
Senior member
User avatar

Posts: 232
Favourite Bot: Poki
Azz101 wrote:
Thank you. Your answers took me to the right way:) And I could do it using c#, so if somebody is interested, i can post my code here.


I would like to see some dealertext-grabbing code for c# :)


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Mon Jan 18, 2010 5:06 am 
Offline
New member
User avatar

Posts: 1
Favourite Bot: TBD
cow_leecher wrote:
Azz101 wrote:
Thank you. Your answers took me to the right way:) And I could do it using c#, so if somebody is interested, i can post my code here.


I would like to see some dealertext-grabbing code for c# :)


I wouldn't mind a look at it also, now that you have my curiosity peaked.


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Mon Jan 18, 2010 7:13 pm 
Offline
New member
User avatar

Posts: 3
Favourite Bot: my planning bot
private const int SMTO_ABORTIFHUNG = 0x2;

private static Guid IID_IHTMLDocument2 = typeof(IHTMLDocument2).GUID;

[DllImport("OLEACC.dll")]
private static extern int ObjectFromLresult(int lResult, ref Guid riid, int wParam, ref IHTMLDocument2 ppvObject);
//Register window message
[DllImport("user32.dll", EntryPoint = "RegisterWindowMessageA")]
public static extern int RegisterWindowMessage(string lpString);

//SendMessage async
[DllImport("user32.dll", EntryPoint = "SendMessageTimeoutA")]
public static extern int SendMessageTimeout(IntPtr hwnd, int msg, int wParam, int lParam, int fuFlags, int uTimeout, out int lpdwResult);

public static IHTMLDocument2 GetInternetExplorerServerWindowDOM(IntPtr hwnd)
{
IHTMLDocument2 document = null;
int lRes;

if (!hwnd.Equals(IntPtr.Zero))
{
int lngMsg = Win32.RegisterWindowMessage("WM_HTML_GETOBJECT");
if (lngMsg != 0)
{
Win32.SendMessageTimeout(hwnd, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, out lRes);
if (lRes != 0)
{
int hr = ObjectFromLresult(lRes, ref IID_IHTMLDocument2, 0, ref document);
}
}
}
return document;
}

To get chat text use .body.innerText property of GetInternetExplorerServerWindowDOM() result IHTMLDocument2 object. Need to add reference to Microsoft.mshtml and add "using mshtml;" statement.


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Tue Jan 19, 2010 3:24 am 
Offline
Senior member
User avatar

Posts: 232
Favourite Bot: Poki
thanks, it worked :)


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Thu Jul 08, 2010 3:23 am 
Offline
New member
User avatar

Posts: 1
Favourite Bot: holdembot
It doesn't work for me =(

lngMsg = 49797, so it is not "0"
But lRes is always "0".

I'm sure that hWnd is right, because printWindow shows chat screenshot.

Can you help me?


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Mon Aug 30, 2010 8:32 pm 
Offline
New member
User avatar

Posts: 2
Favourite Bot: zero
I have the same problem

lngMsg = 49797, so it is not "0"
But lRes is always "0".

pls help


Top
 Profile E-mail  
 
 Post subject: Re: Get information from Internet Explorer_Server
PostPosted: Mon Aug 30, 2010 10:38 pm 
Offline
New member
User avatar

Posts: 2
Favourite Bot: zero
commaster wrote:
I have the same problem

lngMsg = 49797, so it is not "0"
But lRes is always "0".

pls help

Solved it :xx20 The problem is wrong hwnd you have propadbly hwnd of IE (Class IFrame) but you need hwnd of window inside (Class Internet Explorer_Server) you have to enumerate child and get right hwnd


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 


Who is online

Users browsing this forum: MSNb and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: