Glenn6788

_IEFormSetElementValue help

16 posts in this topic

#1 ·  Posted

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.

 

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

Share this post


Link to post
Share on other sites



#3 ·  Posted

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?

Share this post


Link to post
Share on other sites

#4 ·  Posted

Do you have the Excel file that you're using so I can test?

Share this post


Link to post
Share on other sites

#5 ·  Posted

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

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

Which is strange because using your .htm file it fills out fine for me, using any of the code I posted above.

1 person likes this

Share this post


Link to post
Share on other sites

#8 ·  Posted

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 :(

Share this post


Link to post
Share on other sites

#9 ·  Posted

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.

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

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

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

it works in scite but claps out when I run the script.

Share this post


Link to post
Share on other sites

#12 ·  Posted

Can you change ConsoleWrite to MsgBox and check that it's returning form names?

Share this post


Link to post
Share on other sites

#13 ·  Posted

Attached is the error I get

Untitled.jpg

Share this post


Link to post
Share on other sites

#14 ·  Posted

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

Share this post


Link to post
Share on other sites

#15 ·  Posted

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.

 

 

Share this post


Link to post
Share on other sites

#16 ·  Posted

I'm on Windows 10 Enterprise x64 with IE 11 and don't appear to have any issues.

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