Camera Trigger Source Code

jwhitham

Senior Member
Nov 1, 2003
172
2
0
Reading
www.vision4ce.com
A long time ago I wrote some code to work as a timer app for the camera on the Himalaya. I've had a couple of emails about this recently so thought I would post the important parts of code for firing off the camera here. Before it's lost forever as I have a Magician these days.

First I start the camera app:-

Code:
void CCameraTimerDlg::RunCameraApp()
{
 // setup parameters for ShellExecuteEx
 SHELLEXECUTEINFO sei;
 memset(&sei,0,sizeof(SHELLEXECUTEINFO));
 sei.cbSize=sizeof(SHELLEXECUTEINFO);
 sei.hwnd=::GetDesktopWindow();
 sei.lpFile=TEXT("\\Windows\\Camera.exe");
 sei.nShow=SW_SHOW;
 
 // start the camera app running (or if it's already running switch to it)
 ShellExecuteEx(&sei); 
}
Then get a handle to it's command window and take the photo:-

Code:
void CCameraTimerDlg::TakePicture()
{
 // Find main Camera App window
 HWND hCameraApp=::FindWindow(TEXT("WCE_IA_Camera_Main"),NULL);
 
 // if we found it okay....
 if (hCameraApp)
 {
  // find the Camera App's first child window (it's UI)
  HWND hCameraSkin=::GetWindow(hCameraApp,GW_CHILD);
 
  // if we found it okay ...
  if (hCameraSkin)
  {
   // press the "take photo" button
   ::SendMessage(hCameraSkin,WM_COMMAND,0xBC4,0x00);
   
    // wait while photo is taken
    ::Sleep(500);
 
    // press "save photo" button
    ::SendMessage(hCameraSkin,WM_COMMAND,0xBD4,0x00);
  }
 
 }
}
and then quit the camera app

Code:
void CCameraTimerDlg::ExitCameraApp()
{
 // find the Camera App's main window
 HWND hCameraApp=::FindWindow(TEXT("WCE_IA_Camera_Main"),NULL);
 
 // if we found it okay, ask it to close
 if (hCameraApp)
  ::SendMessage(hCameraApp,WM_CLOSE,0,0);
}