Populate $form_state['values'] with defaults from drupal_get_form() I'm looking to resave a form's defaults values. In core the test module uses drupalPost() to test the form so I'm thinking this will be custom code.
This is the function I've come up with.

/**
 * Given a form get the default values from it.
 *
 * @param array $defaults
 *   An empty array used to populate the default values.
 * @param array $form
 *   The form returned from drupal_get_form().
 * @param string $parent_key
 *   The key name of the parent.
 */
function get_defaults_from_form(array &amp;$defaults, array $form, $parent_key = '') {
  foreach (element_children($form) as $key) {
    $values = $form[$key];
    if (isset($values['#value'])) {
      // Grab defaults at this level.
      if (!isset($defaults[$key])) {
        $defaults[$key] = $values['#value'];
      }
      else {
        $defaults[$parent_key . '-' . $key] = $values['#value'];
      }
    }
    elseif (isset($values['#default_value'])) {
      // Grab defaults at this level.
      if (!isset($defaults[$key])) {
        $defaults[$key] = $values['#default_value'];
      }
      else {
        $defaults[$parent_key . '-' . $key] = $values['#default_value'];
      }
    }
    elseif (is_array($values)) {
      // Go deeper if needed.
      get_defaults_from_form($defaults, $values, $key);
    }
  }
}


Use it like this:

$theme_name = 'seven';
// Load the required file for the form functionality.
$router_item = menu_get_item('admin/appearance/settings/' . $theme_name);
if ($router_item ['include_file']) {
  require_once DRUPAL_ROOT . '/' . $router_item ['include_file'];
}
// Get the form for this theme.
$form = drupal_get_form('system_theme_settings', $theme_name);
// Get the defaults.
defaults = array();
get_defaults_from_form($defaults, $form);
print_r($defaults);