鼠标不接受输入

发布于 2024-09-12 00:00:40 字数 1294 浏览 5 评论 0原文

我正在尝试实现鼠标干扰,但输入功能出了问题。它应该告诉我,我已经进行了左键单击或右键单击,但它没有打印任何内容。看看:

#include<graphics.h>
#include<dos.h>
union REGS in,out;
void Graphics(void);
void DetectMouse(void);
void ShowMouse(void);
void HideMouse(void);
void InputMouse(void);
int main()
{
    Graphics();
    DetectMouse();
    ShowMouse();
       //   HideMouse();
    InputMouse();
    getch();
    closegraph();
    return 0;
}
void Graphics(void)
{
    int driver=DETECT,mode;
    initgraph(&driver,&mode,"C:\\TC\\bgi");
    outtextxy(1,1,"Graphics mode activated!");
}
void DetectMouse(void)
{
    int result;
    in.x.ax=0;
    result=int86(0x33,&in,&out);
    if(result)
    {
        outtextxy(10,10,"Driver succesfully detected");
    }
    else
    {
        outtextxy(10,10,"Driver not detected");
    }
}
void ShowMouse(void)
{
    in.x.ax=1;
    int86(0x33,&in,&out);
}
void HideMouse(void)
{
    in.x.ax=2;
    int86(0x33,&in,&out);


}
void InputMouse(void)
{
    for(;kbhit();)
    {
    int x,y;
    in.x.ax=3;
    int86(0x33,&in,&out);
    if(out.x.bx==1)
        outtextxy(30,30,"Left click");
    if(out.x.bx==2)
        outtextxy(40,40,"Right click");
    if(out.x.bx==3)
        outtextxy(50,50,"Middle click");
    delay(100);
    }
}

I am trying to implement mouse interfecing but somethings wrong with the input function.It should tell me that wheater i have made a left click or a right click but its not printing anything.Have a look:

#include<graphics.h>
#include<dos.h>
union REGS in,out;
void Graphics(void);
void DetectMouse(void);
void ShowMouse(void);
void HideMouse(void);
void InputMouse(void);
int main()
{
    Graphics();
    DetectMouse();
    ShowMouse();
       //   HideMouse();
    InputMouse();
    getch();
    closegraph();
    return 0;
}
void Graphics(void)
{
    int driver=DETECT,mode;
    initgraph(&driver,&mode,"C:\\TC\\bgi");
    outtextxy(1,1,"Graphics mode activated!");
}
void DetectMouse(void)
{
    int result;
    in.x.ax=0;
    result=int86(0x33,&in,&out);
    if(result)
    {
        outtextxy(10,10,"Driver succesfully detected");
    }
    else
    {
        outtextxy(10,10,"Driver not detected");
    }
}
void ShowMouse(void)
{
    in.x.ax=1;
    int86(0x33,&in,&out);
}
void HideMouse(void)
{
    in.x.ax=2;
    int86(0x33,&in,&out);


}
void InputMouse(void)
{
    for(;kbhit();)
    {
    int x,y;
    in.x.ax=3;
    int86(0x33,&in,&out);
    if(out.x.bx==1)
        outtextxy(30,30,"Left click");
    if(out.x.bx==2)
        outtextxy(40,40,"Right click");
    if(out.x.bx==3)
        outtextxy(50,50,"Middle click");
    delay(100);
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

漫雪独思 2024-09-19 00:00:40

尝试 if((out.x.bx & 1) != 0) ... - 即仅检查位 0 - 我注意到对于 INT33 AX=3,许多标志“未使用” - 这是否能保证它们为零是任何人的猜测。

Try if((out.x.bx & 1) != 0) ... - i.e. check just bit 0 - I note that many of the flags are 'unused' for INT33 AX=3 - whether this guarantees them zero or not is anyone's guess.

明月松间行 2024-09-19 00:00:40

您可能想要一个主循环。 INT 33 AX=0003 不会阻止等待鼠标输入。

You probably want to have a main loop. INT 33 AX=0003 doesn't block waiting for mouse input.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文