Jump to content

Click in a button!


XRS
 Share

Recommended Posts

Hi, I have a little big app that is not working.

I want to make it clicking about 6 to 6 hours in a button.

My source code is this:

; ----------------------------------------------------------------------------
; <AUT2EXE INCLUDE-END: C:\Archivos de programa\AutoIt3\Include\ie.au3>
; ----------------------------------------------------------------------------
dim $sUrl = "http://www.gamesites200.com/"
dim $sUrl2 = "http://www.gamesites200.com/"
dim $sUrl3 = "http://www.gamesites200.com/"
dim $sUrl4 = "http://www.gamesites200.com/"
dim $click = "xXx"
dim $exit = "exit"
dim $palabra = "id="
dim $restart = "restart"
dim $clock = "clock"
dim $links = "links"
dim $varlink = ""
$Form1 = GUICreate("Autovoter 1 - L2-Underworld.com", 430, 600, 93, 15)
$MenuItem1 = GUICtrlCreateMenu("Help")
$MenuItem2 = GUICtrlCreateMenuItem("About", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("How it works", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("Contact", $MenuItem1)
$Group1 = GUICtrlCreateGroup("Instructions", 5, 5, 275, 69)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("", 15, 20, 150, 17)
$Label2 = GUICtrlCreateLabel("", 15, 35, 107, 17)
$Label3 = GUICtrlCreateLabel(".- Click START button!", 15, 50, 260, 17)
$Obj1 = ObjCreate("Shell.Explorer.2")
$Obj1_ctrl = GUICtrlCreateObj($Obj1, 0, 80, 430, 370)
$Obj2 = ObjCreate("Shell.Explorer.2")
$Obj2_ctrl = GUICtrlCreateObj($Obj2, 0, 455, 430, 110)
_IENavigate($Obj1, "http://www.gamesites200.com", 1)
GUISetState(@SW_SHOW)
$Button1 = GUICtrlCreateButton("START", 350, 50, 75, 25, 0)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $MenuItem2
    MsgBox (0,"About","AutoVoter1")
Case $MenuItem3
    MsgBox (0,"How it works","Just click in the start button...")
Case $MenuItem4
    MsgBox (0,"Contact","Tiga_27_7@hotmail.com")
Case $Button1
_IENavigate($Obj1, $sUrl3, 1)
SearchLinks($links)
EndSwitch
WEnd
Func SearchLinks($links)
_IEAction ($Obj1, "refresh")
$body = _IEBodyReadHTML ($Obj1)
If not StringInStr($body, $palabra) Then
    LinksExit($exit)
    Else
    Funcionclick()
    SearchLinks($links)
    LinksExit($click)
EndIf
EndFunc
Func Funcionclick()
$oLinks = _IELinkGetCollection ($Obj1)
$iNumLinks = @extended
$restlinks = $iNumLinks -7
$Label5 = GUICtrlCreateLabel($restlinks, 200, 20, 30, 17)
For $oLink In $oLinks
$Group1 = GUICtrlCreateGroup("", 5, 5, 275, 69)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetData ($Label1, ".- Votes Remaining:")
GUICtrlSetData ($Label2, "")
GUICtrlSetData ($Label2, ".- TigaXXXXXX@hotmail.com -.")
GUICtrlSetData ($Label5, $restlinks)
$restlinks = $restlinks -1
If StringInStr ($oLink.href, "id=") Then
    _IENavigate ($Obj2, $oLink.href)
    _IELoadWaitTimeout ($Obj2)
    Sleep(33000)
    _IELoadWaitTimeout ($Obj2)
    _IELoadWaitTimeout ($Obj2)
    _IELoadWaitTimeout ($Obj2)
    _IELoadWaitTimeout ($Obj2)
EndIf
Next
EndFunc
Func FuncClick()
EndFunc
Func LinksExit($click)
    $Group1 = GUICtrlCreateGroup("Clicks Information", 5, 5, 275, 69)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlSetData ($Label1, ".- NO CLICKS REMAINING -.")
    GUICtrlSetData ($Label2, "")
    GUICtrlSetData ($Label3, ".- Next search in:")
    $Label4 = GUICtrlCreateLabel("", 140, 50, 40, 17)
    $Label5 = GUICtrlCreateLabel("Sec.", 170, 50, 40, 17)
$c = 10
While $c >= 0
    GUICtrlSetData ($Label4, $c)
    Sleep(1000)
    $c = $c - 1
WEnd
    Sleep (2000)
    GUICtrlSetData ($Label1, "")
    GUICtrlSetData ($Label2, "")
    GUICtrlSetData ($Label3, "")
    GUICtrlSetData ($Label4, "")
    GUICtrlSetData ($Label5, "")
    SearchLinks($links)
EndFunc

I'm new in autoit and I want to know the click functions, and then, click again in about 6 or 12 hours.

As you can see, it will be used to make an automatic voter.

Anyone could help me?

Link to comment
Share on other sites

#include <IE.au3>
;Create the IE
$oIE = _IECreate ("http://www.google.com")

;Get the input object called 'q'
$oQuery= _IEGetObjByName ($oIE, "q")

;Get the button object called 'btnG' (Search in Google)
$oButton= _IEGetObjByName ($oIE, "btnG")

;Set the text in the input
_IEFormElementSetValue ($oQuery, "This is an example for XRS")

;Click on the button
_IEAction($oButton,"click")

Refer to the functions I told you in the help file for more detailed info :)

Link to comment
Share on other sites

Thanks, I got it working but now I have a few more questions.

I want this do:

1. The same every 6 hours;

2. That he doesn't open the IE browser when doing it.

Thats possible?

If so, an example would be great.

Thanks :)

