Jump to content

Help with loop


Recommended Posts

Ok i have problem with my script. When im use only check script its work good

While 1
    $y = ControlListView("Sro Server List", "List1", 1001, "FindItem", "*SERVER NAME HERE*")
    $x = ControlListView("Sro Server List", "List1", 1001, "GetText", $y, "2")
    Sleep(500)
    If $x < 2999 Then
        SoundPlay(@WindowsDir & "\media\tada.wav",0)
        WinActivate("SRO_Client")
        MouseClick("left",602 , 506, 2, 1)
        Exit
    EndIf
WEnd

But i want use this script in GUI and look like this:

#include <GUIConstants.au3>

GUICreate("Free slot search", 240, 90) ; will create a dialog box that when displayed is centered

$servery=GUICtrlCreateCombo ("Chose server:", 10,10, 110, 20, $CBS_DROPDOWNLIST); create first item
GUICtrlSetData($servery, "Aege|Persia|Xian|Alexander|Poseidon", "")
GUICtrlSetStyle($servery, $CBS_DROPDOWNLIST)

$group_1 = GUICtrlCreateGroup ("Slots", 125, 4, 110, 50)
$radio_1 = GUICtrlCreateRadio ("&3", 133, 20, 25, 20)
$radio_2 = GUICtrlCreateRadio ("&2", 168, 20, 25, 20)
$radio_3 = GUICtrlCreateRadio ("&1", 203, 20, 25, 20)

; Init our vars that we will use to keep track of GUI events
$radioval1 = 0  ; We will assume 0 = first radio button selected, 2 = last button
$radioval2 = 0
$1slot = 3000
$2slot = 2999
$3slot = 2998


$button_1 = GUICtrlCreateButton ("go!", 10, 40, 80, 20)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
    
Case $msg = $radio_1
$sloty = $3slot

Case $msg = $radio_2
$sloty = $2slot

Case $msg = $radio_3
$sloty = $1slot
    
Case $msg = $button_1
WinActivate("Sro Server List")
$sName=GUICtrlRead($servery)
    $y = ControlListView("Sro Server List", "List1", 1001, "FindItem", $sName)
    $x = ControlListView("Sro Server List", "List1", 1001, "GetText", $y, "2")
    Sleep(500)
    If $x = $2slot Then
MsgBox(0, "Default button clicked", "Wait for: " & $sloty & $sName)
        Exit
    EndIf


Case $msg >= $radio_1 AND $msg <= $radio_3
$radioval1 = $msg - $radio_1

EndSelect
Wend

And this is work for $2slot but this is not problem. Problem is when in Sro Server List is free slot this not work. Only work when i click on go! button. All i want is this program work like a loop when i push go! button he check program all time and when is free slot show msg box. In first script its work he wait for free slot... but in this GUI script this work only when is free slot and i push go! button. Im know that i mess up but my english sux.

Link to comment
Share on other sites

There is program named Sro Server List this check how many free slots are on server, and first my script work with this program and when is free slot on server u chose its click Confirm at code window. U must run silkroad, write login and pass.. then write image code. And run this script when on ur server is free slot he click on confirm button in game. Just type ur server name here: *SERVER NAME HERE*.

Link to comment
Share on other sites

sro server list is a turk program, u are sure isnt a keyloger program ? lol, u must to learn what is a function first to make a script.

try:

#include <GUIConstants.au3>

GUICreate("Free slot search", 240, 90); will create a dialog box that when displayed is centered

$servery=GUICtrlCreateCombo ("Chose server:", 10,10, 110, 20, $CBS_DROPDOWNLIST); create first item
GUICtrlSetData($servery, "Aege|Persia|Xian|Alexander|Poseidon", "")
GUICtrlSetStyle($servery, $CBS_DROPDOWNLIST)

$group_1 = GUICtrlCreateGroup ("Slots", 125, 4, 110, 50)
$radio_1 = GUICtrlCreateRadio ("&3", 133, 20, 25, 20)
$radio_2 = GUICtrlCreateRadio ("&2", 168, 20, 25, 20)
$radio_3 = GUICtrlCreateRadio ("&1", 203, 20, 25, 20)

; Init our vars that we will use to keep track of GUI events
$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
$radioval2 = 0
$1slot = 3000
$2slot = 2999
$3slot = 2998


$button_1 = GUICtrlCreateButton ("go!", 10, 40, 80, 20)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
sleep(50)
$msg = GUIGetMsg()
Select
        
Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    
Case $msg = $radio_1
    $sloty = $3slot

Case $msg = $radio_2
    $sloty = $2slot

Case $msg = $radio_3
    $sloty = $1slot
    
Case $msg = $button_1
    Look4slot()

Case $msg >= $radio_1 AND $msg <= $radio_3
    $radioval1 = $msg - $radio_1

EndSelect
Wend


Func Look4slot()
While 1
    $sName=GUICtrlRead($servery)
    $y = ControlListView("Sro Server List", "List1", 1001, "FindItem", $sName)
    $x = ControlListView("Sro Server List", "List1", 1001, "GetText", $y, "2")
    MsgBox(0, "Default button clicked", "Wait for: " & $sloty & $sName)
    
    Sleep(500)
    If $x < $2slot Then
        SoundPlay(@WindowsDir & "\media\tada.wav",0)
        if ProcessExists ("SRO_Client.exe") Then
            WinActivate("SRO_Client")
            MouseClick("left",602 , 506, 2, 1)
            Exit
        EndIf
    Exit
    EndIf
WEnd
EndFunc
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...