diff --git a/AutoClicker.v12.suo b/AutoClicker.v12.suo new file mode 100644 index 0000000..cafa3aa Binary files /dev/null and b/AutoClicker.v12.suo differ diff --git a/AutoClicker/AutoClicker.cpp b/AutoClicker/AutoClicker.cpp index b91ab53..207efb2 100644 --- a/AutoClicker/AutoClicker.cpp +++ b/AutoClicker/AutoClicker.cpp @@ -1,13 +1,58 @@ #include #include #include +#include +#include + using namespace std; -bool clicking; -int x; -int y; + +#define RELEASE(__p) {if(__p != nullptr){__p->Release();__p = nullptr;}} + +bool IsWindowsPlayingAudio() +{ + bool playing = false; + bool loopmode = false; + float epsilon = 1E-07; + float value = 0; + HRESULT hr = S_OK; + IMMDeviceEnumerator* pEnumerator = NULL; + IMMDevice *pDevice = NULL; + IAudioMeterInformation *pMeter = NULL; + + CoInitialize(NULL); + CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pEnumerator); + pEnumerator->GetDefaultAudioEndpoint(EDataFlow::eRender, ERole::eMultimedia, &pDevice); + pDevice->Activate(__uuidof(IAudioMeterInformation), CLSCTX_ALL, NULL, (void**)&pMeter); + pMeter->GetPeakValue(&value); + playing = value > epsilon; + + RELEASE(pMeter); + RELEASE(pDevice); + RELEASE(pEnumerator); + CoUninitialize(); + if (FAILED(hr)) + { + cout << "An error occurred: 0x%08X\n" << hr << endl; + return false; + } + + if (playing) + { + cout << "Windows is playing a sound.\n" << endl; + return true; + } + else + { + cout << "Windows is not playing a sound.\n" << endl; + return false; + } +} static void startclicker() { + bool clicking = true; + int x = 0; + int y = 0; while (true) { if (GetAsyncKeyState(VK_NUMPAD1)) @@ -15,38 +60,39 @@ static void startclicker() Sleep(100); POINT cursorPos; GetCursorPos(&cursorPos); - //x = 0; x = cursorPos.x; - //y = 0; y = cursorPos.y; cout << "Mouse X = " << x << endl; cout << "Mouse Y = " << y << endl; - + Sleep(1000); } if (GetAsyncKeyState(VK_ESCAPE)) { cout << "Bye Bye <3 " << endl; - Sleep(500); - system("exit"); + Sleep(2000); + break; } + if (GetAsyncKeyState(VK_NUMPAD2)) { cout << "Clicking !" << endl; - Sleep(100); + Sleep(2000); clicking = true; while (true) { - if (!clicking) { break; } - //Sleep(100); - SetCursorPos(x, y); - mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0); - mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0); + if (IsWindowsPlayingAudio() == false) + { + Sleep(2000); + SetCursorPos(x, y); + mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0); + mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0); + } if (GetAsyncKeyState(VK_NUMPAD3)) { @@ -57,8 +103,8 @@ static void startclicker() if (GetAsyncKeyState(VK_ESCAPE)) { cout << "Bye Bye <3 " << endl; - Sleep(500); - system("exit"); + Sleep(2000); + break; } } } @@ -68,25 +114,22 @@ static void startclicker() static void init() { - clicking = false; - system("TITLE Mouse Clicker by sandaasu"); + cout << "Mouse Clicker by sandaasu, Modified by zaas[20220803]" << endl; cout << "======================================================" << endl; - cout << "[ HOTKEYS ]" << endl << endl; + cout << "[ HOTKEYS ]" << endl; cout << "NumPad1 = save mouse position" << endl; cout << "NumPad2 = activate autoclicker on saved position" << endl; cout << "NumPad3 = STOP" << endl; - cout << "Escape = Close" << endl << endl << endl; - cout << " " << endl << endl; + cout << "Escape = Close" << endl; cout << "======================================================" << endl; - cout << " " << endl << endl; - cout << "[ LOG ] " << endl << endl; + cout << " " << endl; + cout << "[ LOG ] " << endl; startclicker(); } - - -void main() +int main() { init(); + return 0; } diff --git a/AutoClicker/AutoClicker.vcxproj b/AutoClicker/AutoClicker.vcxproj index ac62e22..7a678dd 100644 --- a/AutoClicker/AutoClicker.vcxproj +++ b/AutoClicker/AutoClicker.vcxproj @@ -1,147 +1,147 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {e4a4686a-ff1e-49aa-94ed-93199778b156} - AutoClicker - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {e4a4686a-ff1e-49aa-94ed-93199778b156} + AutoClicker + 10.0.17763.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + \ No newline at end of file diff --git a/AutoClicker/AutoClicker.vcxproj.filters b/AutoClicker/AutoClicker.vcxproj.filters deleted file mode 100644 index eeddbe0..0000000 --- a/AutoClicker/AutoClicker.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Quelldateien - - - \ No newline at end of file diff --git a/AutoClicker/AutoClicker.vcxproj.user b/AutoClicker/AutoClicker.vcxproj.user deleted file mode 100644 index 88a5509..0000000 --- a/AutoClicker/AutoClicker.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/AutoClicker/Debug/AutoClicker.exe.recipe b/AutoClicker/Debug/AutoClicker.exe.recipe deleted file mode 100644 index b3655f4..0000000 --- a/AutoClicker/Debug/AutoClicker.exe.recipe +++ /dev/null @@ -1,7 +0,0 @@ - - - C:\Users\admin\Desktop\AutoClicker\Debug\AutoClicker.exe - - - - \ No newline at end of file diff --git a/AutoClicker/Debug/AutoClicker.log b/AutoClicker/Debug/AutoClicker.log deleted file mode 100644 index 6eb18bd..0000000 --- a/AutoClicker/Debug/AutoClicker.log +++ /dev/null @@ -1,3 +0,0 @@ - AutoClicker.cpp -C:\Users\admin\Desktop\AutoClicker\AutoClicker\AutoClicker.cpp(89,1): warning C4326: Der Rückgabetyp von "main" sollte "int" und nicht "void" sein - AutoClicker.vcxproj -> C:\Users\admin\Desktop\AutoClicker\Debug\AutoClicker.exe diff --git a/AutoClicker/Debug/AutoClicker.obj b/AutoClicker/Debug/AutoClicker.obj deleted file mode 100644 index ddae458..0000000 Binary files a/AutoClicker/Debug/AutoClicker.obj and /dev/null differ diff --git a/AutoClicker/Debug/AutoClicker.tlog/AutoClicker.lastbuildstate b/AutoClicker/Debug/AutoClicker.tlog/AutoClicker.lastbuildstate deleted file mode 100644 index 73b42b4..0000000 --- a/AutoClicker/Debug/AutoClicker.tlog/AutoClicker.lastbuildstate +++ /dev/null @@ -1,2 +0,0 @@ -PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.27.29110:TargetPlatformVersion=10.0.18362.0: -Debug|Win32|C:\Users\admin\Desktop\AutoClicker\| diff --git a/AutoClicker/Debug/AutoClicker.tlog/CL.command.1.tlog b/AutoClicker/Debug/AutoClicker.tlog/CL.command.1.tlog deleted file mode 100644 index fdb2e30..0000000 Binary files a/AutoClicker/Debug/AutoClicker.tlog/CL.command.1.tlog and /dev/null differ diff --git a/AutoClicker/Debug/AutoClicker.tlog/CL.read.1.tlog b/AutoClicker/Debug/AutoClicker.tlog/CL.read.1.tlog deleted file mode 100644 index 4e52534..0000000 Binary files a/AutoClicker/Debug/AutoClicker.tlog/CL.read.1.tlog and /dev/null differ diff --git a/AutoClicker/Debug/AutoClicker.tlog/CL.write.1.tlog b/AutoClicker/Debug/AutoClicker.tlog/CL.write.1.tlog deleted file mode 100644 index 60d0473..0000000 Binary files a/AutoClicker/Debug/AutoClicker.tlog/CL.write.1.tlog and /dev/null differ diff --git a/AutoClicker/Debug/AutoClicker.tlog/link.command.1.tlog b/AutoClicker/Debug/AutoClicker.tlog/link.command.1.tlog deleted file mode 100644 index 70cf05d..0000000 Binary files a/AutoClicker/Debug/AutoClicker.tlog/link.command.1.tlog and /dev/null differ diff --git a/AutoClicker/Debug/AutoClicker.tlog/link.read.1.tlog b/AutoClicker/Debug/AutoClicker.tlog/link.read.1.tlog deleted file mode 100644 index a3e080d..0000000 Binary files a/AutoClicker/Debug/AutoClicker.tlog/link.read.1.tlog and /dev/null differ diff --git a/AutoClicker/Debug/AutoClicker.tlog/link.write.1.tlog b/AutoClicker/Debug/AutoClicker.tlog/link.write.1.tlog deleted file mode 100644 index 617b931..0000000 Binary files a/AutoClicker/Debug/AutoClicker.tlog/link.write.1.tlog and /dev/null differ diff --git a/AutoClicker/Debug/vc142.idb b/AutoClicker/Debug/vc142.idb deleted file mode 100644 index 481df9e..0000000 Binary files a/AutoClicker/Debug/vc142.idb and /dev/null differ diff --git a/AutoClicker/Debug/vc142.pdb b/AutoClicker/Debug/vc142.pdb deleted file mode 100644 index e4d43cc..0000000 Binary files a/AutoClicker/Debug/vc142.pdb and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.Build.CppClean.log b/AutoClicker/Release/AutoClicker.Build.CppClean.log deleted file mode 100644 index e69de29..0000000 diff --git a/AutoClicker/Release/AutoClicker.exe.recipe b/AutoClicker/Release/AutoClicker.exe.recipe deleted file mode 100644 index ca883b7..0000000 --- a/AutoClicker/Release/AutoClicker.exe.recipe +++ /dev/null @@ -1,7 +0,0 @@ - - - C:\Users\admin\Desktop\AutoClicker\Release\AutoClicker.exe - - - - \ No newline at end of file diff --git a/AutoClicker/Release/AutoClicker.log b/AutoClicker/Release/AutoClicker.log deleted file mode 100644 index b43c8dd..0000000 --- a/AutoClicker/Release/AutoClicker.log +++ /dev/null @@ -1,7 +0,0 @@ - AutoClicker.cpp -C:\Users\admin\Desktop\AutoClicker\AutoClicker\AutoClicker.cpp(89,1): warning C4326: Der Rückgabetyp von "main" sollte "int" und nicht "void" sein - Code wird generiert. - Previous IPDB not found, fall back to full compilation. - All 13 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. - Codegenerierung ist abgeschlossen. - AutoClicker.vcxproj -> C:\Users\admin\Desktop\AutoClicker\Release\AutoClicker.exe diff --git a/AutoClicker/Release/AutoClicker.obj b/AutoClicker/Release/AutoClicker.obj deleted file mode 100644 index d919a69..0000000 Binary files a/AutoClicker/Release/AutoClicker.obj and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.tlog/AutoClicker.lastbuildstate b/AutoClicker/Release/AutoClicker.tlog/AutoClicker.lastbuildstate deleted file mode 100644 index 1d8176f..0000000 --- a/AutoClicker/Release/AutoClicker.tlog/AutoClicker.lastbuildstate +++ /dev/null @@ -1,2 +0,0 @@ -PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.27.29110:TargetPlatformVersion=10.0.18362.0: -Release|Win32|C:\Users\admin\Desktop\AutoClicker\| diff --git a/AutoClicker/Release/AutoClicker.tlog/AutoClicker.write.1u.tlog b/AutoClicker/Release/AutoClicker.tlog/AutoClicker.write.1u.tlog deleted file mode 100644 index 22fc897..0000000 Binary files a/AutoClicker/Release/AutoClicker.tlog/AutoClicker.write.1u.tlog and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.tlog/CL.command.1.tlog b/AutoClicker/Release/AutoClicker.tlog/CL.command.1.tlog deleted file mode 100644 index 4cf3d0c..0000000 Binary files a/AutoClicker/Release/AutoClicker.tlog/CL.command.1.tlog and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.tlog/CL.read.1.tlog b/AutoClicker/Release/AutoClicker.tlog/CL.read.1.tlog deleted file mode 100644 index 4e52534..0000000 Binary files a/AutoClicker/Release/AutoClicker.tlog/CL.read.1.tlog and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.tlog/CL.write.1.tlog b/AutoClicker/Release/AutoClicker.tlog/CL.write.1.tlog deleted file mode 100644 index 6838de9..0000000 Binary files a/AutoClicker/Release/AutoClicker.tlog/CL.write.1.tlog and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.tlog/link.command.1.tlog b/AutoClicker/Release/AutoClicker.tlog/link.command.1.tlog deleted file mode 100644 index cdb36cd..0000000 Binary files a/AutoClicker/Release/AutoClicker.tlog/link.command.1.tlog and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.tlog/link.read.1.tlog b/AutoClicker/Release/AutoClicker.tlog/link.read.1.tlog deleted file mode 100644 index 28d8bf4..0000000 Binary files a/AutoClicker/Release/AutoClicker.tlog/link.read.1.tlog and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.tlog/link.write.1.tlog b/AutoClicker/Release/AutoClicker.tlog/link.write.1.tlog deleted file mode 100644 index 24540da..0000000 Binary files a/AutoClicker/Release/AutoClicker.tlog/link.write.1.tlog and /dev/null differ diff --git a/AutoClicker/Release/AutoClicker.vcxproj.FileListAbsolute.txt b/AutoClicker/Release/AutoClicker.vcxproj.FileListAbsolute.txt deleted file mode 100644 index e69de29..0000000 diff --git a/AutoClicker/Release/vc142.pdb b/AutoClicker/Release/vc142.pdb deleted file mode 100644 index 27a1158..0000000 Binary files a/AutoClicker/Release/vc142.pdb and /dev/null differ diff --git a/Debug/AutoClicker.exe b/Debug/AutoClicker.exe deleted file mode 100644 index 4b256ef..0000000 Binary files a/Debug/AutoClicker.exe and /dev/null differ diff --git a/Debug/AutoClicker.ilk b/Debug/AutoClicker.ilk deleted file mode 100644 index eba24fe..0000000 Binary files a/Debug/AutoClicker.ilk and /dev/null differ diff --git a/Debug/AutoClicker.pdb b/Debug/AutoClicker.pdb deleted file mode 100644 index 888228b..0000000 Binary files a/Debug/AutoClicker.pdb and /dev/null differ diff --git a/README.md b/README.md index 927e679..f06c2ea 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,20 @@ # AutoClicker C++ autoclicker for the mouse using its X and Y coordinates on screen - +When learning some lessons online,you have to click "Next" to continue watching next lesson. +This program can detect if the Windows system is playing audio. +If not, it means the lesson is over -- that's the right opportunity to click "Next", automaticlly. NumPad1 = save mouse position NumPad2 = activate autoclicker on saved position NumPad3 = STOP Escape = Close + +功能: +网课自动点击工具。 +上网课的时候,设置好按钮坐标,依据系统声音是否在播放,判断一节课是不是已经结束,然后自动点击“下一节课”。 +按键设置: +小键盘1 --设置按钮坐标 +小键盘2 --开始运行 +小键盘3 --停止 +ESC. -----退出 + diff --git a/Release/AutoClicker.exe b/Release/AutoClicker.exe deleted file mode 100644 index 257dfb9..0000000 Binary files a/Release/AutoClicker.exe and /dev/null differ diff --git a/Release/AutoClicker.iobj b/Release/AutoClicker.iobj deleted file mode 100644 index 58d4641..0000000 Binary files a/Release/AutoClicker.iobj and /dev/null differ diff --git a/Release/AutoClicker.ipdb b/Release/AutoClicker.ipdb deleted file mode 100644 index 8881f5d..0000000 Binary files a/Release/AutoClicker.ipdb and /dev/null differ diff --git a/Release/AutoClicker.pdb b/Release/AutoClicker.pdb deleted file mode 100644 index 3f5fa91..0000000 Binary files a/Release/AutoClicker.pdb and /dev/null differ