News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Mouse Macro in Assembler?

Started by legaata, August 27, 2011, 01:14:35 AM

Previous topic - Next topic

legaata

Hi, I'd like to know how to make a mouse macro using Assembler.
Of course, changing the position is the easiest part.
The hardest part, which I don't seem to know how to solve,
is how to set the button status?

I assume you have to use any of the following functions:
Mouse Interrupt Setup Functions
   INT 33,C   Set Mouse User Defined Subroutine and Input Mask
   INT 33,14  Swap Interrupt Subroutines

   Alternate Mouse Interrupt Setup Functions
   INT 33,18  Set Alternate Subroutine Call Mask and Address
   INT 33,19  Get User Alternate Interrupt Address

But I don't really understand what they mean, any explanation would be much appreciated.

dedndave

the best resource for INT 33h info is probably Ralf Brown's Interrupt List

http://www.cs.cmu.edu/~ralf/

http://www.cs.cmu.edu/~ralf/files.html

the basic list is 6 ZIP files
once unzipped, INT 33h is in a file named INTERRUP.N (a text file), from inter61c.zip

MichaelW

I have the Microsoft Mouse Programmer's Reference from 1991 and none of the 52 functions that it documents allow you to programmatically set the button status. The interrupt subroutine functions allow you to effectively install an interrupt handler for the mouse and specify the mouse events that will cause the handler to be called. The interrupt handler allows your program to respond to mouse events without having to run in a loop where it polls for these events. What is your purpose for setting the button status?
eschew obfuscation

legaata

Quote from: MichaelW on August 27, 2011, 04:41:32 AM
I have the Microsoft Mouse Programmer's Reference from 1991 and none of the 52 functions that it documents allow you to programmatically set the button status. The interrupt subroutine functions allow you to effectively install an interrupt handler for the mouse and specify the mouse events that will cause the handler to be called. The interrupt handler allows your program to respond to mouse events without having to run in a loop where it polls for these events. What is your purpose for setting the button status?

The purpose of setting the button status is to make a mouse macro, because as part of a mouse macro you need to not only move the mouse around but also to make it click.

What is meant by "interrupt handler", is this the program that sets the outregs to be returned if the interrupt is called?
Does this mean you could install an interrupt subroutine and program it to return specific button status if the interrupt is called?

"Respond to mouseevents", what does this mean? Is a mouse event when the position, button status of the mouse etc changes, or is it when the mouse interrupt is called?

Surely there must be some easy way to do this, since there are loads of free mouse macros out there?

legaata

Quote from: dedndave on August 27, 2011, 02:00:58 AM
the best resource for INT 33h info is probably Ralf Brown's Interrupt List

I will look into it, thanks.

Another solution maybe would be to download a simple mouse macro and disassemble it into assembler code to see how it works? I know even a simple assembler as debug can also be used as a disassembler.

dedndave

i think you may be misusing the term "macro"
as Michael mentioned, there is no way to set the status of the mouse buttons, other than clicking the buttons   :P
however, you may alter the values that are stored in memory that represent the button status

an "interrupt handler" is a section of code that is normally not explicitly called by some other code
rather, it is called by the processor upon occurance of an event, such as a hardware event
in the case of the mouse, the interrupt handler is called when the user moves the mouse or clicks one of the buttons

what that means to you is, you do not have to repeatedly check the mouse status to see if it has changed
the interrupt handler can record mouse events and trigger other events
for example, it may cause the cursor to be redrawn
another example - in a game, clicking the left button may cause the program to "fire" a missle

a macro is an assembler tool that may be used to save typing, basically
example...

first, a macro is defined
SetVal  MACRO

        mov     eax,3
        add     ebx,eax

        ENDM


once it has been defined, it may be referenced in source code
each time the "SetVal" macro is referenced, it is expanded into the 2 lines of the macro
        mov     ebx,6
        SetVal
        inc     eax


the assembler will generate the following code...
        mov     ebx,6
        mov     eax,3
        add     ebx,eax
        inc     eax


that is a very simple example
macros can recognize arguments and can be much more complex

MichaelW

So you're trying to create the mouse equivalent of a keyboard "macro", that can return a pre-programmed sequence of simulated mouse button presses and releases and cursor motions to a running program? Does it need to work for any mouse-aware program, or just for your own program?

Something that I failed to make clear in my previous post is that the interrupt subroutine functions (for example, function 12d Set Interrupt Subroutine Call Mask and Address) allow you to effectively install a handler for the mouse hardware interrupt. To implement a mouse macro you will need to install a handler for the mouse software interrupt, Interrupt 33h.
eschew obfuscation

dedndave

you can use
INT 21h, AH=35h to get the address of the original interrupt routine (store it)
INT 21h, AH=25h to set the new interrupt routine address
when you are done, use INT 21h, AH=25h again to restore the original handler

later versions of INT 33h have a special mechanism for this
you can switch between 3 handlers on the fly and set their mask bits

legaata

Well, I am beginning to think that the macros which can be downloaded from Internet works by setting the button status, not on assembler level, but on a higher level of language. Therefore, I think the kind of program I want cannot be written in assembler, but must be written in a windows based language. Unless you find a way to access the Windows API through assembler, that is, which might be very hard.

Quote from: MichaelW on August 29, 2011, 03:26:53 AM
So you're trying to create the mouse equivalent of a keyboard "macro", that can return a pre-programmed sequence of simulated mouse button presses and releases and cursor motions to a running program? Does it need to work for any mouse-aware program, or just for your own program?

For any mouse aware program, at least in windows, that's correct.

dedndave

if you are talking API, you are not talking INT 33h
INT's are an old 16-bit DOS mechanism
modern API functions are 32 or 64 bit

if you can do it, it can be done with ASM - although, it may not always be the best choice

Farabi

I uploaded the driver on my I/O port thread. It should be easy to porting it to 16-bit code.
http://www.win.tue.nl/~aeb/linux/kbd/scancodes-13.html
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"