Masm32 SDK description, downloads and other helpful links

Main Menu


Started by shankle, May 04, 2019, 07:03:51 AM

Previous topic - Next topic



; Purpose of this code is to try and move the focus to my program
; from a program I have no control over.

; I need to left click the mouse in my program to change
; the focus from the game program to my program.
; The code shows as an error with msg20

hdc   dq 0

    cmp D[iMsg],WM_LBUTTONDOWN
     jne >>.WM_KEYDOWN
    mov rax,0x000         ;wParam code for MK_LBUTTON
    cmp rax,MK_LBUTTON
      je >>
;   msg20         db '0x000 & MK_LBUTTON failed',0
    invoke MessageBox, NULL,addr msg20,addr msg20,MB_OK
     jmp >>.PQM
    invoke SetFocus,[hdc]    ; my program
    cmp rax,0
     jg >>
   ;msg18         db 'SetFocus failed',0
   invoke MessageBox, NULL,addr msg18,addr msg18,MB_OK
    jmp >>.PQM
; more code

   cmp D[iMsg],WM_DESTROY
    jne >.default        ; no more messages to check
                           ; so pass to DefWindowProc
   invoke PostQuitMessage,NULL
    jmp >>.END
   invoke DefWindowProc, [hWnd],[iMsg],[wParam],[lParam]
    xor rax,rax
ENDF               ; end of WndProc


SetFocus expects a window handle, not a DC.


MK_LBUTTON = 0x0001 and you are always comparing it to 0x000 loaded from the previous line... instead of 0x000 it looks like you were intending on using [wParam]. No need to do that comparison though, since that bit should be set anyways in this case.