2

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?
nakiya
  • 14,063
  • 21
  • 79
  • 118
  • Many of us have no idea what Garena is, but does that mean you have the source code of the list box? Are you trying to change the behavior of a program you have no source code? – karlphillip Oct 29 '10 at 12:08

3 Answers3

2

If you're willing to step away from using C, you can implement (very easily) a solution to automate clicks using c++ (windows apis), python (wrapper for windows apis), or simply by downloading AutoIt (a scripting language specifically designed to automate tasks).

I've used all three methods (python being my favorite as I wrote that first and had a HUGE wrapper around the available methods) and they all work great!!!

Community
  • 1
  • 1
g19fanatic
  • 10,567
  • 6
  • 33
  • 63
0

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
  • 2,247
  • 5
  • 20
  • 22
0

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
  • 11,211
  • 2
  • 27
  • 38