// MousePas.C // To compile with Turbo C++ // tcc MousePas.c // To comlile with Borland C++ // bcc MousePas.c #include // i86 #include // kbhit() #include // strcmp() #include // printf() void instructions() { clrscr(); printf("You will be prompted to enter a password.\n"); printf("Click on the left and right mouse buttons.\n"); printf("And their clicks will become part of the password.\n"); printf("You must have a mouse driver loaded to use the mous.\n"); } int get_button() { struct REGPACK regs; regs.r_ax = 3; regs.r_bx = regs.r_cx = regs.r_dx = regs.r_es = 0; regs.r_es = 0; intr(0x33, ®s); return regs.r_bx; } void get_mouse_string(char *string, int maxlen) { int i = 0, button; char key = 0; while (key != 13 && i < maxlen) { if (kbhit()) { key = getch(); if (key != 13 && key > 2) { printf("*"); string[i++] = key; } } else if ((button = get_button()) != 0) { if (button == 1) printf("L"); else printf("R"); string[i++] = button; while ((button = get_button()) != 0); } } string[i] = 0; } void main () { char password[128]; char validate[128]; instructions(); printf("Enter a password: "); get_mouse_string(password, 127); // This is the cool part! printf("\nValidate password: "); get_mouse_string(validate, 127); if (strcmp(password, validate)) printf("\n\nValidation FAILED\n"); else printf("\n\nValidation PASSWD\n"); }