| 461 | } |
| 462 | |
| 463 | bool SendKeysCommandHandler::FillFileName(const wchar_t* file_name, |
| 464 | IUIAutomation* ui_automation, |
| 465 | IUIAutomationElement* file_selection_dialog) { |
| 466 | CComVariant file_name_combo_box_automation_id(L"1148"); |
| 467 | CComPtr<IUIAutomationCondition> file_name_combo_box_condition; |
| 468 | HRESULT hr = ui_automation->CreatePropertyCondition(UIA_AutomationIdPropertyId, |
| 469 | file_name_combo_box_automation_id, |
| 470 | &file_name_combo_box_condition); |
| 471 | if (FAILED(hr)) { |
| 472 | LOGHR(WARN, hr) << "Could not create condition to look for file selection combo box"; |
| 473 | return false; |
| 474 | } |
| 475 | |
| 476 | CComPtr<IUIAutomationElement> file_name_combo_box; |
| 477 | hr = file_selection_dialog->FindFirst(TreeScope::TreeScope_Children, |
| 478 | file_name_combo_box_condition, |
| 479 | &file_name_combo_box); |
| 480 | if (FAILED(hr)) { |
| 481 | LOGHR(WARN, hr) << "Failed to get file name combo box on current dialog, trying next dialog"; |
| 482 | return false; |
| 483 | } |
| 484 | |
| 485 | CComVariant edit_control_type(UIA_EditControlTypeId); |
| 486 | CComPtr<IUIAutomationCondition> file_name_edit_condition; |
| 487 | hr = ui_automation->CreatePropertyCondition(UIA_ControlTypePropertyId, |
| 488 | edit_control_type, |
| 489 | &file_name_edit_condition); |
| 490 | if (FAILED(hr)) { |
| 491 | LOGHR(WARN, hr) << "Could not create condition to look for file selection edit control"; |
| 492 | return false; |
| 493 | } |
| 494 | |
| 495 | CComPtr<IUIAutomationElement> file_name_edit_box; |
| 496 | hr = file_name_combo_box->FindFirst(TreeScope::TreeScope_Children, |
| 497 | file_name_edit_condition, |
| 498 | &file_name_edit_box); |
| 499 | if (FAILED(hr)) { |
| 500 | LOGHR(WARN, hr) << "Failed to get file name edit box from combo box on current dialog, trying next dialog"; |
| 501 | return false; |
| 502 | } |
| 503 | |
| 504 | CComPtr<IUIAutomationValuePattern> file_name_value_pattern; |
| 505 | hr = file_name_edit_box->GetCurrentPatternAs(UIA_ValuePatternId, |
| 506 | IID_PPV_ARGS(&file_name_value_pattern)); |
| 507 | if (FAILED(hr)) { |
| 508 | LOGHR(WARN, hr) << "Failed to get value pattern for file name edit box on current dialog, trying next dialog"; |
| 509 | return false; |
| 510 | } |
| 511 | |
| 512 | CComBSTR file_name_bstr(file_name); |
| 513 | hr = file_name_value_pattern->SetValue(file_name_bstr); |
| 514 | if (FAILED(hr)) { |
| 515 | LOGHR(WARN, hr) << "Failed to get set file name on current dialog, trying next dialog"; |
| 516 | return false; |
| 517 | } |
| 518 | |
| 519 | return true; |
| 520 | } |
nothing calls this directly
no outgoing calls
no test coverage detected