tags:

views:

91

answers:

3

alt text

I want to create an auto-tunneler for Garena. What basically has to be done is iterate through all the items in the list box (in the right - I think that is what it is.), right click and click tunnel on each of them. I only have a C compiler with me atm. Any ideas on how to do this? What API calls and so on?

EDIT: Few clarifications as I see my original question was rather vague.

  1. I do not have the source code of Garena nor do I waish to reverse engineer it.
  2. I want to write a standalone application which will send messages or mouse clicks to the window.I was under the impression that this is possible. Am I wrong?
A: 

You can use combination of LB_GETCOUNT, LB_GETTEXTLEN, and LB_GETTEXT messages. The following Delphi code iterate through all the items in a list box:

  function GetAllListBoxItems(hWnd: HWND; slItems: TStrings): string;
  var
    sRetBuffer: string;
    i, x, y: Integer;
  begin
    x := SendMessage(hWnd, LB_GETCOUNT, 0, 0); // Gets the total number of items
    for i := 0 to x - 1 do begin
      y := SendMessage(hWnd, LB_GETTEXTLEN, i, 0);
      SetLength(sRetBuffer, y);
      SendMessage(hWnd, LB_GETTEXT, i, lParam(PChar(sRetBuffer) ) );
      slItems.Add(sRetBuffer);
    end;
  end;

Reference

Vantomex
A: 

Well, if it is a standard list-view control you can you the standard list-view messages. Otherwise you would have to reverse engineer how it works. You can use Spy++ to determine what kind of control it is.

Assuming it is a list-view control, you can get the number of items in it with LVM_GETITEMCOUNT. Then you need to invoke the "Tunnel" command on each item. This is highly dependent upon how the window proc is implemented. One possible approach might be to select each item (LVM_SETITEMSTATE) and then send a WM_COMMAND to the list-view control's parent specifying the menu identifier of "Tunnel". However, this is an implementation detail so you will have to use Spy++ to figure it out. First you should see what messages are sent when you do it manually with the mouse, then you should try and reproduce those messages programmatically.

Luke