Jump to content
nooneclose

[SOLVED] How to send text to a popup in IE with Autoit

Recommended Posts

I need to send a string of text to this popup and click on the ok button to save it.

Here is the code I have so far:

;Start IE 
Sleep(7000)
$oIE = _IECreate("http://www.google.com")
Sleep(500)
_IELoadWait($oIE)
$hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window
Sleep(500)
WinSetState($hIE, "", @SW_MAXIMIZE)

;Wait for a browser page load to complete
Sleep(3000)
_IENavigate($oIE, "https://properURL.com")
Sleep(8000)
_IELoadWait($oIE)

;Attach to a browser control embedded in another window
$oIE = _IEAttach("https://"properURL.com", url")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console
Sleep(2000)

;Get the title of the webpage
;Local $wTitle = _IEPropertyGet($oIE, "title")
;MsgBox($MB_SYSTEMMODAL, "Webpage title:", $wTitle)

;Clicks the new button
Sleep(3000)
_IEAction($nWorkOrderB, "focus")
_IEAction($nWorkOrderB, "click")
Sleep(5000)

;Store the Element names where the important data will be sent
;Store the long description button
Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img")
;Store the long Description field id
Local $wComments    = _IEGetObjById($oIE, "ma6499a9c-rte_iframe")
;Store the ok button id that is in the long description
Local $wCommOk      = _IEGetObjById($oIE, "m74031266-pb")

;*******************************************************************************
; Send the stored data to the proper field
;*******************************************************************************

;Click the long description button
Sleep(300)
_IEAction($wLongDButton, "focus")
_IEAction($wLongDButton, "click")
Sleep(300)

;Sends the Comments
Sleep(500)
_IEAction($wComments, "focus")
_IEAction($wComments, "click")
Sleep(500)
_IEFormElementSetValue($wComments, "hello darkness my old friend")

;Click the ok button
Sleep(500)
_IEAction($wCommOk, "focus")
_IEAction($wCommOk, "click")
Sleep(500)

 

Here is the popup:

5be33f8118f44_Screenshot(138).png.cd23a99616d58e3cf37331725eca86fd.png

Edited by nooneclose

Share this post


Link to post
Share on other sites

@nooneclose you really need to start engaging the gray matter before you report threads. As for your "his response was mean" report, I have already responded in that thread. As for this one, rather than reporting the thread because you feel the response is "not helpful", why not take the time to read the response (which makes several valid points) and respond. Complaining about those that volunteer their time on this forum is a great way to ensure you receive no help in the future.

If you truly feel a response is not being helpful, try being the opposite of "unnecessary, unhelpful, unprofessional and childish"  and ignore it rather than complaining. Not everything is a personal affront to you, even if you are sensing tone in someone's reply.

Share this post


Link to post
Share on other sites

@Danp2 

  Here is the code with a test site URL that anyone can use to see my issue. on the test site you will need to click on the "new work order button" then click on the "long description" button which sits next to the description field. The description field is the one to the right of the work order number field.  

;Start IE 
Sleep(7000)
$oIE = _IECreate("http://www.google.com")
Sleep(500)
_IELoadWait($oIE)
$hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window
Sleep(500)
WinSetState($hIE, "", @SW_MAXIMIZE)

;Wait for a browser page load to complete
Sleep(3000)
_IENavigate($oIE, "https://maximo-demo76.mro.com/maximo/ui/?event=loadapp&value=wotrack&uisessionid=4019&csrftoken=u4q602akdrmfdknalrdmf0rcdo")
Sleep(8000)
_IELoadWait($oIE)

;Attach to a browser control embedded in another window
$oIE = _IEAttach("https://maximo-demo76.mro.com/maximo/ui/?event=loadapp&value=wotrack&uisessionid=4019&csrftoken=u4q602akdrmfdknalrdmf0rcdo")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console
Sleep(2000)

;Get the title of the webpage
;Local $wTitle = _IEPropertyGet($oIE, "title")
;MsgBox($MB_SYSTEMMODAL, "Webpage title:", $wTitle)

;Clicks the new button
Sleep(3000)
_IEAction($nWorkOrderB, "focus")
_IEAction($nWorkOrderB, "click")
Sleep(5000)

;Store the Element names where the important data will be sent
;Store the long description button
Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img")
;Store the long Description field id
Local $wComments    = _IEGetObjById($oIE, "ma6499a9c-rte_iframe")
;Store the ok button id that is in the long description
Local $wCommOk      = _IEGetObjById($oIE, "m74031266-pb")

;*******************************************************************************
; Send the stored data to the proper field
;*******************************************************************************

