Question: I'm trying to grab a window by the process name and focus it, then take a screenshot of it. It works perfectly unless I have Teamviewer open (not even while using teamviewer to screenshare, just when teamviewer is running)

When teamviewer is running the window isn't focused or brought to the foreground, and the rect it screenshots is very small (33x21) where normally it would be 1600x900.

Here is the code in question:

```
        proc = Process.GetProcessesByName(procName)[0];
        SetForegroundWindow(proc.MainWindowHandle);
        ShowWindow(proc.MainWindowHandle, SW_RESTORE);

        Rect rect = new Rect();
        GetWindowRect(proc.MainWindowHandle, ref rect);

        int width = rect.right - rect.left;
        int height = rect.bottom - rect.top;

        Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
        Graphics.FromImage(bmp).CopyFromScreen(rect.left, rect.top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);

```

Here is where I'm getting those functions:

```
    [DllImport("user32.dll")]
    private static extern IntPtr ShowWindow(IntPtr hWnd, int nCmdShow);

    [DllImport("user32.dll")]
    public static extern IntPtr GetWindowRect(IntPtr hWnd, ref Rect rect);

    [DllImport("user32.dll")]
    private static extern int SetForegroundWindow(IntPtr hWnd);

```

Answer: 
go to [this](http://www.willis-owen.co.uk/2011/11/dynamic-select-box-with-cakephp-2-0/). this helped me to do the dependent drop down list. it provies a details step by step process.
I think you need to set autoRender to false otherwise it will try to render the template at app/View/Project/getbycustomer.ctp. Also, you probably want to return or print JSON. Ther are probably several ways to do this, but I have something similar that is working and the controller action is basically this:

```
public function getbycustomer() {
  $this->autoRender = $this->layout = false;
  $customer_id = $this->request->data['Event']['customer_id'];
  $projects = $this->Project->find('list', array('conditions'=>array('Project.customer_id' => $customer_id), 'recursive' => -1));
  $this->set('projects', $projects);
  echo json_encode(array('html' => $this->render('your_partial_template')->body())); // This template would be in app/View/Project/json/
}

```

Then in your Ajax call there should be a 'success' callback that handles the JSON returned:

```
success: function(data) {
  $('#EventProjectId').html(data.html); // assuming this an empty container
}

```

Also, unless your projects table is only two columns the result of your find is probably not what you're expecting. Change it to

```
$projects = $this->Project->find('list', array('conditions'=>array('Project.customer_id' => $customer_id), 'fields' => array('id', 'name_or_whatever', 'recursive' => -1));

```

Then in your partial template you can use the form helper:

```
<?php echo $this->Form->input('Projects.id', array('options' => $projects)); ?>

```