Jump to content

[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
Link to post
Share on other sites
  • Moderators

@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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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)

 

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
Link to post
Share on other sites
  • Moderators
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. 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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.

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
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.  

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. 

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
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
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
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.

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.

  • Similar Content

    • By MrKm
      This tiny yet powerful UDF will help you to convert Images to text with the help of  OCRSpace API version 3.50 .
      Detect text from a local file.
      ; ========================================================= ; Example 2 : Gets text from an image from a local path reference ; : Searchable PDF is not requested by default. ; : Processes it using a basic OCR logic. ; ========================================================= $b_Create_Searchable_PDF = True ; Use a table logic for receipt OCR $b_Table = True ; Set your key here. $v_OCRSpaceAPIKey = "" $OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, $b_Table, True, "eng", True, Default, Default, $b_Create_Searchable_PDF) $sText_Detected = _OCRSpace_ImageGetText($OCROptions, @scriptdir & "\receipt.jpg", 0, "SEARCHABLE_URL") ConsoleWrite( _ " Detected text : " & $sText_Detected & @CRLF & _ " Error Returned : " & @error & @CRLF & _ " PDF URL : " & Eval("SEARCHABLE_URL") & @CRLF)  
      Detect text from a URL reference.
      ; ========================================================= ; Example 1 : Gets text from an image using a url reference ; : Searchable PDF is not requested. ; : Processes it using a basic OCR logic. ; ========================================================= $v_OCRSpaceAPIKey = "" ; SetUp some preferences.. $OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, False, True, "eng", True, Default, Default, False) ; Make the request.. $sText_Detected = _OCRSpace_ImageGetText($OCROptions, "https://i.imgur.com/vbYXwJm.png", 0) ConsoleWrite( _ " Detected text : " & $sText_Detected & @CRLF & _ " Error Returned : " & @error & @CRLF)    
      Detect text from a URL reference to an array
      #include "OCRSpaceUDF\_OCRSpace_UDF.au3" #include <array.au3> ; Set your key here. $v_OCRSpaceAPIKey = "" $OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, $b_Table, True, "eng", True, Default, Default, False) ; Below, the return type is set to 1 to return an array containing the coordinates of the bounding boxes for each word detected, ; in the format : #WordDetected , #Left , #Top , 3Height, #Width $aText_Detected = _OCRSpace_ImageGetText($OCROptions, "https://i.imgur.com/Z1enogD.jpeg", 1) _ArrayDisplay($aText_Detected, "")  
       
      OCRSpaceUDF v1.2.zip
      OCRSpaceUDFv1.0.zip
       
      https://github.com/KabueMurage/AutoIT-OCRSpace-UDF
      Download Latest Version : OCRSpaceUDF v1.2.zip
       
    • By DJ143
      I have a autoit exe file which is used in upload/browse file functionality.  This has been integrated with selenium framework and I am invoking the autoit exe using Java process and runtime. 
      Now the issue is when I run the scripts and invoke the autoit exe in local it works perfectly.  But when I use selenium grid or jenkins to run the scripts in another windows server it is not working.
      Can anyone please suggest any solution for this?
    • By Hermes
      Hello, the script below will read column A from an excel file - and if a value matches in the browser, it will click the corresponding link and click on a specific button to paste the data, then writes "Completed" in Column B. It will continue to read from the excel file and do the same thing for all the remaining rows.
      #Include "Chrome.au3" #Include "wd_core.au3" #Include "wd_helper.au3" #Include "WinHttp.au3" #include <MsgBoxConstants.au3> #include <File.au3> #include <IE.au3> #include <Array.au3> #include <INet.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <GDIPlus.au3> #include <Excel.au3> #Include "WinHttp.au3" #Include "_HtmlTable2Array.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "table1.html") _WD_LoadWait($sSession) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='main']") Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='main']") ;ConsoleWrite ("mat-table " & $sElement & @CRLF) Local $aArray1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[contains(@class,'data')]", $sElement, True) sleep(1000) For $i = 0 to UBound($aArray1) - 1 $aArray1[$i] = _WD_ElementAction($sSession, $aArray1[$i], 'text') Next ;_ArrayDisplay($aArray1) ;Email variables $SmtpServer = "" ; address for the smtp-server to use - REQUIRED $FromName = "Hermes" ; name from who the email was sent $FromAddress = "sender@gmail.com" ; address from where the mail should come $ToAddress = "recipient@gmail.com" ; destination address of the email - REQUIRED, use commas (,) to add more email addresses $Subject = "File not found" ; subject from the email - can be anything you want it to be $Body = "File not found!" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "High" ; Send message priority: "High", "Normal", "Low" $Username = "" ; username for the account used from where the mail gets sent - REQUIRED $Password = "" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $tls = 0 ; enables/disables TLS when required Local $oAppl = _Excel_Open() Local $sWorkbook = "c:\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ;open excel and pass both parameters If FileExists($sWorkbook) Then ;Check if the file exist. Local $oAppl = _Excel_Open() Local $sWorkbook = "c:\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ;open excel and pass both parameters Local $aArray2 = _Excel_RangeRead($oWorkbook,Default,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A")) Local $iIdx Local $Skipline = 0 ;0==> first line Do Local $temprf For $i = 0 To UBound($aArray2) - 1 $temprf &= $aArray2[$i] _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[contains(@class,'edit') and contains(text(),'Edit')]") Local $aElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[contains(@class,'edit') and contains(text(),'Edit')]", $sElement, True) $iIdx = _ArraySearch($aArray1, $aArray2[$i]) If @error Then ContinueLoop _WD_ElementAction($sSession, $aElement[$iIdx], 'click') If $i < $Skipline Then ContinueLoop $oRange = $oWorkbook.ActiveSheet.Range("B" & $i + 1 & ":XFD" & $i + 1) _Excel_RangeCopyPaste($oWorkbook.Activesheet, $oRange) ;Paste Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "pastebutton") _WD_ElementAction($sSession, $oTest4, 'click') Sleep(1000) ;Save Button Local $save3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "button.button") _WD_ElementAction($sSession, $save3, 'click') _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Completed", "B" & $i+1) sleep(1000) Next Until (Not @error) _Excel_Close($oWorkbook) Else _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) Exit EndIf _WD_LoadWait($sSession) ;Attaching files to emails Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0, $tls = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf ; Set security params If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True If $tls Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = True ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send $objEmail="" EndFunc ;==>_INetSmtpMailCom Local $aDir = _FileListToArrayRec(@TempDir, "scoped_dir*;chrome_*", $FLTAR_FOLDERS, $FLTAR_NORECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Sleep(2000) For $i = 1 To $aDir[0] DirRemove($aDir[$i], $DIR_REMOVE) Next _WD_LoadWait($sSession) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome If the excel file doesn't exists in the folder, it will send an email to a specific recipient.
      What i am trying figure out now is if the excel crashes while the script/loop is running, I want to relaunch the excel file continue to the last row before the excel crashed. So if the value of column B is not marked as "completed", it should continue from that row
      Appreciate any help that I can get to achieve this.
      table1.html test.xlsx
    • By adityaparakh
      Hello ,
      I am trying to use Websockets in AutoIt.
      It is to fetch live stock market prices , API is provided and documentation available for python language.
      The link for the code snippet is :
      https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Introduction
      https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Instruments/paths/~1instruments~1subscription/post
       
      https://github.com/symphonyfintech/xts-pythonclient-api-sdk
       
      Second Link is to subscribe to a list of ExchangeInstruments.
      Now I would like to get live stock ltp (LastTradedPrice) for a few stocks whose "ExchangeInstrumentID" I know.
      I am able to use the WinHttp object to perform actions using simple codes like below :
      I have the secretKey and appkey and can generate the needed token. And get the unique ExchangeInstrumentID.

      Below code is just for example of how I am using WinHttp. Unrelated to socket part.
      Global $InteractiveAPItoken = IniRead(@ScriptDir & "\Config.ini", "token", "InteractiveAPItoken", "NA") $baseurl = "https://brokerlink.com/interactive/" $functionurl = "orders" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $baseurl & $functionurl, False) $oHTTP.SetRequestHeader("Content-Type", "application/json;charset=UTF-8") $oHTTP.SetRequestHeader("authorization", $InteractiveAPItoken) $pD = '{ "exchangeSegment": "NSEFO", "exchangeInstrumentID": ' & $exchangeInstrumentID & ', "productType": "' & $producttype & '", "orderType": "MARKET", "orderSide": "' & $orderside & '", "timeInForce": "DAY", "disclosedQuantity": 0, "orderQuantity": ' & $qty & ', "limitPrice": 0, "stopPrice": 0, "orderUniqueIdentifier": "' & $orderidentifier & '"}' $oHTTP.Send($pD) $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status
          
          
      But am struggling to understand and use socket.
      Would be of great help if you can have a look at the link mentioned above and help with the code sample for AutoIt.
      To connect and listen to a socket.
      Thanks a lot
       
    • By Hermes
      Hi, I have a site that has the following elements below: 
      <div>More element here</div> <div>More element here</div> <div>More element here</div> When I do this in Auto It:
      Local $oSelectDiv = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "div") _WD_HighlightElement($sSession, $oSelectDiv, 1) I also tried to add [3], but it doesnt seems to work:
      Local $oSelectDiv = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "div[3]") _WD_HighlightElement($sSession, $oSelectDiv, 1) It always highlight the first one, but I am trying to highlight the 3rd in the list. Is there anyway to select the 3rd div without having to add any class/id in the divs, and without using XPATH? The structure of the elements in that site were built that way.
×
×
  • Create New...