📜 ⬆️ ⬇️

Launch Skype without the annoying Main Page

The reason for writing this was a recent question . I am also very annoyed by the Skype Home window that appears every time I start it, but with the help of a simple C program I managed to get rid of it. It turned out something like Hello World Tutorial on use of Windows API. The program can be downloaded here , and the source code with the description will be found under the cut.


Algorithm in words
  1. We learn from the registry the path where Skype is installed.
    It is registered in HKEY_CURRENT_USER \ Software \ Skype \ Phone \ SkypePath.
  2. Run Skype.exe in the new process.
  3. Since the launch of Skype, we will search for a window with the title “Skype Home” or “Skype Home Page” for 30 seconds. Get the window handle and wait for it to become visible.
  4. Send this window a WM_CLOSE message to automatically close it.

Text runskype.c

#include <windows.h> BOOL RunSkype() { STARTUPINFO si; PROCESS_INFORMATION pi; HKEY key; BYTE appPath[512]; DWORD pathSize = sizeof(appPath); BOOL result = FALSE; //     HKEY_CURRENT_USER\Software\Skype\Phone\SkypePath     Skype if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Skype\\Phone", 0, KEY_READ, &key)==ERROR_SUCCESS) { if (RegQueryValueEx(key, "SkypePath", NULL, NULL, appPath, &pathSize)==ERROR_SUCCESS) { //      Skype.exe    ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); result = CreateProcess(appPath, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } RegCloseKey(key); } return result; } int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { if (RunSkype()) { //   30     Skype      Skype Home int i; for (i = 0; i < 3000; i++) { //   THomeForm     Inspect Objects  Windows SDK //    "Skype Home",    "  Skype" HWND wnd = FindWindow("THomeForm", "Skype Home"); if (!wnd) { wnd = FindWindow("THomeForm", "  Skype"); } //     ,       if (wnd && IsWindowVisible(wnd)) { SendMessage(wnd, WM_CLOSE, 0, 0); return 0; } //    ,    10  Sleep(10); } } return 1; } 


Compilation

Using Visual Studio:
cl user32.lib advapi32.lib runskype.c

Using GCC (MinGW):
gcc -o runskype.exe runskype.c

Note:
In Skype, the Compact View should be selected.
Tested on Windows 7 and Skype 5.5.0.
Of course, the described mechanism is applicable to other programs.

')

Source: https://habr.com/ru/post/127558/


All Articles