getbom.c
This commit is contained in:
parent
ac83cb6472
commit
806dc65674
1 changed files with 120 additions and 0 deletions
120
getBom.c
Normal file
120
getBom.c
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
char* pass;
|
||||||
|
if (OpenClipboard(NULL)) {
|
||||||
|
HANDLE hClipboardData = GetClipboardData(CF_TEXT);
|
||||||
|
if (hClipboardData != NULL) {
|
||||||
|
char *clipboardText = GlobalLock(hClipboardData);
|
||||||
|
if (clipboardText != NULL) {
|
||||||
|
char* ptr = clipboardText;
|
||||||
|
int i = 0;
|
||||||
|
char result[strlen(ptr)];
|
||||||
|
int pos = 0;
|
||||||
|
while (*ptr != '\0') {
|
||||||
|
switch (i){
|
||||||
|
case 0: //Collect cat till newline
|
||||||
|
if (*ptr == '\n'){
|
||||||
|
result[pos] = '\t';
|
||||||
|
pos++;
|
||||||
|
ptr++;
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(*ptr == '\r'){
|
||||||
|
ptr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result[pos] = *ptr;
|
||||||
|
pos++;
|
||||||
|
ptr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: // Collect Desc
|
||||||
|
if (*ptr == '\n'){
|
||||||
|
result[pos] = '\t';
|
||||||
|
pos++;
|
||||||
|
ptr++;
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(*ptr == '\r'){
|
||||||
|
ptr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result[pos] = *ptr;
|
||||||
|
pos++;
|
||||||
|
ptr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 6: //Collect QTY
|
||||||
|
if (*ptr == '\n'){
|
||||||
|
result[pos] = *ptr;
|
||||||
|
pos++;
|
||||||
|
ptr++;
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(*ptr == '\r'){
|
||||||
|
ptr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result[pos] = *ptr;
|
||||||
|
pos++;
|
||||||
|
ptr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 7: //End of Tool line
|
||||||
|
if (*ptr == '\n'){
|
||||||
|
ptr++;
|
||||||
|
i = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ptr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if (*ptr == '\n'){
|
||||||
|
ptr++;
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue