Jump to content
OldMan-Newbee

Convert my old IE based .au3 to work on EDGE or Chrome

Recommended Posts

I'm not much of a coder - I built a script yrs back (8+ yrs) that copies text out of a windows program's textbox (a 911 call creation screen), parses the text into components and inputs that text into the correct textbox fields on a website opened in IE.  It prevents the 911 dispatcher from needing to double enter data.

I want to update this so the users are not limited to using IE.  But could use Chrome or EDGE. I'm having trouble figuring out how best to replace the _IE... calls with something that points to active EDGE or Chrome window. Again I'm sorry but not much of a coder.  I just need some examples of putting text into textboxes and selecting dropdown options inside of EDGE or Chrome. The site does not work well with FireFox.  Any suggestions would be great.

Here is the first part of the script. The _IEAttach , _IEFrameGetObjByName, _IEFormElementGetObjByName and such are what I need to replace with something that will identify the fields on the website in EDGE/Chrome.

Thank you for any direction you can give me.

#include<IE.au3>
#include <MsgBoxConstants.au3>
AutoItSetOption("WinTitleMatchMode",2)    ;set matching to grab window title
WinActivate("I/Dispatcher [")            ;select the dispatch window
$title = WinGetTitle("[active]")            ;assign window title to varible $title
Opt("SendKeyDelay",250)            ;delay 250 milliseconds
Send("{F7}")                ;move focus
Opt("SendKeyDelay",250)            ;another delay
Send("+{HOME}")                ;highlight all text in the command line
$pretext = ControlGetText($title,"",1001)        ;assign text from commandline into var $pretext for parsing

If $pretext = "" Then
    Send("{F7}")
    Opt("SendKeyDelay",5)
    Send("{DOWN}")
    $pretext2 = ControlGetText($title,"",1001)
    $aCmdlin = StringSplit($pretext2,",",0)
    Send("{F7}"&"+{HOME}"&"{DELETE}")
ElseIf $pretext <> "" Then
    Send("{F7}")
    $aCmdlin = StringSplit($pretext,",",0)
    Send("{ENTER}")
EndIf


If StringLen($aCmdlin[1]) >= 3 Then        ;length of the first string in the aCmdlin array determins if
    $car_id = $aCmdlin[1]        ;the user typed in the car id first or the query code first
    $type = $aCmdlin[2]            ;car ids are 3 or 4 chars long while the query codes are 1 or 2 chars long
Else
    $type = $aCmdlin[1]
    $car_id = $aCmdlin[2]
EndIf

AutoItSetOption("WinTitleMatchMode",2)
If WinActivate("Hot File Inquiry") = 0 Then
    MsgBox(0,"Error","The Hot File Inquiry Window is not open, please open it and re-submit the query - line 98")
    Exit
EndIf
WinActivate("Hot File Inquiry")
Local $Winh = WinActivate("Hot File Inquiry")
Local $oIE = _IEAttach("Hot File Inquiry")
If Not CheckIEError(@error,"_IEAttach: Hot File Inquiry - line 104") Then
    Exit
EndIf
Local $o_IEFrame = _IEFrameGetObjByName($oIE,"TOP")
If Not CheckIEError(@error,"_IEFrameGetObjByName:TOP") Then
    Exit
EndIf
Local $o_form = _IEGetObjByName($o_IEFrame,"inquiry")
If Not CheckIEError(@error,"_IEGetObjByName:inquiry") Then
    Exit
 EndIf
$oB = _IEFormElementGetObjByName($o_form,"b_show_inq1")      ; puts hotfiles window back to new search screen prior to transfering data
_IEAction($oB,"click")
$o_carid = _IEFormElementGetObjByName($o_form,"car_id")
If Not CheckIEError(@error,"_IEFormElementGetObjByName:car_id") Then
    Exit
EndIf

 

 

Share this post


Link to post
Share on other sites

If you want to support multiple browsers, then I suggest that you switch to using the Webdriver UDF (I may be slightly biased 😛).

46 minutes ago, OldMan-Newbee said:

The site does not work well with FireFox. 

That's unfortunate, because FF is the easiest IMO when needing to attach to an existing instance of a web browser. Pretty sure that I've posted elsewhere about the challenges with attaching to chromium-based browsers.

Many of the commands have similar naming conventions, ie --
 

_IEAttach ==> _WD_Attach

_IEGetObjByName ==> _WD_GetElementByName

_IEAction ==> _WD_Action or _WD_ElementAction

Your script looks fairly simple other than the use of frames.

Give it a shot and come back with any questions / issues you encounter. :thumbsup:

Share this post


Link to post
Share on other sites

Danp2 - Thank you so much for all your work on WD

I'm clearly too inept to sort through this.  I've been playing around with my copy of your wd_demo.  I can follow along with how much of it works.

I've been able to enter data into my website if I start with _WD_Navigate - launch a new EDGE session and go to the website.

I can't seem to access the site if it is already open.

I can use WinActivate to get focus on the existing site but then cannot figure out how to us WD to put text into the already open page.

Any suggestions or examples as my old brain is fried.

Thank you,

Share this post


Link to post
Share on other sites

I figured I was just screwing up the script or missing some important piece. It has to do with how the session data is collected at the launch of the browser?

I will dig more. It is still far better than them re-typing info in half a dozen fields.

Thank you again Danp2 for your time.

OM-N

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...