Jump to content

Recommended Posts

Posted

i'd like to add a countdown somewhere under the $list1 in this script. ideally it would start at 5 minutes and count down to zero and then reset itself to 5 minutes if possible. this script attacks an enemy every 5 minutes so i'd like to know when the next attack is coming :P

#include <GUIConstants.au3>
#include <IE.au3>
 $wins = 0
 $losses = 0
 

$oIE = _IECreateEmbedded ()
$Form1 = GUICreate("KnightFight", 1271, 970, -5, -1)
GUISetIcon("D:\004.ico")
$GUIActiveX = GUICtrlCreateObj($oIE, 5, 4, 1060, 959)
_IENavigate($oIE, "xxxxxxxxxxxxxx")
$GroupBox1 = GUICtrlCreateGroup("", -24, 9, 1073, 969)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
$List1 = GUICtrlCreateList("", 1072, 232, 161, 70)
GUICtrlSetData($List1, "Wins:" & $wins & "|Losses:" & $losses)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Start", 1136, 16, 73, 25, 0)
$Button3 = GUICtrlCreateButton("Close", 1136, 96, 75, 25, 0)
$Combo1 = GUICtrlCreateCombo("Level", 1080, 480, 145, 25)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30")
$Combo2 = GUICtrlCreateCombo("Allignment", 1080, 536, 145, 25)
GUICtrlSetData(-1, "Neutral|Knight of Light|Horde of Darkness")
$Combo3 = GUICtrlCreateCombo("Level Difference", 1080, 576, 145, 25)
GUICtrlSetData(-1, "Exact|Higher than or Equal to|Less than or Equal to")
GUISetState(@SW_SHOW)
 while 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
        ; Create a browser window and navigate to knightfight
; get pointers to the login form and username and password fields
$List1 = GUICtrlCreateList("", 1072, 232, 161, 70)
GUICtrlSetData($List1, "Wins:" & $wins & "|Losses:" & $losses)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$o_form = _IEFormGetObjByName($oIE, "regform")
$o_login = _IEFormElementGetObjByName($o_form, "user")
$o_password = _IEFormElementGetObjByName($o_form, "password")
$o_server = _IEFormElementGetObjByName($o_form, "server")
_IELoadWait ($oIE)
; Set field values and submit the form
_IEFormElementOptionselect($o_server, "xxxxxxxxx")
sleep(500)
_IEFormElementSetValue($o_login, "xxxxxxxx")
_IEFormElementSetValue($o_password, "xxxxxxx")
_IEFormSubmit($o_form)
_IELoadWait ($oIE)
while 1
; Clicks mission and selects an opponent
_IELinkClickByText ($oIE, "Mission")
 $oForms = _IEFormGetCollection ($oIE,2)
 $oElement = _IEFormElementGetCollection($oForms,2)
 $oElement2 = _IEFormElementGetCollection($oForms,3)
 $oElement3 = _IEFormElementGetCollection($oForms,4)
 If GUICtrlRead($Combo2) = "Neutral" Then
     _IEFormElementOptionselect($oelement3, "0")
 ElseIf GUICtrlRead($Combo2)= "Knight of Light" Then
      _IEFormElementOptionselect($oelement3, "1")
  ElseIf GUICtrlRead($Combo2) = "Horde of Darkness" Then
       _IEFormElementOptionselect($oelement3, "2")
   EndIf
   If GUICtrlRead($Combo3) = "Exact" Then
    _IEFormElementOptionselect($oelement, "=")
 ElseIf GUICtrlRead($Combo3) = "Higher than or Equal to" Then
    _IEFormElementOptionselect($oelement, ">=")
 ElseIf GUICtrlRead($Combo3) = "Less than or Equal to" Then
    _IEFormElementOptionselect($oelement, "<=")
EndIf
IF GUICtrlRead($Combo1) = "1" Then
     _IEFormElementSetValue($oelement2, "1")
ElseIf GUICtrlRead($Combo1) = "2" Then
     _IEFormElementSetValue($oelement2, "2")
ElseIf GUICtrlRead($Combo1) = "3" Then
     _IEFormElementSetValue($oelement2, "3")
ElseIf GUICtrlRead($Combo1) = "4" Then
     _IEFormElementSetValue($oelement2, "4")
ElseIf GUICtrlRead($Combo1) = "5" Then
     _IEFormElementSetValue($oelement2, "5")
ElseIf GUICtrlRead($Combo1) = "6" Then
     _IEFormElementSetValue($oelement2, "6")
ElseIf GUICtrlRead($Combo1) = "7" Then
     _IEFormElementSetValue($oelement2, "7")
ElseIf GUICtrlRead($Combo1) = "8" Then
     _IEFormElementSetValue($oelement2, "8")
ElseIf GUICtrlRead($Combo1) = "9" Then
     _IEFormElementSetValue($oelement2, "9")
ElseIf GUICtrlRead($Combo1) = "10" Then
     _IEFormElementSetValue($oelement2, "10")
ElseIf GUICtrlRead($Combo1) = "11" Then
     _IEFormElementSetValue($oelement2, "11")