;Click the long description button
Sleep(300)
_IEAction($wLongDButton, "focus")
_IEAction($wLongDButton, "click")
Sleep(300)

;Sends the Comments
Sleep(500)
_IEAction($wComments, "focus")
_IEAction($wComments, "click")
Sleep(500)
_IEFormElementSetValue($wComments, "Did it work?")

;Click the ok button
Sleep(500)
_IEAction($wCommOk, "focus")
_IEAction($wCommOk, "click")
Sleep(500)

 

Share this post


Link to post
Share on other sites

@JLogan3o13 posting about my reports in a public post instead of messaging me directly is unprofessional. FYI I read all three pages of comments on the other post and saw nothing that would help me. I also read the UDF that was posted. I did not understand it and also that post was about clicking on a popup. I want to send a popup text. Also, I am very grateful for the people who use their free time to help others. I often thank them and let them know how helpful they were in a very kind manner. It is the unnecessary rude posts I don't like. I don't have the luxury of free time when I come here for help that is because I need help not rude remarks or criticism.

Edited by nooneclose

Share this post


Link to post
Share on other sites
1 minute ago, nooneclose said:

@JLogan3o13 posting about my reports in a public post instead of messaging me directly is literally childish and very unprofessional. FYI I read all three pages of comments on the other post and saw nothing that would help me. I also read the UDF that was posted. I did not understand it and also that post was about clicking on a popup. I want to send a popup text. Also, I am very grateful for the people who use their free time to help others. I often thank them and let them know how helpful they were in a very kind manner. It is the unnecessary rude posts I don't like. I don't have the luxury of free time when I come here for help that is because I need help not rude remarks or criticism.

You keep using the terms "childish" and "unprofessional" when you are the only one acting in this manner. A couple of things:

  • Quote

    I also read the UDF that was posted. I did not understand it

    Your capacity for understanding suggestions from forum members (or lack thereof) is no one's problem but your own. You could ask for clarification instead of complaining that others are not being as helpful as you feel they should be.

  • Quote

    I don't have the luxury of free time when I come here for help that is because I need help not rude remarks or criticism.

    You sound very much as though you believe you are entitled to a response right now, because your time is precious. First and foremost, this is not a paid support forum but one dedicated to helping people with their own scripts. Thus far from your time here I see more of a demand on others to barf up code for you or "just fix it" rather than a desire to actually learn. That, along with your treatment of those trying to help, is not going to encourage the many forum members that volunteer their time to continue to assist.

This is my final word on the matter, beyond a warning not to continue to abuse the reporting system because someone is "not being helpful" to you. If it continues you will be granted a vacation from posting on the site for a day. 

Share this post


Link to post
Share on other sites

@nooneclose You need to help us to be better able to help you. Showing us an image of a popup isn't very useful, especially when you could have posted the demo site information again. The code you posted doesn't even run, so you might want to work on that.

P.S. The popup that you want to interact with is being displayed in an iframe element, so you'll want to use _IEFrameGetCollection or _IEFrameGetObjByName to get a reference to this container. Read the help file for examples on how to properly use these commands.

Share this post


Link to post
Share on other sites

@Danp2  Thank you very much. I am not sure why the code I posted didn't work for you? It works for me. I will look into the _IEFrameGetCollection and _IEFrameGetObjByName. Thank you again for your help I will try some stuff tomorrow and get back with you. 

Also, I will do better (with my posts). I'll post a more detailed version of my code and the popup tomorrow with the demo site as a reference. 

Edited by nooneclose

Share this post


Link to post
Share on other sites
23 minutes ago, nooneclose said:

I am not sure why the code I posted didn't work for you? It works for me.

I don't see how that's possible when --

1) The UDF include is missing for the _IE functions

2) The variable $nWorkOrderB is used before is value is defined

That's as far as I got. :lol:

Share this post


Link to post
Share on other sites

@Danp2 ok at your request I have duplicated my script using the demo site. the script is 100% working. Also, I think you are going to like it very much. 😊 

Here is the working code with your suggestion in place:

#include <OutlookEX.au3>                                                ;Allows the outlook functions
#include <IE.au3>                                                       ;Allows Internet Explorer functions
#include <AD.au3>                                                       ;Allows Active Directory functions
#include "DTC.au3"                                                      ;Allows Custom Date and Time functions
#include <Date.au3>                                                     ;Allows Date and Time functions
#include <DateTimeConstants.au3>                                        ;Allows Date and Time functions
#include <StringConstants.au3>                                          ;Allows Certain String functions
#include <Array.au3>                                                    ;Allows Array functions
#include <Misc.au3>                                                     ;Allows the "is pressed" function to be used
#include <MsgBoxConstants.au3>                                          ;Allows message box to be used
#include <Constants.au3>                                                ;Allows constants to be used
;#RequireAdmin                                                          ;Requests admin privliges before starting program

