#include "dos.h" #include "bios.h" main() { int pl=0; while(pl!=13) { pl=getch(); if (pl==75) printf("<-Left"); if(pl==77)printf("Right->"); }} ‘---- Option Explicit Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private Declare Function GetActiveWindow Lib "user32" () As Long Private Sub Command1_Click() keybd_event vbKeyLeft, 0, 0, 0 End SubPrivate Sub Command2_Click() keybd_event vbKeyRight, 0, 0, 0 End SubPrivate Sub Timer1_Timer() Static bFlag As Boolean
If GetActiveWindow <> Me.hWnd Then
bFlag = Not bFlag If bFlag = True Then Command1_Click Else Command1_Click End If End If End Sub’------ 有点问题,只是提个思路,我在想想,好像输入焦点到不了Dos程序
#include "bios.h"
main()
{
int pl=0;
while(pl!=13)
{
pl=getch();
if (pl==75) printf("<-Left");
if(pl==77)printf("Right->"); }}
‘----
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Sub Command1_Click()
keybd_event vbKeyLeft, 0, 0, 0
End SubPrivate Sub Command2_Click()
keybd_event vbKeyRight, 0, 0, 0
End SubPrivate Sub Timer1_Timer()
Static bFlag As Boolean
If GetActiveWindow <> Me.hWnd Then
bFlag = Not bFlag
If bFlag = True Then
Command1_Click
Else
Command1_Click
End If
End If
End Sub’------
有点问题,只是提个思路,我在想想,好像输入焦点到不了Dos程序