Angular
Auto-Fill Angular Fields from VFP using Internet Explorer Automation
Gravatar is a globally recognized avatar based on your email address. Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  MarshalR
  All
  Dec 3, 2018 @ 07:49pm

Am attempting to Auto-Fill-in an Angular 1.x Form from Visual FoxPro using Internet Explorer Automation. Can Set Values to Fields but need a way to trigger Angular's Change Event. Can this be done?

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  Rick Strahl
  MarshalR
  Dec 6, 2018 @ 12:33am

You can probably trigger a blur() even by setting focus to another control then setting focus back to it. Basically Angular change detection kicks in when an event fires, so you need to trigger something on the control. You might also be able to trigger a KeyUp() event on the control, but not sure if that can be done directly. Worth a try.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  MarshalR
  MarshalR
  Dec 9, 2018 @ 06:48pm

Hi Rick,

Thanks for your reply.

Even though no Error is Triggered, it appears that Focus Events don't work in Internet Explorer 11. Have Also attempted to directly use the OnBlur Event which also doesn't work.

Here's a sample Web Page I'm attempting to Fill-In via Automation. Left out the AngularJS code (sure you have a copy). Don't know how to Trigger a KeyUp Event (FireEvent('keyup') results in an Error).

Have also tried using the Windows Shell SendKeys command (works in Chrome but not in IE11).

Thanks for your help

Marshal Rosenberg

<!doctype html>
<html ng-app>
    <head>
        <title>AngularJS Fill-In Test</title>
    </head>
    <body>
       <FORM> 
        House No: <input type="text" ng-model="houseno" name="houseno" />
        <br />
     
       
		Street: <input type="text" ng-model="street" name="street" />
        <br />
        {{ houseno + ' ' + street }}
       </FORM>
        <script src="angular.js"></script>    	
    </body>
</html>
Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  MarshalR
  Rick Strahl
  Dec 10, 2018 @ 05:17am

Thanks for your reply Rick - am not using the Web Browser control - using Ole Automation (CREATE OBJECT("InternetExplorer.Application").

Marshal

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  MarshalR
  MarshalR
  Dec 22, 2018 @ 01:13pm

Am looking at a Chrome option. SendKeys works but I need to be able to set Focus to individual Form Controls. Any way to set Focus to an Angular Form Control in Chrome Progrmatically (using JavaScript?)

Marshal

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  MarshalR
  Rick Strahl
  Dec 22, 2018 @ 01:15pm

Am looking at a Chrome option. SendKeys works but I need to be able to set Focus to individual Form Controls. Any way to set Focus to an Angular Form Control in Chrome Progrmatically (using JavaScript?)

Marshal

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  Rick Strahl
  MarshalR
  Dec 22, 2018 @ 01:19pm

There's no good way to really do that. There are a few Chromium based ActiveX controls but they are very buggy and you can't access the DOM through them anyway (Chromium doesn't have COM API).

There are a few really hacky ways to make this work using Web Sockets and injecting some JavaScript but that only works if you control the page or can get some sort of hook into Chrome prior to loading the page.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  MarshalR
  Rick Strahl
  Dec 22, 2018 @ 01:24pm

Thanks for your reply Rick Any way to get Focus and SendKeys to work with an AngularJS Form in IE?

Marshal

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  Rick Strahl
  MarshalR
  Dec 23, 2018 @ 02:02pm

If memory serves you can use el.scope().$apply() to force an AngularJs binding to refresh. Can't recall the exact syntax it's been a long time, but that forces a value to be set and the binding to be refreshed in the active Angular scope of the control.

If you control the application the best thing to do is to have public functions inside of the page that you can call from FoxPro and then use JavaScript to actually update the controls.

There's more info in this very old blog post:

There's also some useful info in this more recent white paper:

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  MarshalR
  Rick Strahl
  Dec 24, 2018 @ 04:22pm

Thanks so much for the info. Will look into this.

Does the el in el.Scope().$Apply() refer to an Input Control?

Marshal

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  Rick Strahl
  MarshalR
  Dec 25, 2018 @ 08:10pm

Yes... Element that is databound.

It's been a long time since I used AngularJs but if I recall Angular attaches .scope() to any object that it manages.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Auto-Fill Angular Fields from VFP using Internet Explorer Automation
  MarshalR
  Rick Strahl
  Dec 26, 2018 @ 06:41am

Does the Input Control/Object have to referenced through JavaScript or can it be referenced from the IE Automation API (document.forms(0).Item() collection)?

Marshal

© 1996-2019