ElseIf GUICtrlRead($Combo1) = "12" Then
     _IEFormElementSetValue($oelement2, "12")
ElseIf GUICtrlRead($Combo1) = "13" Then
     _IEFormElementSetValue($oelement2, "13")
ElseIf GUICtrlRead($Combo1) = "14" Then
     _IEFormElementSetValue($oelement2, "14")
ElseIf GUICtrlRead($Combo1) = "15" Then
     _IEFormElementSetValue($oelement2, "15")
ElseIf GUICtrlRead($Combo1) = "16" Then
     _IEFormElementSetValue($oelement2, "16")
ElseIf GUICtrlRead($Combo1) = "17" Then
     _IEFormElementSetValue($oelement2, "17")
ElseIf GUICtrlRead($Combo1) = "18" Then
     _IEFormElementSetValue($oelement2, "18")
ElseIf GUICtrlRead($Combo1) = "19" Then
     _IEFormElementSetValue($oelement2, "19")
ElseIf GUICtrlRead($Combo1) = "20" Then
     _IEFormElementSetValue($oelement2, "20")
ElseIf GUICtrlRead($Combo1) = "21" Then
     _IEFormElementSetValue($oelement2, "21")
ElseIf GUICtrlRead($Combo1) = "22" Then
     _IEFormElementSetValue($oelement2, "22")
ElseIf GUICtrlRead($Combo1) = "23" Then
     _IEFormElementSetValue($oelement2, "23")
ElseIf GUICtrlRead($Combo1) = "24" Then
     _IEFormElementSetValue($oelement2, "24")
ElseIf GUICtrlRead($Combo1) = "25" Then
     _IEFormElementSetValue($oelement2, "25")
ElseIf GUICtrlRead($Combo1) = "26" Then
     _IEFormElementSetValue($oelement2, "26")
ElseIf GUICtrlRead($Combo1) = "27" Then
     _IEFormElementSetValue($oelement2, "27")
ElseIf GUICtrlRead($Combo1) = "28" Then
     _IEFormElementSetValue($oelement2, "28")
ElseIf GUICtrlRead($Combo1) = "29" Then
     _IEFormElementSetValue($oelement2, "29")
ElseIf GUICtrlRead($Combo1) = "30" Then
     _IEFormElementSetValue($oelement2, "30")
endif
 _IEFormSubmit($oforms)
; Attacks!
 $oForms2 = _IEFormGetCollection ($oIE,0)
 $oElement = _IEFormElementGetCollection($oForms,1)
 _IEFormSubmit($oforms2)
 $sText = _IEPropertyGet($oIE,"innertext")
 if StringRegExp($sText, 'Winner: xxxxxxx') = 1 Then
     $wins = $wins +1
 ElseIf StringRegExp($sText, 'Winner: xxxxxx') = 0 Then
     $losses = $losses +1
 EndIf
 $List1 = GUICtrlCreateList("", 1072, 232, 161, 70)
GUICtrlSetData($List1, "Wins:" & $wins & "|Losses:" & $losses)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
 _IELinkClickByText ($oIE, "Estate")
 _IELinkClickByText ($oIE, "Pray at the altar")
  $sText = _IEPropertyGet($oIE,"innertext")
  while StringRegExp($sText, 'Your prayers have been answered; your health increased by 0 points!') = 0
        $oForms3 = _IEFormGetCollection ($oIE,0)
        $oElement4 = _IEFormElementGetCollection($oForms3,3)
        _IELoadWait ($oIE)
        _IEFormSubmit($oforms3)
        $sText = _IEPropertyGet($oIE,"innertext")    
    wend
 sleep(330000)
 wend
 Case $Button3
     Func Terminate ()
    Exit 0
EndFunc
    EndSwitch
WEnd
Posted

Script won't run, not gonna bother go through the whole script, please post a reproducer that can identify your problem clearly.

Change all the long Ifs to this

_IEFormElementSetValue($oelement2, GUICtrlRead($Combo1))
Posted

Script won't run, not gonna bother go through the whole script, please post a reproducer that can identify your problem clearly.

Change all the long Ifs to this

_IEFormElementSetValue($oelement2, GUICtrlRead($Combo1))

thanks i changed that around......the reason it won't run is because i edited some things out (my account etc) for privacy reasons. all i need to know is how to get a timer on the side of the GUI that counts down from 5 minutes to zero and then resets back to 5 minutes and repeats.

Posted

One way to do it is to add a Do....while in the while 1 statement. You need to use OnEvents in that case. I did this in my last script, and I am sure it is probably the dirtiest way to do it, but it works at least :P

if $countdown=1 Then
   $i = 60
    Do
      GUICtrlSetData($btnSync,"Synkronisera ("&$i&" sek)")
        sleep(1000)
        $i = $i - 1
        if $i = 0 Then
            _btnSync()
        EndIf
    Until $i = 0
EndIf

> there are 10 types of people in the world, those who understand binary and those who don't.

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
  • Recently Browsing   0 members

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