- BC20260158's blog
基于C++的聊天轰炸器
- 2025-2-17 18:33:34 @
1.转码:
#include #include #includeusing namespace std;
int main() { // 璁剧疆鏈湴鍖栦互鏀寔瀹藉瓧绗﹁緭鍏? setlocale(LC_ALL, ""); wstring input;
// 璇诲彇鐢ㄦ埛杈撳叆鐨勬枃鏈?
wcout << L"璇疯緭鍏ユ枃鏈? ";
getline(wcin, input);
vector<int> keyCodes;
// 閬嶅巻姣忎釜瀛楃骞惰浆鎹负铏氭嫙閿爜
for (wchar_t c : input) {
SHORT result = VkKeyScanW(c);
if (result == -1) {
wcerr << L"鏃犳硶杞崲瀛楃: " << c << endl;
continue;
}
BYTE vkCode = LOBYTE(result);
keyCodes.push_back(static_cast<int>(vkCode));
}
// 杈撳嚭鍗佽繘鍒堕敭鐮侊紝绌烘牸鍒嗛殧
for (size_t i = 0; i < keyCodes.size(); ++i) {
if (i > 0) cout << " ";
cout << keyCodes[i];
}
cout<<endl<<keyCodes.size();
cout << endl;
return 0;
}
2.轰炸
#include #include #includeusing namespace std;
int main() { // 璁剧疆鏈湴鍖栦互鏀寔瀹藉瓧绗﹁緭鍏? setlocale(LC_ALL, ""); wstring input;
// 璇诲彇鐢ㄦ埛杈撳叆鐨勬枃鏈?
wcout << L"璇疯緭鍏ユ枃鏈? ";
getline(wcin, input);
vector<int> keyCodes;
// 閬嶅巻姣忎釜瀛楃骞惰浆鎹负铏氭嫙閿爜
for (wchar_t c : input) {
SHORT result = VkKeyScanW(c);
if (result == -1) {
wcerr << L"鏃犳硶杞崲瀛楃: " << c << endl;
continue;
}
BYTE vkCode = LOBYTE(result);
keyCodes.push_back(static_cast<int>(vkCode));
}
// 杈撳嚭鍗佽繘鍒堕敭鐮侊紝绌烘牸鍒嗛殧
for (size_t i = 0; i < keyCodes.size(); ++i) {
if (i > 0) cout << " ";
cout << keyCodes[i];
}
cout<<endl<<keyCodes.size();
cout << endl;
return 0;
}
#include<windows.h> #include<stdio.h> #include using namespace std; void Down(int letter){ keybd_event(letter,0,0,0); } void Up(int letter){ keybd_event(letter,0,KEYEVENTF_KEYUP,0); } void press(int letter){ Down(letter); Up(letter); } int main(){ int b; int c; int a[500]; printf("letter num:"); scanf("%u",&b); printf("truns:"); scanf("%u",&c); for(int i=0;i<b;i++){ printf("input %u (enter->13):",i); scanf("%u",&a[i]); } printf("5s"); Sleep(5000); for(int i=0;i<c;i++){ for(int j=0;j<b;j++){ press(a[j]); } printf("%d\n",i); Sleep(10); } return 0; }