;*******************************************************************************
;Closes the script if "End" is pressed
;*******************************************************************************
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

HotKeySet("{END}", "Terminate")
Func Terminate()
    MsgBox($MB_ICONINFORMATION, "DEATH", "Script Stoped!")
    Exit
EndFunc


;*******************************************************************************
; Opens the Maximo Test site and files a New Workorder
;*******************************************************************************
;Start IE at the Maximo Test site from google
Sleep(2000)
$oIE = _IECreate("http://www.google.com")
Sleep(500)
_IELoadWait($oIE)
$hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window
Sleep(500)
WinSetState($hIE, "", @SW_MAXIMIZE)

;Wait for a browser page load to complete
Sleep(3000)
;Test site
_IENavigate($oIE, "https://maximo-demo76.mro.com/maximo/webclient/login/login.jsp?welcome=true")
Sleep(8000)
_IELoadWait($oIE)

;Attach to a browser control embedded in another window
;Fake site
$oIE = _IEAttach("https://maximo-demo76.mro.com/maximo/webclient/login/login.jsp?welcome=true", "url")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console
Sleep(2000)

;Store the username and password
Local $wUserName = _IEGetObjByName($oIE, "username")
Local $wPassword = _IEGetObjByName($oIE, "password")

;Send the username and password
_IEFormElementSetValue($wUserName, "maximo")
_IEFormElementSetValue($wPassword, "maxpass1")
Sleep(3000)

;Clicks the login button
Local $wLogin = _IEGetObjById($oIE, "loginbutton")
Sleep(500)
_IEAction($wLogin, "focus")
_IEAction($wLogin, "click")
Sleep(500)

;Navigate to the work order tracking application
Sleep(3000)
Local $wWorkOrderButton = _IEGetObjById($oIE, "m7f8f3e49_ns_menu_WO_MODULE_a")
Local $wWorkOrderTrack  = _IEGetObjById($oIE, "m7f8f3e49_ns_menu_WO_MODULE_sub_changeapp_WOTRACK_a")
Sleep(300)

_IEAction($wWorkOrderButton, "focus")
_IEAction($wWorkOrderButton, "click")

_IEAction($wWorkOrderTrack, "focus")
_IEAction($wWorkOrderTrack, "click")

Sleep(8000)
_IELoadWait($oIE)
MsgBox("", "", "Did it work?")

;Store the Work order Button ID
Local $nWorkOrderB  = _IEGetObjById($oIE, "toolactions_INSERT-tbb_anchor")

;Clicks the new work order button
Sleep(3000)
_IEAction($nWorkOrderB, "focus")
_IEAction($nWorkOrderB, "click")
Sleep(5000)

;Store the Element names where the important data will be sent
;You can ignore these:
;Local $wDescription = _IEGetObjById($oIE, "m65d795a4-tb")
;Local $wLocation    = _IEGetObjById($oIE, "m7b0033b9-tb")
;Local $wWorkType    = _IEGetObjById($oIE, "me2096203-tb")
;Local $wTime        = _IEGetObjById($oIE, "m972c8009-tb")
;Local $wByEmail     = _IEGetObjById($oIE, "m89bb4711-tb")
;Local $wReportedBy  = _IEGetObjById($oIE, "me25d1b3-tb")
;Local $wRoomPhone   = _IEGetObjById($oIE, "mb9bb8962-tb")

;Store the long description button
Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img")
;Store the long Description field id
Local $wComments    = _IEGetObjById($oIE, "ma6499a9c-rte_iframe")
;Store the ok button id that is in the long description
Local $wCommOk      = _IEGetObjById($oIE, "m74031266-pb")


;*******************************************************************************
; Send the stored data to the proper field
;*******************************************************************************
;Sends the discription
Sleep(2000)
;_IEFormElementSetValue($wDescription, $eDescription)
Sleep(2000)

;Click the long description button
Sleep(300)
_IEAction($wLongDButton, "focus")
_IEAction($wLongDButton, "click")
Sleep(300)

;Sends the Comments
Sleep(500)
_IEAction($wComments, "focus")
_IEAction($wComments, "click")
_IEAction($wComments, "click")
Sleep(500)
_IEFormElementSetValue($wComments, "Hello World! did it work?")

