views:

139

answers:

1

Hey, I'm using D 1.041 with Tango 0.99.8 and was wondering how I would go about moving the mouse and simulating keyboard presses and getting infos from the screen, for example the color of a specific pixel on a specific coordinate. I'm using Windows.

Any help would be greatly appreciated. I want to program a class-based library with functionality that resembles AutoIt's. For example:

mouse.move(100, 200);
mouse.click(2); // 2 = Middle Mouse Click
keyboard.type('abc');

import tango.sys.win32.UserGdi;

class Mouse{
    alias SetCursorPos set_pos;
    alias GetCursorPos get_pos;
    void left_click(){
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0);
    }
    void right_click(){
        mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0);
        mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0);
    }
}

This code gives me the following error:

Error 42: Symbol Undefined _mouse_event@16 --- errorlevel 1

Any help on that? I'm still using version.

+2  A: 

This is a bug in Tango.

Tango declares mouse_event as:

void mouse_event(DWORD, DWORD, DWORD, DWORD);

while MSDN shows that it takes 5 parameters, not 4.

For serious Win32 development you should take a look at the Windows API bindings project.

CyberShadow