#include #include #include int main(void) { // Open the clipboard char* pass; if (OpenClipboard(NULL)) { // Get the clipboard data HANDLE hClipboardData = GetClipboardData(CF_TEXT); if (hClipboardData != NULL) { // Lock the data to access its contents char *clipboardText = GlobalLock(hClipboardData); if (clipboardText != NULL) { char* ptr = clipboardText; int i = 1; char result[strlen(ptr)];//A bit big, but what are we gonna do? int pos = 0; char* L; char* o; char* t; char* hex20; while (*ptr != '\0') { // We want to find Lot L = o; o = t; t = hex20; hex20 = ptr; //Who needs Regex? char lot[5] = {*L, *o, *t, *hex20, '\0'}; //printf("%s\n", lot); if (strcmp(lot, "Lot ") == 0){ i = 0; ptr++; } switch (i) { case 0: //Get the lot, add to result if (*ptr == '\n'){ result[pos] = *ptr; pos++; ptr++; i++; break; } else { result[pos] = *ptr; pos++; ptr++; break; } default: ptr++; break; } } result[pos] = '\0'; // End the string GlobalUnlock(hClipboardData); const char *Newclip = result; HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, strlen(Newclip)+1); if (hMem != NULL) { char *memText = GlobalLock(hMem); strcpy(memText, Newclip); GlobalUnlock(hMem); if (OpenClipboard(NULL)) { EmptyClipboard(); SetClipboardData(CF_TEXT, hMem); CloseClipboard(); printf("%s", Newclip); } else { printf("Failed to open clipboard for writing.\n"); GlobalFree(hMem); } } else { printf("Failed to allocate memory for clipboard text.\n"); } } }// close the clipboard CloseClipboard(); } return 0; }