;Click the ok button
Sleep(500)
_IEAction($wCommOk, "focus")
_IEAction($wCommOk, "click")
Sleep(500)

Local $oForm = _IEFormGetCollection($oIE, 0)

;Run some tests to see where the long description element is
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 2)
_IEFormElementSetValue($oQuery, "AutoIt IE test 2")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 3)
_IEFormElementSetValue($oQuery, "AutoIt IE test 3")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE test 4")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 5)
_IEFormElementSetValue($oQuery, "AutoIt IE test 5")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 6)
_IEFormElementSetValue($oQuery, "AutoIt IE test 6")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 7)
_IEFormElementSetValue($oQuery, "AutoIt IE test 7")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 8)
_IEFormElementSetValue($oQuery, "AutoIt IE test 8")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 9)
_IEFormElementSetValue($oQuery, "AutoIt IE test 9")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 8)
_IEFormElementSetValue($oQuery, "AutoIt IE test 8")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 10)
_IEFormElementSetValue($oQuery, "AutoIt IE test 10")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 11)
_IEFormElementSetValue($oQuery, "AutoIt IE test 11")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 12)
_IEFormElementSetValue($oQuery, "AutoIt IE test 12")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 13)
_IEFormElementSetValue($oQuery, "AutoIt IE test 13")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 14)
_IEFormElementSetValue($oQuery, "AutoIt IE test 14")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 15)
_IEFormElementSetValue($oQuery, "AutoIt IE test 15")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 16)
_IEFormElementSetValue($oQuery, "AutoIt IE test 16")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 17)
_IEFormElementSetValue($oQuery, "AutoIt IE test 17")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 18)
_IEFormElementSetValue($oQuery, "AutoIt IE test 18")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 19)
_IEFormElementSetValue($oQuery, "AutoIt IE test 20")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 20)
_IEFormElementSetValue($oQuery, "AutoIt IE test 20")

Sleep(3000)

;Sends the Location
Sleep(300)
;_IEFormElementSetValue($wLocation, $eLocation)
Sleep(2000)

;Sends the Work Type
Sleep(300)
Local $eWorkType = "CM"
;_IEFormElementSetValue($wWorkType, $eWorkType)
Sleep(2000)

;Sends the Reported Date
Sleep(300)
;_IEFormElementSetValue($wTime, $eSentOn)
Sleep(2000)

;Sends the Reported By
Sleep(300)
;_IEFormElementSetValue($wReportedBy, $eReportedBy)
Sleep(2000)

;Sends the Reported By Email
Sleep(300)
;_IEFormElementSetValue($wByEmail, $eSenderAddress)
Sleep(2000)

;Sends the Reported By Phone
Sleep(300)
;_IEFormElementSetValue($wRoomPhone, $eRoomPhone)
Sleep(2000)

I tried 20 elements but I did not see any of them in the long description field.  Also, I do not remember if I mentioned that in order for "text" to appear in the long description the ok button has to be pressed when the pop up pops up or it won't save.

anyways as always, any help would be appreciated.  

Share this post


Link to post
Share on other sites

@Danp2 I see what I did wrong, my mistake.  I misread your reply.  I thought it said to use _IEFormElementGetCollection when it says _IEFrameGetCollection. I was confused for a second because I did use _IEFormElementGetCollection 20 times. I will make the change soon and get back with you. Thank you. 

Share this post


Link to post
Share on other sites

@Danp2 Ok here is the updated code with the _IEFrameGetCollection:

#include <OutlookEX.au3>                                                ;Allows the outlook functions
#include <IE.au3>                                                       ;Allows Internet Explorer functions
#include <AD.au3>                                                       ;Allows Active Directory functions
#include "DTC.au3"                                                      ;Allows Custom Date and Time functions
#include <Date.au3>                                                     ;Allows Date and Time functions
#include <DateTimeConstants.au3>                                        ;Allows Date and Time functions
#include <StringConstants.au3>                                          ;Allows Certain String functions
#include <Array.au3>                                                    ;Allows Array functions
#include <Misc.au3>                                                     ;Allows the "is pressed" function to be used
#include <MsgBoxConstants.au3>                                          ;Allows message box to be used
#include <Constants.au3>                                                ;Allows constants to be used
;#RequireAdmin                                                          ;Requests admin privliges before starting program

;*******************************************************************************
;Closes the script if "End" is pressed
;*******************************************************************************
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

HotKeySet("{END}", "Terminate")
Func Terminate()
    MsgBox($MB_ICONINFORMATION, "DEATH", "Script Stoped!")
    Exit
EndFunc


