Test tc cursor mouse operation (TC)

Source: Internet
Author: User

Test tc cursor mouse operation (TC)
The mouse operation code used in the Code is controlled by the common registers _ AX, _ BX, _ CX, _ DX.
I really want to use TC multithreading to solve this problem, but I didn't find a specific implementation method on the Internet. Is there only a multi-thread method in C ++ or MS VC? Annoying

int main(){    char szText[20] = "";    for(;;)    {        if(LeftPress())        {            MouseGetXY();            if(MouseX < 0 || MouseX > 800 || MouseY < 0 || MouseY > 600)                printf("Cursor is not in the Active Area of the screen!\n");            else            {                printf("LeftButton Pressed!\n");                sprintf(szText, "cursorX,Y:(%d, %d)\n", MouseX, MouseY);                printf(szText);            }            //sleep(1);        }        if(RightPress())        {            MouseGetXY();            if(MouseX < 0 || MouseX > 400 || MouseY < 0 || MouseY > 300)                printf("Cursor is not in the Active Area of the screen!\n");            else            {                printf("RightButton Pressed!\n");                sprintf(szText, "CursorX,Y:(%d, %d)\n", MouseX, MouseY);                printf(szText);                /*moveto(120,240);*/                textcolor(5);                cprintf("/*RButton Test*/");                printf("\n");            }            //sleep(1);        }        if(kbhit())        {            if(0x011b == bioskey(0))            {                printf("\ntestEnd\n");                break;            }        }        if(!LeftPress() && !RightPress())            continue;        printf("test again:\n");    }    getch();}


Problem: When the code is left-pressed or right-clicked, the print statement is printed multiple times.

Solution: After all the corresponding statements are executed, add a sleep (1.

Cause: this problem should be caused by multi-thread round robin;
Textcolor (6 );
Textbackground (7 );
Cprintf ("Left and Right button both Pressed! \ N ");
The execution efficiency of these three statements is too low.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.