CEF Window Automation

Put simple Tips and Tricks that are not entire Tutorials in this forum
Jhartje
Posts: 10
Joined: 23 May 2019, 08:20

CEF Window Automation

Post by Jhartje » 28 Jul 2021, 14:28

I have been trying to find a way to automate a CEF window that is imbedded in a WPF window.
It turns out the solution is quit simple. All you need to do is start the application that contains the CEF control with the DebuggerPort set to 8081.

Example:

Code: Select all

Run, TargetPath -remote-debugging-port=8081
Then you can access the controls in the CEF control using ACC.
You will need the ACC.ahk which you can find here https://www.autohotkey.com/boards/viewtopic.php?f=7&t=40590&p=185259&hilit=acc+viewer#p185259

burque505
Posts: 1732
Joined: 22 Jan 2017, 19:37

Re: CEF Window Automation

Post by burque505 » 29 Jul 2021, 17:43

@Jhartje, that sounds very interesting. Do you have a sample script you can share?
Regards,
burque505

Jhartje
Posts: 10
Joined: 23 May 2019, 08:20

Re: CEF Window Automation

Post by Jhartje » 09 Aug 2021, 07:23

Nothing in depth at this time as we are still working through some issues with accessing this port on a remote server and having the port reopen when the application is closed. But something like this works just fine.
Open the application with the remote debugging port set to 8081. Do your things to open the CEF window and then get your objects. The code below will get the only checkbox in the CEF window and the check it.

Code: Select all

ChromeLegacyWindow := Winexist("Chrome_WidgetWin_01")
AccChromewin := Acc_Get("Object", "4", 0, "ahk_id " ChromeLegacyWindow)
AccCheckBox := GetElementByRole(AccChromewin, "check box")
AccCheckBox.AccDoDefaultAction()


GetElementByRole(AccObj, Role) {
   if (Acc_GetRoleText(AccObj.accRole(0)) = Role)
      return AccObj
   
   for k, v in Acc_Children(AccObj)
      if IsObject(obj := GetElementByRole(v, Role))
         return obj
}

Post Reply

Return to “Tips and Tricks (v1)”