管理員
|
這是我用 DEV-C 寫的純 C 的鍵盤測試的小程式
這是我用 DEV-C 寫的純 C 的鍵盤測試的小程式,大家一起想吧,要如何才能
測到 Ctrl、Alt、Shift、CapsLock、PrintScreen、ScrollLock、Pause、
NumLock、視窗鍵、mouse功能鍵 . . . :dc
做了一點點的調整。
#include <add_tc.h>
ust A[256]={0},F[24]={0},P=0;
main()
{
ust ca,cb,i;
clrscr();
prn(2,"\n");
prn(9," "); printf("歡迎使用,鍵盤的按鍵測試程式 0.31 版,\n");
prn(9," "); printf("本程式由 slime 論壇 getter 網友所編寫,\n");
prn(9," "); printf("本程式使用 Dev-C 所編譯 . . .就這樣。\n");
prn(9," "); printf("版權沒有,散佈不究。\n");
prn(2,"\n");
prn(9," "); printf("有幾個鍵測不到:\n");
prn(9," "); printf("Ctrl、Alt、Shift、CapsLock、PrintScreen\n");
prn(9," "); printf("ScrollLock、Pause、NumLock、視窗鍵、mouse");
prn(2,"\n");
prn(9," ");
pause();
do{
pr_();
printf("清除按過的燈號︰[空白]鍵連續按 3 下");
printf("\t離開程式︰[Esc] 鍵連續按 3 下");
printf("\n請按下欲測試之按鍵: ");
if(P>0 & (ca==0|ca==224))
{
if(cb>58&cb<69){ printf("F%d ",cb-58); }
if(cb==133 |cb==134){ printf("F%d ",cb-122); }
if(cb==82){ printf("Insert"); }
if(cb==83){ printf("Delete"); }
if(cb==71){ printf("Home"); }
if(cb==79){ printf("End"); }
if(cb==73){ printf("PageUp"); }
if(cb==81){ printf("PageDown"); }
if(cb==72){ printf("↑ "); }
if(cb==80){ printf("↓ "); }
if(cb==75){ printf("← "); }
if(cb==77){ printf("→ "); }
printf("\t按鍵碼~1:%#02x \t按鍵碼~2:%#02x",ca, cb);
}
else
{
if(ca==27){ printf("Esc \t按鍵碼: %#02x",ca); }
else { printf("%c \t按鍵碼: %#02x",ca,ca); }
}
ca=getch();
if(ca==0)
{
cb=getch();
F[cb-57]=1;
P++; F[0]=0; F[1]=0;
}
else if(ca==224)
{
cb=getch();
if(cb==133){ F[12]=1;}
if(cb==134){ F[13]=1;}
if(cb==82){ F[14]=1;}
if(cb==83){ F[15]=1;}
if(cb==71){ F[16]=1;}
if(cb==79){ F[17]=1;}
if(cb==73){ F[18]=1;}
if(cb==81){ F[19]=1;}
if(cb==72){ F[20]=1;}
if(cb==80){ F[21]=1;}
if(cb==75){ F[22]=1;}
if(cb==77){ F[23]=1;}
P++; F[0]=0; F[1]=0;
}
else
{
A[ca]=1;
if(ca!=27){ F[0]=0; }
if(ca!=32){ F[1]=0; }
}
if(ca==32)
{
F[1]++;
if(F[1]>2)
{
for(i=0;i<256;i++){ A[i]=0; }
for(i=0;i<24;i++){ F[i]=0; }
P=0;
}
}
if(ca==27)
{
F[0]++;
if(F[0]>2){ break; }
}
}while(1);
}
pr_()
{
clrscr();
printf("Esc[%2s]︰連續按了 %d\n",A[27]>0?"█":" ",F[0]);
printf("F1[%2s] ",F[2]>0?"█":" ");
printf("F2[%2s] ",F[3]>0?"█":" ");
printf("F3[%2s] ",F[4]>0?"█":" ");
printf("F4[%2s] ",F[5]>0?"█":" ");
printf("F5[%2s] ",F[6]>0?"█":" ");
printf("F6[%2s] ",F[7]>0?"█":" ");
printf("F7[%2s] ",F[8]>0?"█":" ");
printf("F8[%2s] ",F[9]>0?"█":" ");
printf("F9[%2s]\n",F[10]>0?"█":" ");
printf("F10[%2s] ",F[11]>0?"█":" ");
printf("F11[%2s] ",F[12]>0?"█":" ");
printf("F12[%2s] ",F[13]>0?"█":" ");
printf("\n");prn(38,"─");printf("\n");
printf("`~[%2s] ",A[96]>0|A[126]>0?"█":" ");
printf("1![%2s] ",A[49]>0|A[33]>0?"█":" ");
printf("2@[%2s] ",A[50]>0|A[64]>0?"█":" ");
printf("3#[%2s] ",A[51]>0|A[35]>0?"█":" ");
printf("4$[%2s] ",A[52]>0|A[36]>0?"█":" ");
printf("5%[%2s] ",A[53]>0|A[37]>0?"█":" ");
printf("6^[%2s] ",A[54]>0|A[94]>0?"█":" ");
printf("7&[%2s] ",A[55]>0|A[38]>0?"█":" ");
printf("8*[%2s] ",A[56]>0|A[42]>0?"█":" ");
printf("9([%2s] ",A[57]>0|A[40]>0?"█":" ");
printf("0)[%2s]\n",A[48]>0|A[41]>0?"█":" ");
printf("-_[%2s] ",A[45]>0|A[95]>0?"█":" ");
printf("=+[%2s] ",A[61]>0|A[43]>0?"█":" ");
printf("\\|[%2s] ",A[92]>0|A[124]>0?"█":" ");
printf("Backspace[%2s] ",A[8]>0?"█":" ");
printf("\n");prn(38,"─");printf("\n");
printf("Tab[%2s]\n",A[9]>0?"█":" ");
printf("qQ[%2s] ",A[113]>0|A[81]>0?"█":" ");
printf("wW[%2s] ",A[119]>0|A[87]>0?"█":" ");
printf("eE[%2s] ",A[101]>0|A[69]>0?"█":" ");
printf("rR[%2s] ",A[114]>0|A[82]>0?"█":" ");
printf("tT[%2s] ",A[116]>0|A[84]>0?"█":" ");
printf("yY[%2s] ",A[121]>0|A[89]>0?"█":" ");
printf("uU[%2s] ",A[117]>0|A[85]>0?"█":" ");
printf("iI[%2s] ",A[105]>0|A[73]>0?"█":" ");
printf("oO[%2s] ",A[111]>0|A[79]>0?"█":" ");
printf("pP[%2s] ",A[112]>0|A[80]>0?"█":" ");
printf("[{[%2s]\n",A[91]>0|A[123]>0?"█":" ");
printf("]}[%2s] ",A[93]>0|A[125]>0?"█":" ");
printf("\n");prn(38,"─");printf("\n");
printf("aA[%2s] ",A[97]>0|A[65]>0?"█":" ");
printf("sS[%2s] ",A[115]>0|A[83]>0?"█":" ");
printf("dD[%2s] ",A[100]>0|A[68]>0?"█":" ");
printf("fF[%2s] ",A[102]>0|A[70]>0?"█":" ");
printf("gG[%2s] ",A[103]>0|A[71]>0?"█":" ");
printf("hH[%2s] ",A[104]>0|A[72]>0?"█":" ");
printf("jJ[%2s] ",A[106]>0|A[74]>0?"█":" ");
printf("kK[%2s] ",A[107]>0|A[75]>0?"█":" ");
printf("lL[%2s] ",A[108]>0|A[76]>0?"█":" ");
printf(";:[%2s] ",A[59]>0|A[58]>0?"█":" ");
printf("'\"[%2s] ",A[39]>0|A[34]>0?"█":" ");
printf("\n");prn(38,"─");printf("\n");
printf("zZ[%2s] ",A[122]|A[90]>0?"█":" ");
printf("xX[%2s] ",A[120]>0|A[88]>0?"█":" ");
printf("cC[%2s] ",A[99]>0|A[67]>0?"█":" ");
printf("vV[%2s] ",A[118]>0|A[86]>0?"█":" ");
printf("bB[%2s] ",A[98]>0|A[66]>0?"█":" ");
printf("nN[%2s] ",A[110]>0|A[78]>0?"█":" ");
printf("mM[%2s] ",A[109]>0|A[77]>0?"█":" ");
printf(",<[%2s] ",A[44]>0|A[60]>0?"█":" ");
printf(".>[%2s] ",A[46]>0|A[62]>0?"█":" ");
printf("/?[%2s] ",A[47]>0|A[63]>0?"█":" ");
printf("\n");prn(38,"─");printf("\n");
printf("Enter[%2s] ",A[13]>0?"█":" ");
printf("Space[%2s]︰連續按了 %d ",A[32]>0?"█":" ",F[1]);
printf("\n");prn(38,"─");printf("\n");
printf("Insert[%2s] ",F[14]>0?"█":" ");
printf("delect[%2s] ",F[15]>0?"█":" ");
printf("Home[%2s] ",F[16]>0?"█":" ");
printf("End[%2s] ",F[17]>0?"█":" ");
printf("PageUP[%2s] ",F[18]>0?"█":" ");
printf("PageDown[%2s] ",F[19]>0?"█":" ");
printf("\n");prn(38,"─");printf("\n");
printf("↑[%2s] ",F[20]>0?"█":" ");
printf("↓[%2s] ",F[21]>0?"█":" ");
printf("←[%2s] ",F[22]>0?"█":" ");
printf("→[%2s] ",F[23]>0?"█":" ");
printf("\n");prn(38,"─");printf("\n");
}
---------------------------------------------------
程式執行檔,我附加在我的【頭像】裡,另存圖片後,在修改
副檔名為 .rar (*.gif --> *.rar)。在解壓縮就有了。
|