paulcsf
February 13th, 2007, 10:46 PM
Alright, I know this is way out of date, but I can't find the answer anywhere, these forums, google, etc. Hopefully somebody has the answer.
I have an old program, it's a test program written in Power Basic for Dos. It currently runs on Dos and Win 98 machines. We are finally updating it, and I can't find a way to create the same functionality that I had before.
The functionality:
When the user presses and holds the Shift, Control, or Alt key, the menu at the bottom of the screen changes. So I don't want to wait until a key combination is pressed, I just want to detect that the key is down.
The original code:
'checkshiftstate gets the keyboard status byte and returns a
'0 if neither shift key is pressed,
'1 if the right shift key is pressed,
'2 if the left shift key is pressed,
'3 if both shift key's are pressed.
FUNCTION CHECKSHIFTSTATE() LOCAL PUBLIC AS INTEGER
DIM INB AS LOCAL WORD
DIM CSS AS INTEGER
CSS=0
! MOV AX,&H0200
! INT &H16
! MOV INB,AX
IF BIT(INB,0) THEN BIT SET CSS,0
IF BIT(INB,1) THEN BIT SET CSS,1
CHECKSHIFTSTATE=CSS
END FUNCTION
I have tried using GetKeyState, and GetAsyncKeyState, both of which work great on XP. When I take the same executable to the 98 machine, neither work as expected. GetKeyState doesn't work at all. GetAsyncKeyState works as long as the console doesn't have focus, ie I put the focus on another window on the desktop, and the GetAsyncKeyState returns exactly as expected. I have also tried GetKeyboardState, again without any luck.
while(1)
{
L=GetAsyncKeyState(VK_SHIFT);
//L=L/(2^15);
printf("\r\n%04X ",L);
L=GetAsyncKeyState(VK_CONTROL);
//L=L/(2^15);
printf("%04X ",L);
L=GetAsyncKeyState(VK_MENU);
//L=L/(2^15);
printf("%04X ",L);
}
Anybody have any ideas? The long run goal is to get rid of Win98, but until I can get everything converted and tested, it's got to be compatible on both 98 and XP.
If I check operating systems, can I use either the DOS INT 16,2 or the 0040:0017 bios memory areas in a Win32 console on 98, and then use the working functions on XP?
Thanks in advance,
I have an old program, it's a test program written in Power Basic for Dos. It currently runs on Dos and Win 98 machines. We are finally updating it, and I can't find a way to create the same functionality that I had before.
The functionality:
When the user presses and holds the Shift, Control, or Alt key, the menu at the bottom of the screen changes. So I don't want to wait until a key combination is pressed, I just want to detect that the key is down.
The original code:
'checkshiftstate gets the keyboard status byte and returns a
'0 if neither shift key is pressed,
'1 if the right shift key is pressed,
'2 if the left shift key is pressed,
'3 if both shift key's are pressed.
FUNCTION CHECKSHIFTSTATE() LOCAL PUBLIC AS INTEGER
DIM INB AS LOCAL WORD
DIM CSS AS INTEGER
CSS=0
! MOV AX,&H0200
! INT &H16
! MOV INB,AX
IF BIT(INB,0) THEN BIT SET CSS,0
IF BIT(INB,1) THEN BIT SET CSS,1
CHECKSHIFTSTATE=CSS
END FUNCTION
I have tried using GetKeyState, and GetAsyncKeyState, both of which work great on XP. When I take the same executable to the 98 machine, neither work as expected. GetKeyState doesn't work at all. GetAsyncKeyState works as long as the console doesn't have focus, ie I put the focus on another window on the desktop, and the GetAsyncKeyState returns exactly as expected. I have also tried GetKeyboardState, again without any luck.
while(1)
{
L=GetAsyncKeyState(VK_SHIFT);
//L=L/(2^15);
printf("\r\n%04X ",L);
L=GetAsyncKeyState(VK_CONTROL);
//L=L/(2^15);
printf("%04X ",L);
L=GetAsyncKeyState(VK_MENU);
//L=L/(2^15);
printf("%04X ",L);
}
Anybody have any ideas? The long run goal is to get rid of Win98, but until I can get everything converted and tested, it's got to be compatible on both 98 and XP.
If I check operating systems, can I use either the DOS INT 16,2 or the 0040:0017 bios memory areas in a Win32 console on 98, and then use the working functions on XP?
Thanks in advance,