1 /** 2 去除多条消息中的用户名 3 比如: 微信多条消息 4 **/ 5 #include <cstdio> 6 #include <cstdlib> 7 #include <cstring> 8 #include <assert.h> 9 #define _AFXDLL 10 //#include <afx.h> 11 #include <windows.h> 12 #include <iostream> 13 using namespace std; 14 const int max_len=1e6; 15 16 char str_1[max_len],str_total[max_len]; 17 18 //void copy_to_clipboard(char str_1[max_len]) 19 //{ 20 /////https://zhidao.baidu.com/question/371455437.html 21 // 22 /////https://blog.csdn.net/daska110/article/details/80323447 23 // 24 // 25 // 26 // 27 //// char cD[] ="qq34r6"; 28 // if(OpenClipboard(NULL)) 29 // { 30 // HGLOBAL hmem=GlobalAlloc(GHND,7); 31 // char *pmem=(char *)GlobalLock(hmem);///add (char *) 32 // 33 // EmptyClipboard(); 34 // memcpy(pmem,str_1,strlen(str_1)+1); 35 // SetClipboardData(CF_TEXT,hmem); 36 // CloseClipboard(); 37 // GlobalFree(hmem); 38 // } 39 //} 40 41 BOOL SetClipData(char *pstr) 42 { 43 ///https://www.cnblogs.com/emjx/p/11141572.html 44 if(OpenClipboard(NULL)) 45 { 46 char *pBuf; 47 if(0==EmptyClipboard()) 48 { 49 CloseClipboard(); 50 return false; 51 } 52 HGLOBAL hClip=GlobalAlloc(GMEM_MOVEABLE,strlen(pstr)+1); 53 if(NULL==hClip) 54 { 55 CloseClipboard(); 56 return false; 57 } 58 pBuf=(char*)GlobalLock(hClip); 59 if(NULL==pBuf) 60 { 61 CloseClipboard(); 62 return false; 63 } 64 strcpy(pBuf,pstr); 65 GlobalUnlock(hClip); 66 67 if(NULL==SetClipboardData(CF_TEXT,hClip)) 68 { 69 CloseClipboard(); 70 return false; 71 } 72 73 CloseClipboard(); 74 } 75 return true; 76 } 77 78 int main() 79 { 80 ///Ctrl+Z + Enter 结束 81 while (gets(str_1)) 82 { 83 if (strcmp(str_1,"Traveller:")!=0) 84 { 85 ///人工修改格式(一开始没留换行) 86 strcat(str_total," "); 87 88 strcat(str_total,str_1); 89 } 90 } 91 printf("%s ",str_total); 92 93 ///exe 94 ///放置消息到剪贴板 95 SetClipData(str_total); 96 // copy_to_clipboard(str_total); 97 return 0; 98 }
放到markdown(加上"- ")
1 /** 2 去除多条消息中的用户名 3 比如: 微信多条消息 4 **/ 5 #include <cstdio> 6 #include <cstdlib> 7 #include <cstring> 8 #include <assert.h> 9 #define _AFXDLL 10 //#include <afx.h> 11 #include <windows.h> 12 #include <iostream> 13 using namespace std; 14 const int max_len=1e6; 15 16 char str_1[max_len],str_total[max_len]; 17 18 //void copy_to_clipboard(char str_1[max_len]) 19 //{ 20 /////https://zhidao.baidu.com/question/371455437.html 21 // 22 /////https://blog.csdn.net/daska110/article/details/80323447 23 // 24 // 25 // 26 // 27 //// char cD[] ="qq34r6"; 28 // if(OpenClipboard(NULL)) 29 // { 30 // HGLOBAL hmem=GlobalAlloc(GHND,7); 31 // char *pmem=(char *)GlobalLock(hmem);///add (char *) 32 // 33 // EmptyClipboard(); 34 // memcpy(pmem,str_1,strlen(str_1)+1); 35 // SetClipboardData(CF_TEXT,hmem); 36 // CloseClipboard(); 37 // GlobalFree(hmem); 38 // } 39 //} 40 41 BOOL SetClipData(char *pstr) 42 { 43 ///https://www.cnblogs.com/emjx/p/11141572.html 44 if(OpenClipboard(NULL)) 45 { 46 char *pBuf; 47 if(0==EmptyClipboard()) 48 { 49 CloseClipboard(); 50 return false; 51 } 52 HGLOBAL hClip=GlobalAlloc(GMEM_MOVEABLE,strlen(pstr)+1); 53 if(NULL==hClip) 54 { 55 CloseClipboard(); 56 return false; 57 } 58 pBuf=(char*)GlobalLock(hClip); 59 if(NULL==pBuf) 60 { 61 CloseClipboard(); 62 return false; 63 } 64 strcpy(pBuf,pstr); 65 GlobalUnlock(hClip); 66 67 if(NULL==SetClipboardData(CF_TEXT,hClip)) 68 { 69 CloseClipboard(); 70 return false; 71 } 72 73 CloseClipboard(); 74 } 75 return true; 76 } 77 78 int main() 79 { 80 ///Ctrl+Z + Enter 结束 81 while (gets(str_1)) 82 { 83 if (strcmp(str_1,"Traveller:")!=0) 84 { 85 ///之后可以专门遇到用户名,则删除一个换行符(第一次不操作) 86 if (strcmp(str_1,"")==0) 87 continue; 88 89 ///人工修改格式(一开始没留换行) 90 strcat(str_total,"- "); 91 strcat(str_total,str_1); 92 strcat(str_total," "); 93 } 94 } 95 printf("%s ",str_total); 96 97 98 ///exe 99 ///放置消息到剪贴板 100 SetClipData(str_total); 101 // copy_to_clipboard(str_total); 102 return 0; 103 }
QQ 有时间:判断去除
如 {name} + 2020/10/6 19:42:36
字符串的规则
有可能同步到电脑端的时候,并没有获取所有的内容,对于之前的内容,多选,逐条发送