News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Another simple programs...

Started by felipe, May 02, 2017, 09:58:04 AM

Previous topic - Next topic

felipe

I hope there's no problems for posting so simple codes (i'm just learning) here, but if there is, please let me know.

So these two funny programs (at least they are funny for me) would do this: The program named 'left' would change your mouse buttons to a lefthand configuration. The program named 'right' would restore the default configuration (the opposed if you are a lefthand user with the 'normal' configuration of the mouse buttons already changed.)

Give it a try if you want, it's funny!  :biggrin:  :t  :icon14:  :icon13:   :lol:

LEFT:

             
                .386
                .model  flat,stdcall
                option  casemap:none
                include c:\masm32\include\windows.inc
                include c:\masm32\include\user32.inc
                include c:\masm32\include\kernel32.inc
                includelib c:\masm32\lib\kernel32.lib
                includelib c:\masm32\lib\user32.lib

                .data

                .code

start:
main            proc
                call    changebut
                call    ExitProcess
main            endp
               

changebut       proc
                push    SPIF_UPDATEINIFILE          ; Updates de user profile.   
                push    0                           ; Null.
                push    TRUE                        ; Change the meanings of the buttons.   
                push    SPI_SETMOUSEBUTTONSWAP      ; This it's what we want to do. 
                call    SystemParametersInfo        ; Windows will do it.
                ret 
changebut       endp

                end     main


RIGHT:

     
                .386
                .model  flat,stdcall
                option  casemap:none
                include c:\masm32\include\windows.inc
                include c:\masm32\include\user32.inc
                include c:\masm32\include\kernel32.inc
                includelib c:\masm32\lib\kernel32.lib
                includelib c:\masm32\lib\user32.lib

                .data

                .code

start:
main            proc
                call    changebut
                call    ExitProcess
main            endp
               

changebut       proc
                push    SPIF_UPDATEINIFILE          ; Updates de user profile.   
                push    0                           ; Null.
                push    FALSE                       ; Change the meanings of the buttons.   
                push    SPI_SETMOUSEBUTTONSWAP      ; This it's what we want to do. 
                call    SystemParametersInfo        ; Windows will do it.
                ret 
changebut       endp

                end     main

hutch--

Hi felipe,

No problems at all, you are doing it the right way, small examples that do one thing at a time with clear predictable results. I have one suggestion for you, unless you are using a very old machine, you don't have to restrict MASM to only using 386 instructions. Try this as it allows you to use the later instructions.

    .686p                           ; create 32 bit code
    .mmx
    .xmm
    .model flat, stdcall            ; 32 bit memory model
    option casemap :none            ; case sensitive


felipe


jj2007

Minor point: Instead of
  c:\masm32\
use
  \masm32\

... so that people who are using e.g. D:\Masm can test your code immediately.

felipe

Good point JJ, thanks a lot!  :t