Jump to content
Sign in to follow this  
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.


"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!

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. 


"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!

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By mLipok
      In the past there was many questions about how to: "Automatic file upload using without user interaction"

      https://www.autoitscript.com/forum/topic/92907-ie-8-input-namenomfic-typefile-idnomfic/
      https://www.autoitscript.com/forum/topic/116899-cant-automate-input-typefile-tag-in-ie/?tab=comments#comment-815478
      https://www.autoitscript.com/forum/topic/14883-input-typefile/
      https://www.autoitscript.com/forum/topic/188708-how-to-set-the-value-of-an-input-typefile-element/
      https://www.autoitscript.com/forum/topic/91513-how-can-i-auto-set-file-path-for-input-file-in-ie/
      https://www.autoitscript.com/forum/topic/116899-cant-automate-input-typefile-tag-in-ie/
      https://www.autoitscript.com/forum/topic/169190-how-to-script-file-upload-button/
      https://www.autoitscript.com/forum/topic/145327-how-to-deal-with-ie-window-for-upload-a-fileinput-typefile/
      https://www.autoitscript.com/forum/topic/140482-internet-explorer-input-file-problem/
       
      I found solution here: 
      https://stackoverflow.com/questions/33253517/upload-a-file-via-input-input-in-html-form-with-vba
      and:
      https://www.motobit.com/tips/detpg_uploadvbsie/
      And I translate this code to AutoIt3 code:
      ; Upload file using http protocol And multipart/form-data ; v1.01 ; 2001 Antonin Foller, PSTRUH Software Global $oErrorHandler = ObjEvent("AutoIt.Error", _ErrFunc) do_vbsUpload() Func do_vbsUpload() #cs ; We need at least two arguments (File & URL) ConsoleWrite('- ' & @ScriptLineNumber & @CRLF) If $CmdLine[0] < 2 Then InfoEcho() ConsoleWrite('- ' & @ScriptLineNumber & @CRLF) ; Are some required objects missing? If StringInStr(CheckRequirements(), "Error") > 0 Then InfoEcho() ConsoleWrite('- ' & @ScriptLineNumber & @CRLF) Local $s_FileName, $s_DestURL, $s_FieldName $s_FieldName = "FileField" ; Default field name For $i_argCounter = 1 To $CmdLine[0] ConsoleWrite('+ '& $i_argCounter& ' >> ' & $CmdLine[$i_argCounter] & @CRLF) Select Case $i_argCounter = 1 ;~ $s_FileName = $CmdLine[$i_argCounter] $s_FileName = @ScriptFullPath Case $i_argCounter = 2 $s_DestURL = $CmdLine[$i_argCounter] Case $i_argCounter = 3 $s_FieldName = $CmdLine[$i_argCounter] EndSelect Next UploadFile($s_DestURL, $s_FileName, $s_FieldName) #ce UploadFile('http://www.dobeash.com/test.html', @ScriptFullPath, 'fileExample') EndFunc ;==>do_vbsUpload ; ******************* upload - begin ; Upload file using input type=file Func UploadFile($s_DestURL, $s_FileName, $s_FieldName) ; Boundary of fields. ; Be sure this string is Not In the source file Const $Boundary = "---------------------------0123456789012" ; Get source file As a binary data. Local $d_FileContents = GetFile($s_FileName) ; Build multipart/form-data document Local $s_FormData = BuildFormData($d_FileContents, $Boundary, $s_FileName, $s_FieldName) ; Post the data To the destination URL IEPostBinaryRequest($s_DestURL, $s_FormData, $Boundary) EndFunc ;==>UploadFile ; Build multipart/form-data document with file contents And header info Func BuildFormData($d_FileContents, $Boundary, $s_FileName, $s_FieldName) Const $s_ContentType = "application/upload" ; The two parts around file contents In the multipart-form data. Local $s_Pre = "--" & $Boundary & @CRLF & mpFields($s_FieldName, $s_FileName, $s_ContentType) Local $s_Po = @CRLF & "--" & $Boundary & "--" & @CRLF ; Build form data using recordset binary field Const $i_adLongVarBinary = 205 Local $oRS = ObjCreate("ADODB.Recordset") ; https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/append-method-ado?view=sql-server-ver15 $oRS.Fields.Append("b", $i_adLongVarBinary, StringLen($s_Pre) + BinaryLen($d_FileContents) + StringLen($s_Po)) $oRS.Open() $oRS.AddNew() ; Convert Pre string value To a binary data Local $i_LenData = StringLen($s_Pre) $oRS("b").AppendChunk(StringToMB($s_Pre) & StringToBinary(Chr(0))) $s_Pre = $oRS("b").GetChunk($i_LenData) $oRS("b") = "" ; Convert Po string value To a binary data $i_LenData = StringLen($s_Po) $oRS("b").AppendChunk(StringToMB($s_Po) & StringToBinary(Chr(0))) $s_Po = $oRS("b").GetChunk($i_LenData) $oRS("b") = "" ; Join Pre & $d_FileContents & Po binary data $oRS("b").AppendChunk($s_Pre) $oRS("b").AppendChunk($d_FileContents) $oRS("b").AppendChunk($s_Po) $oRS.Update() Local $s_FormData = $oRS("b") $oRS.Close() Return $s_FormData EndFunc ;==>BuildFormData ; sends multipart/form-data To the URL using IE Func IEPostBinaryRequest($s_URL, $s_FormData, $Boundary) ; Create InternetExplorer Local $oIE = ObjCreate("InternetExplorer.Application") ; You can uncoment Next line To see form results $oIE.Visible = True ; Send the form data To $s_URL As POST multipart/form-data request $oIE.Navigate($s_URL, '', '', $s_FormData, _ "Content-Type: multipart/form-data; boundary=" & $Boundary & @CRLF) While $oIE.Busy Wait(1, "Upload To " & $s_URL) WEnd ; Get a result of the script which has received upload ;~ On Error Resume Next Local $s_IE_InnerHTML = $oIE.Document.body.innerHTML MsgBox(0, 'TEST #' & @CRLF & @ScriptLineNumber, $s_IE_InnerHTML) $oIE.Quit() Return $s_IE_InnerHTML EndFunc ;==>IEPostBinaryRequest ; Infrormations In form field header. Func mpFields($s_FieldName, $s_FileName, $s_ContentType) Local $s_MPTemplate = _ ; template For multipart header 'Content-Disposition: form-data; name="{field}";' & _ 'FileName="{file}"' & @CRLF & _ 'Content-Type: {ct}' & @CRLF & @CRLF & _ '' Local $s_Out $s_Out = StringReplace($s_MPTemplate, "{field}", $s_FieldName) $s_Out = StringReplace($s_Out, "{file}", $s_FileName) $s_Out = StringReplace($s_Out, "{ct}", $s_ContentType) Return $s_Out EndFunc ;==>mpFields Func Wait($i_Seconds, $s_Message) MsgBox(64, '', $s_Message, $i_Seconds) EndFunc ;==>Wait ; Returns file contents As a binary data Func GetFile($s_FileName) Local $oStream = ObjCreate("ADODB.Stream") $oStream.Type = 1 ; Binary $oStream.Open() $oStream.LoadFromFile($s_FileName) Local $d_GetFile = $oStream.Read() $oStream.Close() Return $d_GetFile EndFunc ;==>GetFile ; Converts OLE string To multibyte string Func StringToMB($S) Local $I, $B For $I = 1 To StringLen($S) $B &= StringToBinary(Asc(StringMid($S, $I, 1))) Next Return $B EndFunc ;==>StringToMB ; ******************* upload - end ; ******************* Support ; Basic script info Func InfoEcho() Local $sMsg = _ "Upload file using http And multipart/form-data" & @CRLF & _ "Copyright (C) 2001 Antonin Foller, PSTRUH Software" & @CRLF & _ "use" & @CRLF & _ "[cscript|wscript] fupload.vbs file $s_URL [fieldname]" & @CRLF & _ " file ... Local file To upload" & @CRLF & _ " $s_URL ... $s_URL which can accept uploaded data" & @CRLF & _ " fieldname ... Name of the source form field." & @CRLF & _ @CRLF & CheckRequirements() & @CRLF & _ "" ConsoleWrite('! ' & $sMsg & @CRLF) EndFunc ;==>InfoEcho ; Checks If all of required objects are installed Func CheckRequirements() Local $sMsg = _ "This script requires some objects installed To run properly." & @CRLF & _ CheckOneObject("ADODB.Recordset") & @CRLF & _ CheckOneObject("ADODB.Stream") & @CRLF & _ CheckOneObject("InternetExplorer.Application") & @CRLF & _ "" Return $sMsg ; $sMsgBox $sMsg EndFunc ;==>CheckRequirements ; Checks If the one object is installed. Func CheckOneObject($sClassName) Local $sMsg ObjCreate($sClassName) If @error = 0 Then $sMsg = "OK" Else $sMsg = "Error:" & @error EndIf Return $sClassName & " - " & $sMsg EndFunc ;==>CheckOneObject ; ******************* Support - end ; User's COM error function. Will be called if COM error occurs Func _ErrFunc(ByRef $oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc  
      But I miss something and the code not works as intendend.
      Please join and contribute, in solving this issue, as this will be handy for entire community.
      @mLipok
       
      btw.
      I think that this may be realated to ChrB() which I simply translate to StringToBinary()
      Especialy this :
      StringToBinary(Chr(0))) could be the main issue.
      But for now I'm tired and going to sleep.
      Hope maybe tomorrow somebody solve this issue.
       
    • By MiKa666
      Hi all,
      I'm developing a tool for exploratively testing another software. For that I wanna cover all the GUI functionality from that software and verify everything works as intended. But now I've a problem which I couldnt solve so far.
      One thing that software I'm testing does, is to load up either a single picture or a series of pictures. Depending on how much pictures got loaded, further actions will be proceeded...
      This loaded pictures are schon within a ToolbarWindow and they're clickable. What I need to know is, how much pictures are in this ToolbarWindow...
      Can anybody provide me a tip on how to achive this?
      Would be amazing!!
      BR,
      Mic
    • By meety
      Hello!
      wingettext function can get the text content of the IE browser page, but the text content of the page cannot be obtained in the chrome browser? What should I do?
    • By DirtyJohny
      Hi everyone.Need rewrite this function how in еxample.
      Original:
      #RequireAdmin #NoTrayIcon Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next MsgBox(262144,'Monitors '&$lss.Count,$sss&" "&@CR) $lss=Null $sls=Null EndFunc _a() Example:
      Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) If IsObj($ObjService) Then For $objItemMB In $ObjMB $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)
    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
×
×
  • Create New...