views:

420

answers:

2

Hi guys

I am working on a project in 8086 assembly on windows machine and I need to know which mouse button has been clicked. What are the interrupts for this? or how do I go about finding this out?

Thanks

+1  A: 

On a "DOS" machine, look into Software Interrupt 0x33.
Command AH = 0x03 returns the mouse button pressed in register CX (along with mouse coordinates and other info, in other registers).

If available, it is of course much easier to user the Windows API for this purpose, as indicated in matja's answer.

mjv
+4  A: 

If you're making a DOS program that runs under windows, you can use software interrupt 0x33, function 3, which returns the button status in the BL register :

    mov   ax,0x3
    int   0x33
    test  bl,1
    jnz   left_button_pressed
    test  bl,2
    jnz   right_button_pressed

More info here http://www.ctyme.com/intr/rb-5959.htm

If you're making a native Windows application, you can test for button presses by checking for the standard mouse button messages (WM_LBUTTONDOWN/UP , WM_RBUTTONDOWN/UP , WM_MBUTTONDOWN/UP) passed to your registered WndProc for the main window created by your program.

The function declaration for the WndProc is "LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);", the message type is passed in uMsg, so you'd check the DWORD at [esp+12] and compare it with the message ID you want to handle.

matja
Nice one that works brillent! Thanks
Ciarán

related questions