(10-10-2022, 03:42 AM)eoredson Wrote: The assembly code I am using to trap x1b and x05 is this:
Code: (Select All);Traps and ignores Print-Screen and Control-Break. v1.1a PD 2020.
;Compiled with 'Tasm /t Keytrap;'
;Compile calling program using /fs with BC. (QBX forces /fs).
.model medium, basic ;Stay compatible with basic.
extrn SETUEVENT: far
.code
public SETINT
SETINT proc uses ds
mov ax, 351BH ;Get old control-break interrupt
int 21h ;vector and save it.
mov word ptr cs:OldVector1,bx
mov word ptr cs:OldVector1+2,es
push cs ;Set the new
pop ds ;interrupt vector
lea dx, EventHandler ;to the address
mov ax, 251BH ;of our service
int 21H ;routine.
mov ax, 3505H ;Get old print-screen interrupt
int 21h ;vector and save it.
mov word ptr cs:OldVector2,bx
mov word ptr cs:OldVector2+2,es
push cs ;Set the new
pop ds ;interrupt vector
lea dx, EventHandler ;to the address
mov ax, 2505H ;of our service
int 21H ;routine.
ret
SETINT endp
public EVENTHANDLER
EVENTHANDLER proc
iret ;eat keystroke. pop stack.
OldVector1 dd 0 ;keep data in code segment.
OldVector2 dd 0
EVENTHANDLER endp
public RESTINT
RESTINT proc uses ds ;Restore the old
lds dx, cs:OldVector1 ;interrupt vectors
mov ax, 251BH ;so things will
int 21h ;keep working when
lds dx, cs:OldVector2 ;this basic program is
mov ax, 2505H ;finished.
int 21h
ret
RESTINT endp
end
This looks like real mode x86 ASM. Brings back a lot of old memories. None of this stuff is going to work with QB64 though because QB64 works under protected mode operating systems that does not allow you to use interrupts like we could with DOS. You'll need to use the appropriate OS APIs to achieve what you are trying to do. I would suggest looking at what @Spriggsy said if you are writing your code for Windows. I am quite certain that there are relevant APIs for Linux and macOS too. However, I am not too familiar with those OSes.