;*******************************************************************************
; Opens the Maximo Test site and files a New Workorder
;*******************************************************************************
;Start IE at the Maximo Test site from google
Sleep(2000)
$oIE = _IECreate("http://www.google.com")
Sleep(500)
_IELoadWait($oIE)
$hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window
Sleep(500)
WinSetState($hIE, "", @SW_MAXIMIZE)

;Wait for a browser page load to complete
Sleep(3000)
;Test site
_IENavigate($oIE, "https://maximo-demo76.mro.com/maximo/webclient/login/login.jsp?welcome=true")
Sleep(8000)
_IELoadWait($oIE)

;Attach to a browser control embedded in another window
;Fake site
$oIE = _IEAttach("https://maximo-demo76.mro.com/maximo/webclient/login/login.jsp?welcome=true", "url")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console
Sleep(2000)

;Store the username and password
Local $wUserName = _IEGetObjByName($oIE, "username")
Local $wPassword = _IEGetObjByName($oIE, "password")

;Send the username and password
_IEFormElementSetValue($wUserName, "maximo")
_IEFormElementSetValue($wPassword, "maxpass1")
Sleep(3000)

;Clicks the login button
Local $wLogin = _IEGetObjById($oIE, "loginbutton")
Sleep(500)
_IEAction($wLogin, "focus")
_IEAction($wLogin, "click")
Sleep(500)

;Navigate to the work order tracking application
Sleep(3000)
Local $wWorkOrderButton = _IEGetObjById($oIE, "m7f8f3e49_ns_menu_WO_MODULE_a")
Local $wWorkOrderTrack  = _IEGetObjById($oIE, "m7f8f3e49_ns_menu_WO_MODULE_sub_changeapp_WOTRACK_a")
Sleep(300)

_IEAction($wWorkOrderButton, "focus")
_IEAction($wWorkOrderButton, "click")

_IEAction($wWorkOrderTrack, "focus")
_IEAction($wWorkOrderTrack, "click")

Sleep(8000)
_IELoadWait($oIE)

;Store the Work order Button ID
Local $nWorkOrderB  = _IEGetObjById($oIE, "toolactions_INSERT-tbb_anchor")

;Clicks the new work order button
Sleep(3000)
_IEAction($nWorkOrderB, "focus")
_IEAction($nWorkOrderB, "click")
Sleep(5000)

;Store the Element names where the important data will be sent
;You can ignore these:
;Local $wDescription = _IEGetObjById($oIE, "m65d795a4-tb")
;Local $wLocation    = _IEGetObjById($oIE, "m7b0033b9-tb")
;Local $wWorkType    = _IEGetObjById($oIE, "me2096203-tb")
;Local $wTime        = _IEGetObjById($oIE, "m972c8009-tb")
;Local $wByEmail     = _IEGetObjById($oIE, "m89bb4711-tb")
;Local $wReportedBy  = _IEGetObjById($oIE, "me25d1b3-tb")
;Local $wRoomPhone   = _IEGetObjById($oIE, "mb9bb8962-tb")

;Store the long description button
Local $wLongDButton = _IEGetObjById($oIE, "mad3161b5-img2")
;Store the long Description field id
Local $wComments    = _IEGetObjById($oIE, "dijitEditorBody")
;Store the ok button id that is in the long description
Local $wCommOk      = _IEGetObjById($oIE, "m74031266-pb")


;*******************************************************************************
; Send the stored data to the proper field
;*******************************************************************************
;Sends the discription
Sleep(2000)
;_IEFormElementSetValue($wDescription, $eDescription)
Sleep(2000)

;Click the long description button
Sleep(300)
_IEAction($wLongDButton, "focus")
_IEAction($wLongDButton, "click")
Sleep(300)

;Sends the Comments
Sleep(500)
_IEAction($wComments, "focus")
_IEAction($wComments, "click")
_IEAction($wComments, "click")
Sleep(500)
_IEFormElementSetValue($wComments, "Hello World! did it work?")

;Click the ok button
Sleep(500)
_IEAction($wCommOk, "focus")
_IEAction($wCommOk, "click")
Sleep(500)

Local $oForm = _IEFormGetCollection($oIE, 0)

