Glenn6788 Posted March 29, 2017 Share Posted March 29, 2017 hello. I recently cooked the hard drive on my laptop and am having some trouble re-creating my old scripts. I am having trouble setting the text in a form element from whatever is copied on the clipboard. The form doesn't have a name so I was using _IEFormGetCollection from memory, I am trying to set the value for "LocOrLP" to what I have copied from the clipboard. Below is my html and autoit code. expandcollapse popup<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1"><title> WAX RF <meta http-equiv="IB_Scanner" content="Enabled" /><meta http-equiv="IB_ScannerNavigate" content="Javascript: SubmitFormBarcode();" /><meta http-equiv="IB_OnKey13" content="Javascript: SubmitForm('ENTERPRESSED')" /><meta http-equiv="IB_OnKey9" content="Javascript: HandleTab()" /><meta http-equiv="IB_OnKey112" content="Javascript:IBKeyHandler('Override')" /><meta http-equiv="IB_OnKey114" content="Javascript:IBKeyHandler('Back')" /><meta http-equiv="IB_OnKey115" content="Javascript:IBKeyHandler('Cancel')" /><meta http-equiv="IB_OnKey113" content="Javascript:IBKeyHandler('OK')" /><meta http-equiv="IB_OnKey116" content="Javascript:IBKeyHandler('Done')" /><meta http-equiv="IB_OnKey119" content="Javascript:IBKeyHandler('ShortPick')" /><meta http-equiv="IB_OnKey120" content="Javascript:IBKeyHandler('Full')" /><meta http-equiv="IB_OnKey123" content="Javascript:IBKeyHandler('Skip')" /></head> <body onload="init();"> <div class="waxMainRFWrap"> <form action="/Execute/Display" class="waxMainRFForm" method="post" onsubmit="return SubmitForm('ENTERPRESSED')"><input id="ClickedButton" name="ClickedButton" type="hidden" value="" /> <input id="IsMenu" name="IsMenu" type="hidden" value="False" /> <table class="waxMainRFTable"> <tr class="waxMainRFTableRow"> <td colspan="2" class="waxMainRFTableCell"> <label class="waxLabel" id="MovementLbl" style="color:Black;">Move Unit or LP-</label> </td> </tr> <tr class="waxMainRFTableRow"> <td colspan="2" class="waxMainRFTableCell"> <label class="waxLabel" id="FromLbl" style="color:Black;">From Information</label> </td> </tr> <tr class="waxMainRFTableRow"> <td class="waxMainRFTableCell"> <label class="waxTextLabel" for="LocOrLP">Loc / LP / Con</label> </td> <td class="waxMainRFTableCell"> <input class="waxText" type="text" name="LocOrLP" id="LocOrLP" value="" maxlength="25" /> </td> </tr> expandcollapse popup#include <IE.au3> #Region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409) --- #Region --- Internal functions Au3Recorder Start --- Func _Au3RecordSetup() Opt('WinWaitDelay', 100) Opt('WinDetectHiddenText', 1) Opt('MouseCoordMode', 0) Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '') If $aResult[1] <> '00000409' Then MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')') EndIf EndFunc ;==>_Au3RecordSetup Func _WinWaitActivate($title, $text, $timeout = 0) WinWait($title, $text, $timeout) If Not WinActive($title, $text) Then WinActivate($title, $text) WinWaitActive($title, $text, $timeout) EndFunc ;==>_WinWaitActivate _Au3RecordSetup() #EndRegion --- Internal functions Au3Recorder Start --- HotKeySet("{ESC}", "Terminate") $i = 0 $repeats = InputBox("Repeats", "How many Loops would you like Glenn?", "") $oIE = _IECreate("http://au1kathmap51p.kathmandu.com:8080/Execute/Display") _IELoadWait($oIE) Sleep(200) Send("02515") Sleep(100) Send("{ENTER}") Sleep(200) _IELoadWait($oIE) Send("02515") Sleep(100) Send("{ENTER}") Sleep(200) _IELoadWait($oIE) Sleep(1000) Send("2") _IELoadWait($oIE) Sleep(1000) Send("6") _IELoadWait($oIE) Sleep(1000) Send("5") Sleep(1000) _IELoadWait($oIE) While ($i < $repeats) _WinWaitActivate("Locations - Excel", "") Send("{CTRLDOWN}c{CTRLUP}") Send("{DOWN}") $sData = ClipGet() _WinWaitActivate("WAX RF - Internet Explorer", "") $oQuery = _IEFormElementGetCollection($oIE) $oSubmit = _IEFormElementGetObjByName($oQuery, "LocOrLP") _IEFormElementSetValue($oSubmit, $sData) ; Getting the error here $i = ($i + 1) WEnd Func Terminate() Exit 0 EndFunc ;==>Terminate _WinWaitActivate("WAX RF - Internet Explorer", "") WAX RF.htm Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2017 Share Posted March 30, 2017 Try, something like this, why don't you use the Excel UDF to get the Excel information into an Array? $oForm = _IEFormGetCollection($oIE, 0) $oItem = _IEFormElementGetObjByName($oForm, "LocOrLP") _IEFormElementSetValue($oItem, $sData) Link to comment Share on other sites More sharing options...
Glenn6788 Posted March 30, 2017 Author Share Posted March 30, 2017 Thanks for the reply Subz. I tried putting the index for _IEFormGetCollection to 0. It gets rid of the error but still doesn't set the value in the form. I put in a msgbox to check that it is converting the clipboard to a variable. Not sure why it's still not working? Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2017 Share Posted March 30, 2017 Do you have the Excel file that you're using so I can test? Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2017 Share Posted March 30, 2017 If you don't want to use Excel UDF you could use the following: While ($i < $repeats) _WinWaitActivate("Locations - Excel", "") Sleep(100) ClipPut("") Do Sleep(100) Send("^c") $sData = ClipGet() Until $sData Send("{DOWN}") _WinWaitActivate("WAX RF - Internet Explorer", "") $oForm = _IEFormGetCollection($oIE, 0) $oSubmit = _IEFormElementGetObjByName($oForm, "LocOrLP") _IEFormElementSetValue($oSubmit, $sData) $i += 1 WEnd Link to comment Share on other sites More sharing options...
Glenn6788 Posted March 30, 2017 Author Share Posted March 30, 2017 The problem is not with the excel or the clipboard variable. Even using the below code separate from the excel altogether I still get nothing $oForm = _IEFormGetCollection($oIE, 0) $oSubmit = _IEFormElementGetObjByName($oForm, "LocOrLP") _IEFormElementSetValue($oSubmit, "TEST") Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2017 Share Posted March 30, 2017 Which is strange because using your .htm file it fills out fine for me, using any of the code I posted above. Glenn6788 1 Link to comment Share on other sites More sharing options...
Glenn6788 Posted March 30, 2017 Author Share Posted March 30, 2017 Definitely. I just changed from windows 7 to 8.1 enterprise. Wondering if its something to do with that? It is making me crazy this thing Link to comment Share on other sites More sharing options...
Glenn6788 Posted March 30, 2017 Author Share Posted March 30, 2017 do I need to make a new variable like $oIE I am still on the same url but have navigated through different menus since _IECreate From memory I didn't have to do this last time. Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2017 Share Posted March 30, 2017 What does the following return when running in Scite: While ($i < $repeats) _WinWaitActivate("Locations - Excel", "") Sleep(100) ClipPut("") Do Sleep(100) Send("^c") $sData = ClipGet() Until $sData Send("{DOWN}") _WinWaitActivate("WAX RF - Internet Explorer", "") $oForm = _IEFormGetCollection($oIE, 0) For $oName in $oForm ConsoleWrite($oName.Name & @CRLF) Next $oSubmit = _IEFormElementGetObjByName($oForm, "LocOrLP") _IEFormElementSetValue($oSubmit, $sData) $i += 1 WEnd Link to comment Share on other sites More sharing options...
Glenn6788 Posted March 31, 2017 Author Share Posted March 31, 2017 it works in scite but claps out when I run the script. Link to comment Share on other sites More sharing options...
Subz Posted March 31, 2017 Share Posted March 31, 2017 Can you change ConsoleWrite to MsgBox and check that it's returning form names? Link to comment Share on other sites More sharing options...
Glenn6788 Posted March 31, 2017 Author Share Posted March 31, 2017 Attached is the error I get Link to comment Share on other sites More sharing options...
Subz Posted March 31, 2017 Share Posted March 31, 2017 So can try the following While ($i < $repeats) _WinWaitActivate("Locations - Excel", "") Sleep(100) ClipPut("") Do Sleep(100) Send("^c") $sData = ClipGet() Until $sData Send("{DOWN}") _WinWaitActivate("WAX RF - Internet Explorer", "") $oIE = _IEAttach("WAX RF - Internet Explorer") $oForm = _IEFormGetCollection($oIE, 0) For $oName in $oForm MsgBox(64, "Obj Name", $oName.Name) Next $oSubmit = _IEFormElementGetObjByName($oForm, "LocOrLP") _IEFormElementSetValue($oSubmit, $sData) $i += 1 WEnd Link to comment Share on other sites More sharing options...
Glenn6788 Posted March 31, 2017 Author Share Posted March 31, 2017 I think its something to do with IE.au3 compatibility with windows 8.1 and IE11 I don't seem to get errors when I add #RequireAdmin Kinda sucks though because I'm already a local admin. Link to comment Share on other sites More sharing options...
Subz Posted March 31, 2017 Share Posted March 31, 2017 I'm on Windows 10 Enterprise x64 with IE 11 and don't appear to have any issues. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now