FindWindow and OpenDental..

For complex topics that regular users would not be interested in. For power users and database administrators.
Post Reply
User avatar
Justin Shafer
Posts: 596
Joined: Sat Jul 28, 2007 7:34 pm
Location: Fort Worth, TX.

FindWindow and OpenDental..

Post by Justin Shafer » Thu Aug 13, 2015 10:25 am

FindWindow and OpenDental.. I am using a MFC project, and it seems slightly difficult for me to find OpenDental's HWnd using the Title text because it changes... Anyway we can use a specific OpenDental class in the Window so this ugliness can go away?

And I have a feeling one day the window class will change?


if (CWnd::FindWindow( _T("WindowsForms10.Window.8.app.0.2bf8098_r16_ad1"), NULL)){
pWndPrev = CWnd::FindWindow( _T("WindowsForms10.Window.8.app.0.2bf8098_r16_ad1"), NULL);
if (NULL != pWndPrev)
{
// If so, does it have any popups?
// If iconic, restore the main window
if (pWndPrev->IsIconic())
// Bring the main window or its popup to the foreground
pWndPrev->ShowWindow(SW_RESTORE);
pWndPrev->ShowWindow(SW_MAXIMIZE);
// Bring the main window or its popup to the foreground
pWndPrev->SetForegroundWindow();
pWndPrev->SetActiveWindow();
INPUT input;
memset(&input,0,sizeof(INPUT));
input.type = INPUT_MOUSE;
input.mi.mouseData=0;
input.mi.dx = 323*(65536/GetSystemMetrics(SM_CXSCREEN));//x being coord in pixels
input.mi.dy = 77*(65536/GetSystemMetrics(SM_CYSCREEN));//y being coord in pixels
input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;
SendInput(1,&input,sizeof(input));
Sleep(1000);
if (CWnd::FindWindow( NULL, _T("Select Source"))){
keybd_event (VK_SPACE, 0, 0, 0 );
Sleep(100);
keybd_event (VK_SPACE, 0, KEYEVENTF_KEYUP, 0);
Sleep (1000);
}
}
}
}
}
//UpdateData(FALSE);
if (CWnd::FindWindow(NULL, _T("Video DataSource"))){
pWndPrev = CWnd::FindWindow(NULL, _T("Video DataSource"));
if (NULL != pWndPrev)
{
// If so, does it have any popups?
pWndChild = pWndPrev->GetLastActivePopup();
// If iconic, restore the main window
if (pWndPrev->IsIconic())
//Sleep(2000);
pWndPrev->ShowWindow(SW_RESTORE);
// Bring the main window or its popup to the foreground
pWndChild->SetForegroundWindow();
pWndChild->SetActiveWindow();
pWndChild->MoveWindow(NULL,NULL,800,600,TRUE);
// and you are done activating the other application
}
}

User avatar
Justin Shafer
Posts: 596
Joined: Sat Jul 28, 2007 7:34 pm
Location: Fort Worth, TX.

Re: FindWindow and OpenDental..

Post by Justin Shafer » Thu Aug 13, 2015 6:14 pm

So I didn't realize after using the twain function in OD, that the category is not remembered when the program first opens. If defaults to the top of the list.

Could you guys default it to Photos?

I can't figure out a way to use AutoHotKey or Visual Studio (MFC) to pull this off.

Post Reply