;Run some tests to see where the long description element is
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 2)
_IEFormElementSetValue($oQuery, "AutoIt IE test 2")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 3)
_IEFormElementSetValue($oQuery, "AutoIt IE test 3")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE test 4")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 5)
_IEFormElementSetValue($oQuery, "AutoIt IE test 5")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 6)
_IEFormElementSetValue($oQuery, "AutoIt IE test 6")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 7)
_IEFormElementSetValue($oQuery, "AutoIt IE test 7")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 8)
_IEFormElementSetValue($oQuery, "AutoIt IE test 8")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 9)
_IEFormElementSetValue($oQuery, "AutoIt IE test 9")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 8)
_IEFormElementSetValue($oQuery, "AutoIt IE test 8")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 10)
_IEFormElementSetValue($oQuery, "AutoIt IE test 10")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 11)
_IEFormElementSetValue($oQuery, "AutoIt IE test 11")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 12)
_IEFormElementSetValue($oQuery, "AutoIt IE test 12")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 13)
_IEFormElementSetValue($oQuery, "AutoIt IE test 13")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 14)
_IEFormElementSetValue($oQuery, "AutoIt IE test 14")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 15)
_IEFormElementSetValue($oQuery, "AutoIt IE test 15")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 16)
_IEFormElementSetValue($oQuery, "AutoIt IE test 16")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 17)
_IEFormElementSetValue($oQuery, "AutoIt IE test 17")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 18)
_IEFormElementSetValue($oQuery, "AutoIt IE test 18")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 19)
_IEFormElementSetValue($oQuery, "AutoIt IE test 20")
Sleep(300)
Local $oQuery = _IEFormElementGetCollection($oForm, 20)
_IEFormElementSetValue($oQuery, "AutoIt IE test 20")

Sleep(3000)

;More tests to see where the long description element is
Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFrame = 0
For $i = 0 To ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection($oIE, $i)
    $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt)


;Sends the Location
Sleep(300)
;_IEFormElementSetValue($wLocation, $eLocation)
Sleep(2000)

;Sends the Work Type
Sleep(300)
Local $eWorkType = "CM"
;_IEFormElementSetValue($wWorkType, $eWorkType)
Sleep(2000)

;Sends the Reported Date
Sleep(300)
;_IEFormElementSetValue($wTime, $eSentOn)
Sleep(2000)

;Sends the Reported By
Sleep(300)
;_IEFormElementSetValue($wReportedBy, $eReportedBy)
Sleep(2000)

;Sends the Reported By Email
Sleep(300)
;_IEFormElementSetValue($wByEmail, $eSenderAddress)
Sleep(2000)

;Sends the Reported By Phone
Sleep(300)
;_IEFormElementSetValue($wRoomPhone, $eRoomPhone)
Sleep(2000)

Here is a picture of the frames it found. How do I access the correct Frame? 

5be46efe32e92_Screenshot(140).thumb.png.547fc5a11533af1ee38a3b62a31d11d9.png

Edited by nooneclose

Share this post


Link to post
Share on other sites

I think I found the name of the frames but I'm not sure what to do with them. 

Frame names:

frames = window.top.document.getElementsByTagName("IFRAME")