Link to comment
Share on other sites

Here's an example of how to make your script do something every X hours:

#include <date.au3>

$Hours=6;Put here how many hours you want to pause your script.

While 1
    
    ;############################################
    ;This is where you do your stuff every 6 hours
    ;#############################################
    
    ;The following loop pauses the script for 6 hours.
    $StartDate=_NowCalc();Get the start time
    While 1
        $Diff=_DateDiff('h',$StartDate,_NowCalc());Check the difference between the current time and the time it started
        If Number($Diff)=$Hours then ExitLoop;When the difference is 6 hours, exit the current loop.
        Sleep(100)
    WEnd
WEnd

And to avoid him to open the IE browser, I suppose you could check in a loop for iexplore.exe. If it exists, close it. Or:

Opt("WinTitleMatchMode",2)
While 1
    If WinExists("Internet Explorer") then WinClose("Internet Explorer")
    Sleep(100)
WEnd
Link to comment
Share on other sites

Here's an example of how to make your script do something every X hours:

#include <date.au3>

$Hours=6;Put here how many hours you want to pause your script.

While 1
    
    ;############################################
    ;This is where you do your stuff every 6 hours
    ;#############################################
    
    ;The following loop pauses the script for 6 hours.
    $StartDate=_NowCalc();Get the start time
    While 1
        $Diff=_DateDiff('h',$StartDate,_NowCalc());Check the difference between the current time and the time it started
        If Number($Diff)=$Hours then ExitLoop;When the difference is 6 hours, exit the current loop.
        Sleep(100)
    WEnd
WEndoÝ÷ Ø    ݶ¯¢'akh¢§¶ºèÂÇ«"Ë©¦Ê¢é]r)Ú)~â{e¢·Åâ×±ËlrZ,z+N­ÊxêmãMøZ)ÓÙ^1«Ê{~6ãU¡Wµ!õ¢Lb²Û8Ó~׫ëDÆh­ê÷ãméÖp¥¢Ç¸Ó~׫ëDÆh­ê÷ãRç©ãMtÓVwr^þ«¨µäáyÊyú+h¥é⨺²Â)Ý£¬jX¥X­r¢*.­Ê&¦ë^®+'µö¬µ:ò²¶§X¤zØb±«­¢+Ø¥¹±Õ±Ðí%¹ÔÌÐì(í$½Õ±¹Ð¥¹Ý¡ÉÔÍÑÉÑå½ÕÈ%áÁ±½ÉÈÕÐͽµÑ¡¥¹±¥¬Ñ¡¥ÌÝ¥±°¡¥Ñ¡Ý¥¹½Ü)}¥ÉÑ ÀÌØí½%°ÅÕ½ÐíÝÝܹ½½±¹½´ÅÕ½Ðì°À°À°Ä°À¤

That opens a invisible Google window....

Dunno if it helps.. but there is a way to not even see the voter...

Link to comment
Share on other sites

Thanks, It's working now!

But now I have another problem.

Let's think that the NAME of the button gets an random name.

Instead being always "food" it randomizes itself, like "food", "icecream", "banana"

There's anyway to click it by its name like it's ever the same?

Link to comment
Share on other sites

Look at _IETagnameGetCollection and pass an index. If it is a form element you can also use _IEFormElementGetCollection.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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