1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
| void CKeyWedgeDlg::Routine()
{
BOOL bResult;
HWND hwnd = (HWND)-1;
BYTE *pData;
KEY_STATE_FLAGS kstate[1];
UINT vKey;
BYTE scanPlusFormatData[ MAX_BARCODE_LEN + 80 ];
CTime theTime = CTime::GetCurrentTime();
if (compteurelemtab>=DialogOption.elemtab.GetSize()-1) compteurelemtab=0; //Remise à zéro du compteur sur elemtab
for (compteurelemtab;compteurelemtab<DialogOption.elemtab.GetSize();compteurelemtab++)
{
CString stringelem = DialogOption.elemtab[compteurelemtab];
stringelem.MakeUpper();
if (stringelem.Compare(_T("DROITE"))==0)
{
keybd_event( VK_RIGHT, 0, KEYEVENTF_SILENT, 0 ); // RIGHT key down
keybd_event( VK_RIGHT, 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 ); // RIGHT key up
Sleep(50);
}
else if (stringelem.Compare(_T("GAUCHE"))==0)
{
//AfxMessageBox(_T("GAUCHE"), MB_OK, NULL);
keybd_event( VK_LEFT, 0, KEYEVENTF_SILENT, 0 ); // LEFT key down
keybd_event( VK_LEFT, 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 ); // LEFT key up
Sleep(50);
}
else if (stringelem.Compare(_T("BAS"))==0)
{
// AfxMessageBox(_T("BAS"), MB_OK, NULL);
keybd_event( VK_DOWN, 0, KEYEVENTF_SILENT, 0 ); // DOWN key down
keybd_event( VK_DOWN, 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 ); // DOWN key up
Sleep(50);
}
else if (stringelem.Compare(_T("HAUT"))==0)
{
// AfxMessageBox(_T("HAUT"), MB_OK, NULL);
keybd_event( VK_UP, 0, KEYEVENTF_SILENT, 0 ); // UP key down
keybd_event( VK_UP, 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 ); // UP key up
Sleep(50);
}
else if (stringelem.Compare(_T("DATE"))==0)
{
// AfxMessageBox(_T("DATE"), MB_OK, NULL);
CTime theTime = CTime::GetCurrentTime();
int day,month,year;
day = theTime.GetDay();
month = theTime.GetMonth();
year = theTime.GetYear();
memset(scanPlusFormatData, '\0', MAX_BARCODE_LEN + 80); //initialize to all nulls
pData = scanPlusFormatData;
sprintf((char*)pData, "=DATE(%d;%d;%d)", (year%100)+100,month,day);
// For each character in the string
while( *pData != '\0' )
{
switch( *pData )
{
case '!':
keybd_event( VK_SHIFT, 0, KEYEVENTF_SILENT, 0 ); // SHIFT key down
keybd_event( '1', 0, 0, 0 );
keybd_event( '1', 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 );
keybd_event( VK_SHIFT, 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 ); // SHIFT key up
break;
case '@':
keybd_event( VK_SHIFT, 0, KEYEVENTF_SILENT, 0 ); // SHIFT key down
keybd_event( '2', 0, 0, 0 );
keybd_event( '2', 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 );
keybd_event( VK_SHIFT, 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 ); // SHIFT key up
break;
case '#':
keybd_event( VK_SHIFT, 0, KEYEVENTF_SILENT, 0 ); // SHIFT key down
keybd_event( '3', 0, 0, 0 );
keybd_event( '3', 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 );
keybd_event( VK_SHIFT, 0, (KEYEVENTF_KEYUP|KEYEVENTF_SILENT), 0 ); // SHIFT key up
break;
default:
vKey = (UINT)*pData;
bResult = PostKeybdMessage(hwnd, vKey, kstate[0], 1, kstate, &vKey);
if(bResult) {
keybd_event(0,0,1,0);
}
}
// Now move on to the next character
pData++;
Sleep(1);
} // end while (*pData != '\0')
}
else if (stringelem.Compare(_T("STOP"))==0)
{
compteurelemtab++;
return;
}
}
} |
Partager