var frame = frames; if( frame.id == "md3374424_bimviewer_model_frame"

viewer = new ViewerWrapper( md3374424_bimviewer_modelNW )

var ctrl = document.getElementById( "md3374424_bimviewer_modelNW" )

modelMgr = new ModelManager( "md3374424_bimviewer_modelNW", "md3374424_bimviewer_model_model_cb", viewer )

what does the frame name look like? 

Edited by nooneclose

Share this post


Link to post
Share on other sites

@Danp2Thank you very very much! I know this is difficult and that you're helping me out of your free time just wanted you to know that your help means a lot to me. Even if its just a step closer to have this project finished ill take any step over a dead end. 

To have the changes stick the "OK" button in that iframe needs to be clicked. But I thought my code clicks on it? 

I'll spare you the duplication and just show you the ok button code.

;Click the ok button
Sleep(500)
Local $wOK = _IEGetObjById($oIE, "m74031266-pb")
_IEAction($wOK, "focus")
_IEAction($wOK, "click")
Sleep(3000)

having this after a text is sent to the iframe should save the contents but for some reason, it does not. 

I tried with your code with this. It sends "good morning" and I think "ok" is clicked because the window closes but I am not sure anymore. 

 

 

Also, this post is the current top result from google concerning anything about "sending text to a popup with autoit"  and or "autoit how to sent text to a frame in ie"

 

Edited by nooneclose

Share this post


Link to post
Share on other sites

@Danp2 I checked the website and when the code opens the long description iframe for some reason the buttons like reset, clear and ok or cancel do not work properly. I am going to try somethings but this is weird. 

Share this post


Link to post
Share on other sites

ok, I figured it out. assume that all the proper code is in place. 

;Click the long description button
Sleep(300)
_IEAction($wLongDButton, "focus")
_IEAction($wLongDButton, "click")
Sleep(1000)

;Clicks on the font name
Sleep(1000)
Local $wFN = _IEGetObjById($oIE, "dijit__editor_plugins__FontNameDropDown_4_select")
_IEAction($wFN, "focus")
_IEAction($wFN, "click")
Sleep(2000)

;Sends the long description
Sleep(500)
_IEAction($wComments, "focus")
_IEAction($wComments, "click")
Sleep(500)
$oFrame = _IEFrameGetCollection($oIE, 1)
;_IEBodyWriteHTML($oFrame, "Good Morning test 2")
Send("Today's time/date is not today got him!")

;Click the ok button
Sleep(2000)
Local $wOK = _IEGetObjById($oIE, "m74031266-pb")

the buttons work. It is the actual text that _IEBodyWriteHTML($oFrame, "Good Morning test 2") sends that Maximo doesn't recognize.  I tested the clicks with different functions and I tested the text that is sent. Only the "Send()" method works. (as in the long description saves it when "ok" is clicked)

For some reason, the long description does not recognize text that is sent by the "_IEBodyWriteHTML()" method.

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

  • Similar Content

    • By TXTechie
      Hello Everyone,
      I'm looking for a way to use an already open Internet Explorer (IE) window (if one is up and running) and then navigate to a new URL in a new IE tab.
      I thought that _IECreate would easily meet my needs. However, when I use the following script:
      #include <IE.au3> Local $oIE = _IECreate("https://" & $Server & ":8444/", 1, 1, 0, 1) ...with one or more open IE windows, it still opens yet a new IE window.
      Are there any other ideas for how to reliably use an already open IE windows and then how to open a new tab in IE to navigate to a new URL?
      Regards,
      TX Techie
    • By WoodGrain
      Hi All,
      I've tried to create a script to browse to a web page in IE, but it only works for some sites, I've tried to simplify the script as much as possible, hoping you can point me in the right direction - thanks.
      This one going to Google does work:
      #include <IE.au3> $oIE = _IECreate("https://www.google.com.au/", 0, 1, 1) _IELoadWait($oIE) _IEQuit($oIE) But this one going to OneDrive opens the IE page, but fails immediately returning the errors, and the IE window is not closed:
      --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023174, Browser has been deleted prior to operation.)
      --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_InvalidObjectType ()
      --> IE.au3 T3.0-2 Error from function _IEQuit, $_IESTATUS_InvalidObjectType
      #include <IE.au3> $oIE = _IECreate("https://abccorp-my.sharepoint.com/", 0, 1, 1) _IELoadWait($oIE) _IEQuit($oIE) Even if I put a sleep timer in for 10 seconds after the _IECreate it still doesn't work
      Thanks all!
    • By Dent
      https://rmplusportal.rightmove.co.uk/
      On that page is a login form requiring username, password and then the clicking of the button (or pressing enter but I'm not a fan of using Send)
      Here's the section of code from the page that specifically deals with the form...
      <form> <div class="error-message-login" data-test="error-message"></div> <label> <span>User email</span> <div class="ui input"> <input id="email" type="text" placeholder="Your email"> </div> </label> <label> <span>Password</span> <div class="ui input"> <input id="password" type="password" placeholder="Password"> </div> </label> <button class="ui primary button" role="button" data-test="login">Login</button> <p> <a class="forgot-your-password" href="https://www.rightmove.co.uk/forgottenPasswordForm.html">Forgot your password?</a> </p> </form> Specifically the <button class...></button> is causing me problems as I can't find a way to click it. The 'User email' and 'Password' objects have an 'id' so I can reference these in the AutoIT code and interact with them and the button also previously had the id of 'login' but I guess in a change to this page that was altered.
      Oddly, if I get the code to show the instance of IE that is created and manually click Login or press Enter the page gives me an error saying 'Please enter your email address' even though it is there. I have to manually go into each field and make a change i.e. adding a character to the end of each field then deleting it before it will let me in by either clicking Login or pressing enter. So maybe there's so code elsewhere on the page that knows the fields haven't been physically typed in?
      Any help on this would be much appreciated.
    • By JackER4565
      Hi, first of all thanks to all the guys who always help people in the forums, I wouldn't be able to do anything if wasn't for your help, even if I don't ask it myself.
       
      I've created this code to get some info on a monitoring network on my work. It relays on _IETableGetCollection and _IETableWriteToArray.
      It works well, but take around 3:25 minutes to get the info from 28 pages (some of them are large and take longer to load, but most of them are small and fast).
      My question is if you see a way to get the program to go faster...
       
      I've tried to make it easy for you to understand and edited somethings with sensitive info.
      (Some of the pages doesn't have the black divider with MIRA in the end, so I need to search if it is there or not.)
       
      #include <IE.au3> #include <array.au3> Local $oIE = _IECreate("about:blank", 0, 0) Local $paginas[28] = [89, 90, 91, 92, 93, 96, 105, 113, 119, 125, 126, 129, 131, 133, 135, 137, 139, 140, 141, 144, 145, 146, 148, 149, 150, 151, 158, 159] Local $Datos_array[0][2] Local $oTable Local $tabla Local $aux_x = 1 Local $ar = 1 Local $Numtables_datos = 0 MsgBox(0, "asd", "asd") For $pag = 0 To UBound($paginas) - 1 Step 1 _IENavigate($oIE, "<WEBSITE URL>" & $paginas[$pag]) ; <<< the pages to load are always the same except for the last digits. _ArrayAdd($Datos_array, $paginas[$pag] & "|" & "Entrante", 0, "|") ; <<<<<<<<<<<<<<<< adds the page number toarray [0, 0] ;############################################ START counts amount of tables with traffic $oTable = _IETableGetCollection($oIE) Local $iNumTables = @extended For $i = 3 To $iNumTables - 2 Step 1 $oTable = _IETableGetCollection($oIE, $i) $nomb_tabla2 = _IETableWriteToArray($oTable) ; <<<<<<<< TABLE TO ARRAY. $string2 = StringStripWS($nomb_tabla2[1][0], 8) If $string2 <> "MIRA" Then $Numtables_datos = $Numtables_datos + 1 Next $tabla_End = $iNumTables - $Numtables_datos ;############################################ FIN $tabla_Start = 4 $tabla_trafico = 2 For $for = 1 To $Numtables_datos Step 1 $oTable = _IETableGetCollection($oIE, $tabla_Start - 1) ; <<<<<<<<<<< NAME OF THE TABLE; row2 = mira $nomb_tabla = _IETableWriteToArray($oTable) ; <<<<<<<< TABLE TO ARRAY ;########################################### ADDS the traffic number into the row $string = StringStripWS($nomb_tabla[1][0], 8) If $string == "MIRA" Then ;si o si pasa por aca 1 vez _ArrayAdd($Datos_array, $nomb_tabla[0][0]) $nomb_aux = $nomb_tabla[0][0] $aux_x = 1 $tabla_trafico = $tabla_trafico + 2 Else ;esto deberia ser por row _ArrayAdd($Datos_array, $nomb_aux & " " & $aux_x) $aux_x = $aux_x + 1 $tabla_trafico = $tabla_trafico + 1 EndIf $oTable = _IETableGetCollection($oIE, $tabla_trafico) Local $aTableData = _IETableWriteToArray($oTable) $bps = _ArrayToString($aTableData, "|", 0, 0, @CRLF, 0, 0) $bps = StringRight($bps, 5) $bps = StringLeft($bps, 4) $trafico_actual = _ArrayToString($aTableData, "|", 0, 0, @CRLF, 2, 2) If $bps == "Gbps" Then $trafico_actual = $trafico_actual * 1000 If $bps == "Kbps" Then $trafico_actual = $trafico_actual / 1000 $Datos_array[$ar][1] = $trafico_actual $ar = $ar + 1 If $string == "MIRA" Then $tabla_Start = $tabla_Start + 2 Else $tabla_Start = $tabla_Start + 1 EndIf Next $ar = $ar + 1 ;~ ############# CAÍDA ############ ;~ If $actual_entrante = 0 Then ;~ $xxx = 0 ;~ Do ;~ MsgBox(0, "Tráfico Caído", $paginas[$i], 5) ;~ $xxx = $xxx + 1 ;~ Until $xxx = 10 ;~ EndIf ;~ ############# CAÍDA ############. Local $Numtables_datos = 0 Next _ArrayDisplay($Datos_array, "Array display") _IEQuit($oIE) Thanks!! 


      monitoria.html
    • By Dent
      Here is the URL to get to the page with the code as shown in the screenshot https://www.rightmove.co.uk/house-prices/detail.html?country=england&locationIdentifier=POSTCODE^1603593&searchLocation=SW1V+1AA&year=1&referrer=listChangeCriteria
      But how do I select the highlighted text, the address?
      I've tried variations of the below code but to no avail so far
      Local $oClassReturn = $oIE.document.getElementsByClassName("soldList") If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF) Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("div") If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF) MsgBox(0, "TEST", $oTagReturn.Item(0))  

×
×
  • Create New...