Jump to content

_IEFormSetElementValue help


Recommended Posts

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

Link to comment
Share on other sites

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

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

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

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

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...