Jump to content

Database for AutoIT to store 5 sentences to be auto pasted every hour. How to do it.


 Share

Recommended Posts

Hi Guys,

I have done up a small script to auto post in my forum every hour once.

However, I need to know how to come up with a database where I can store 5 topics and 5 descriptions so that it can pull from it and post it every hour.

How do I set the loop to do that too?

#include <IE.au3>

$oIE = _IECreate ("http://bbs.bbsmo.com/post.php?action=newthread&fid=5&extra=page%3D1" ,1)

; Hide the browser window to demonstrate sending text to invisible window
;_IEAction($oIE, "invisible")

sleep (3000)

$oForm = _IEFormGetObjByName($oIE, "postform")
$oText = _IEFormElementGetObjByName ($oForm, "subject")
_IEFormElementSetValue ($oText, "Hey! This works!")

$oObj = _IEGetObjById($oIE,"bbcodemode")
_IEAction($oObj,"click")

$oOptions=_IEGetObjById($oIE,"typeid")
_IEFormElementOptionselect($oOptions,"本地",1,"byText")

$oForm1 = _IEFormGetObjByName($oIE, "postform")
$oText1 = _IEFormElementGetObjByName ($oForm1, "message")
_IEFormElementSetValue ($oText1, "Testing Description")
Edited by tradertt
Link to comment
Share on other sites

How can I use that to get it to paste per line per time?

Like this:

Global $avColors[5] = ["Aqua", "Blue", "Crimson", "Denim", "Eggplant"]
Global $avObjects[5] = ["Ziggurat", "Yak", "Ximian", "Walker", "Victrolla"]

For $a = 0 to UBound($avColors) - 1
    For $b = 0 To UBound($avObjects) - 1
        ConsoleWrite("There is a " & $avColors[$a] & " colored " & $avObjects[$b] & " in my yard!" & @LF)
    Next
Next

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Like this:

Global $avColors[5] = ["Aqua", "Blue", "Crimson", "Denim", "Eggplant"]
Global $avObjects[5] = ["Ziggurat", "Yak", "Ximian", "Walker", "Victrolla"]

For $a = 0 to UBound($avColors) - 1
    For $b = 0 To UBound($avObjects) - 1
        ConsoleWrite("There is a " & $avColors[$a] & " colored " & $avObjects[$b] & " in my yard!" & @LF)
    Next
Next

^_^

This is my actual code:

#include<IE.au3>
#include <File.au3>
$Links="C:\Users\User\Documents\links.txt"
$Subject="惊人的叫春声!!!"
$Post="惊人的叫春声!!! http://www.sdsd.com/0610b44d9b9fed0ff954.video?%E6%83%8A%E4%BA%BA%E7%9A%84%E5%8F%AB%E6%98%A5%E5%A3%B0%EF%BC%81%EF%BC%81%EF%BC%81"
_IELoadWaitTimeout(15000)
_IEErrorHandlerRegister()
For $i=1 to _FileCountLines($Links)
    $oIE=_IECreate (FileReadLine($Links,$i),1)
;$oIE = _IECreate ("http://discuz.ezup.biz/post.php?action=newthread&fid=15&extra=page%3D1" , 1)

$oForm = _IEFormGetObjByName($oIE, "postform")
$oText = _IEFormElementGetObjByName ($oForm, "subject")
_IEFormElementSetValue ($oText, $Subject)

$oObj = _IEGetObjById($oIE,"bbcodemode")
_IEAction($oObj,"click")

$oOptions=_IEGetObjById($oIE,"typeid")
_IEFormElementOptionselect($oOptions,"日本",1,"byText")

$oForm1 = _IEFormGetObjByName($oIE, "postform")
$oText1 = _IEFormElementGetObjByName ($oForm1, "message")
_IEFormElementSetValue ($oText1, $Post)


 ; $oSubmit=_IEGetObjById($oIE,"postsubmit")
  ;_IEAction($oSubmit,"click")
    _IELoadWait($oIE,5000)
    _IEQuit($oIE)
Next

I am really sorry but I suck at arrays or even coding.

Could you give me an example of how i can intergrate it into my code:

$Subject="惊人的叫春声!!!"

$Post="惊人的叫春声!!! http://www.sdsd.com/0610b44d9b9fed0ff954.v...%EF%BC%81"

instead of calling this at the beginning of my code, I would like the $subject to be called from say Excel cell A1, $post to be called from Excel cell A2

and after the first loop, $subject to call from Excel cell B1 and $post to be called from Excel cell B2

Or can I use arrays for that

[autoit]Global $avColors[5] = ["topic1", "topic2", "topic3", "topic4", "topic5"]
Global $avObjects[5] = ["subject1", "subject2", "subject3", "subject4", "subject5"]

and it will loop through the code and past Topic 1 and Subject 1 into the forum

then on 2nd loop, paste Topic 2 and Subject 2 into the forum

and so on ....

THANK YOU :)

Link to comment
Share on other sites

That makes it even easier, because you only need one variable and one For/Next loop for accessing both arrays at the same time:

Global $avColors[5] = ["Aqua", "Blue", "Crimson", "Denim", "Eggplant"]
Global $avObjects[5] = ["Ziggurat", "Yak", "Ximian", "Walker", "Victrolla"]

For $a = 0 to UBound($avColors) - 1
    ConsoleWrite("There is a " & $avColors[$a] & " colored " & $avObjects[$a] & " in my yard!" & @LF)
Next

I don't understand your script, because I don't know what it is you are reading from links.txt, and there's no way I'm going to the web site to try and figure it out. Will the arrays replace static data you would have kept in the .txt file?

But I can help you understand arrays, which are a vital concept to learn for ANY scripting you might do. Just ignore the larger problem for a moment and understand the demo I gave you.

An one-dimensional array is just a numbered list. The only thing even slightly complicated about it is the list is numbered from 0. So in the code above, by declaring an array with 5 elements (i.e. Global $avColors[5]), you get a numbered list from 0 thru 4 (i.e. $avColors[0] = "Aqua", and $avColors[4] = "Eggplant").

I could have hard-coded my For/Next loop for $a = 0 To 4, but I didn't want to because it might change if you want a different number later, so I use Ubound() to get the number of elements from the array, which is 5. But there's a problem, because they are numbered from 0 there is no element 5, so I subtract 1 from the number returned by Ubound().

That's it. If you can follow that script you can use one-dimensional arrays in any scripting language out there.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 weeks later...

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...