Jump to content

set value for text field in IE !!!


Recommended Posts

hello everybody 

I have this code in my html 

<div class="tagsdiv" id="post_tag">
    <div class="jaxtag">
    <div class="nojs-tags hide-if-js">
        <label for="tax-input-post_tag">Add, Remove Tags</label>
        <p><textarea name="tax_input[post_tag]" rows="3" cols="20" class="the-tags" id="tax-input-post_tag"  aria-describedby="new-tag-post_tag-desc"></textarea></p>
    </div>
         <div class="ajaxtag hide-if-no-js">
        <label class="screen-reader-text" for="new-tag-post_tag">Add New Tag</label>
        <p><input data-wp-taxonomy="post_tag" type="text" id="new-tag-post_tag" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-post_tag-desc" value="" />
        <input type="button" class="button tagadd" value="Add" /></p>
    </div>
    <p class="howto" id="new-tag-post_tag-desc">Split tags with comma</p>
        </div>
    <ul class="tagchecklist" role="list"></ul>
</div>

I wanna set tag in its text area but I can't :(

here is my code 

#include <IE.au3>
#include <array.au3>
#Include <File.au3>
#include <MsgBoxConstants.au3>

Local $oIE =_IECreate($url)

Local $oTag = _IEGetObjById($oIE,"new-tag-post_tag")

_IEFormElementSetValue($oTag, "cars")

please help

 

Edited by AlienStar
Link to comment
Share on other sites

there is no output or errors !

when I run the code it opens the page to post and do nothing for tags textarea !

I set the topic title by this :

    Local $title = _IEGetObjById($oIE, "title")
    Local $ttlcntnt = FileReadLine($files[$i], 1)
    _IEFormElementSetValue($title, $ttlcntnt)

and it works well 

here is the part of html code which I depend on.

<div id="titlewrap">
        <label class="screen-reader-text" id="title-prompt-text" for="title">write title here</label>
    <input type="text" name="post_title" size="30" value="" id="title" spellcheck="true" autocomplete="off" />
</div>

but when I try to do for tags by the same way it failed 

Link to comment
Share on other sites

excuse me but really I don't know what output I have to send 

here is my full code 

#include <IE.au3>
#include <array.au3>
#Include <File.au3>
#include <MsgBoxConstants.au3>

local $files = _FileListToArrayRec(@ScriptDir, "*.txt", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT)

for $i = 1 to UBound($files)-1
    
    ;post topic content via url bellow 
    Local $content = FileRead($files[$i])
    ;------------------------------------------------
    Local $url = "https://engnajjar.wordpress.com/wp-admin/post-new.php?content="&_URIEncode($content)
    Local $oIE =_IECreate($url)
    ;------------------------------------------------
    _IELoadWait($oIE)
    ;------------------------------------------------
    Local $title = _IEGetObjById($oIE, "title")
    Local $ttlcntnt = FileReadLine($files[$i], 1)
    if StringLen($ttlcntnt)=0 Then
        $ttlcntnt = FileReadLine($files[$i], 2)
    EndIf
    _IEFormElementSetValue($title, $ttlcntnt)
    ;------------------------------------------------
    ; here choose the category checkbox
    Local $chkbx = _IEGetObjById($oIE, "in-popular-category-5")
    _IEAction($chkbx, "click")
    ;------------------------------------------------
    ;here I wanna set tags
    Local $oTag = _IEGetObjById($oIE,"new-tag-post_tag")
    _IEFormElementSetValue($oTag, "cars")
    ;------------------------------------------------
    ; here is publish button 
    Local $oSubmit = _IEGetObjById($oIE,"publish")
    _IEAction($oSubmit, "click")
    ;------------------------------------------------
    _IELoadWait($oIE)
    ;------------------------------------------------
    _IEQuit($oIE)
    ProcessClose("iexplore.exe")
next

all the code works but the tags not 

thats all I can send you :)

Link to comment
Share on other sites

@AlienStar Do you see an "Add" button next to the Tags input element? If so, have you tried clicking it in your script?

P.S. You can press the F8 key in Scite to toggle the display of the Output panel. I would expect to see something like the following when you run your script --

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\test5.au3" /UserParams    
+>16:19:15 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Dan\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Dan\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\test5.au3
+>16:19:15 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\test5.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (in-popular-category-5)
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType
+>16:19:26 AutoIt3.exe ended.rc:0
+>16:19:26 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 11.09

 

Link to comment
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\wamp\www\Egypt\category\Upload\tmp\write wp post.au3" /UserParams    
+>00:48:39 Starting AutoIt3Wrapper v.15.729.1555.1 SciTE v.3.5.4.0   Keyboard:00000409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0409)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Mouhammad\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Mouhammad\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.12.0)  from:C:\Program Files (x86)\AutoIt3  input:C:\wamp\www\Egypt\category\Upload\tmp\write wp post.au3
+>00:48:39 AU3Check ended.rc:0
>Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\wamp\www\Egypt\category\Upload\tmp\write wp post.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
+>00:48:48 AutoIt3.exe ended.rc:0
+>00:48:48 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 9.346
 

Link to comment
Share on other sites

Well, AFAIK it won't work without clicking the button. You can either --

  • Use _IETagNameGetCollection to retrieve all Input elements and then traverse the collection of elements until you find the desired one (lots of examples of this on the forum)
  • Use IEbyXPATH to retrieve the desired element
  • Come up with another solution on your own. :thumbsup:
Link to comment
Share on other sites

10 minutes ago, Danp2 said:

Well, AFAIK it won't work without clicking the button. You can either --

  • Use _IETagNameGetCollection to retrieve all Input elements and then traverse the collection of elements until you find the desired one (lots of examples of this on the forum)
  • Use IEbyXPATH to retrieve the desired element
  • Come up with another solution on your own. :thumbsup:

thanks my friend I'll try :)

Link to comment
Share on other sites

I don't know  whats happens !
I re-test the first code I write and it succeed
and I don't know why it didn't work at first 

#include <IE.au3>
#include <array.au3>
#Include <File.au3>
#include <MsgBoxConstants.au3>

Local $oIE =_IECreate($url)

Local $oTag = _IEGetObjById($oIE,"new-tag-post_tag")

_IEFormElementSetValue($oTag, "cars")

thanks anyway for help Danp2

Edited by AlienStar
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...