News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Stop on key press or mouse input

Started by Magnum, January 03, 2013, 03:37:26 PM

Previous topic - Next topic

Magnum

I would to make this program stop if it detects any key press or mouse input.

Vielen Dank.



;Telephone.asm
;              Simulate telephone ringing
;              Help from SuperDave -- a.k.a. DednDave,             PRODUCE 1 KHz TONE FOR 54.9 mS
;              PRODUCE 800 Hz TONE FOR 54.9 mS

.486                       ; create 32 bit code
.model flat, stdcall       ; 32 bit memory model
option casemap :none       ; case sensitive

include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\shell32.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shell32.lib
include \masm32\macros\macros.asm

.data

.code 
                 
start:

mov ecx, 20
@@:
push ecx
invoke Beep, 1000, 55 ; Frequency in hertz and sound duration
invoke Beep, 800, 55   
pop ecx
dec ecx
jnz @B
invoke Sleep, 1500   

mov ecx, 20
@@:
push ecx
invoke Beep, 1000, 55 ; Frequency in hertz and sound duration
invoke Beep, 800, 55   
pop ecx
dec ecx
jnz @B
invoke Sleep, 1500

mov ecx, 20
@@:
push ecx
invoke Beep, 1000, 55 ;
invoke Beep, 800, 55   
pop ecx
dec ecx
jnz @B

invoke ExitProcess,0

end start


Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

hutch--

Andy,

Just set a variable as a flag.


.data?
  flag dd ?
-------
.code
  mov flag, 0  ; initialise to zero


Trap either or both mouse or keyboard messages then set the flag to non-zero. You can also set some other keystroke to start it again.