Sign in to follow this  
Followers 0
Overlord

radiobutton checked?

6 posts in this topic

probably some noob question again but I'm stumbling and keep falling with my face to the floor...

to gether with the help of some great people here I was able to create a script that would help me greatly.

Now I want to implement this script into a GUI so that I can process more pages in a row.

I keep failing on the part which radiobutton is checked so that I can tell which function needs to be performed...

I'm sure my script can be a lot better but I'm just lacking skills...

please take a look at my script and tell me what's wrong.

I'm 100% it must be in the START function, but can't figure it out.

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.3.0.0
    Author:      myName
    
    Script Function:
    Template AutoIt script.
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Dim Const $navOpenInNewTab = 0x0800
Global $sURL1 = "http://www.facebook.com/friends/?ref=tn#/friends/?id=1310176439&flid=0&view=everyone&q=&nt=0&nk=0&s=0&st=0#50"
Global $sURL2 = "http://www.facebook.com/friends/?ref=tn#/friends/?id=1310176439&flid=0&view=everyone&q=&nt=0&nk=0&s=50&st=0#50"
Global $sURL3 = "http://www.facebook.com/friends/?ref=tn#/friends/?id=1310176439&flid=0&view=everyone&q=&nt=0&nk=0&s=100&st=0#50"
Global $sURL4 = "http://www.facebook.com/friends/?ref=tn#/friends/?id=1310176439&flid=0&view=everyone&q=&nt=0&nk=0&s=150&st=0#50"
Global $sURL5 = "http://www.facebook.com/friends/?ref=tn#/friends/?id=1310176439&flid=0&view=everyone&q=&nt=0&nk=0&s=200&st=0#50"
Global $sURL6 = "http://www.facebook.com/friends/?ref=tn#/friends/?id=1310176439&flid=0&view=everyone&q=&nt=0&nk=0&s=250&st=0#50"
Global $sURL7 = "http://www.facebook.com/friends/?ref=tn#/friends/?id=1310176439&flid=0&view=everyone&q=&nt=0&nk=0&s=300&st=0#50"
Global $sURL8 = "http://www.facebook.com/friends/?ref=tn#/friends/?id=1310176439&flid=0&view=everyone&q=&nt=0&nk=0&s=350&st=0#50"

Global $sSearch = "http://www.facebook.com/profile.php?id="
Global $sReplace = "http://apps.facebook.com/inthemafia/status_invite.php?from="
Global $oIE, $oLinks, $new_link

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Mafia Wars auto-adder", 355, 223, 194, 126)
GUISetBkColor(0xC0C0C0)
$Label1 = GUICtrlCreateLabel("This application will automatically add", 37, 16, 289, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
GUICtrlSetColor(-1, 0x800000)
$Label2 = GUICtrlCreateLabel("your friends to mafia wars.", 82, 48, 199, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
GUICtrlSetColor(-1, 0x800000)
$Label3 = GUICtrlCreateLabel("How many pages do you want to process?", 32, 80, 299, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
GUICtrlSetColor(-1, 0x800000)
$Radio1 = GUICtrlCreateRadio("1 Page", 27, 112, 65, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
$Radio2 = GUICtrlCreateRadio("2 Pages", 102, 112, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
$Radio3 = GUICtrlCreateRadio("3 Pages", 181, 112, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
$Radio4 = GUICtrlCreateRadio("4 Pages", 256, 112, 72, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
$Radio5 = GUICtrlCreateRadio("5 Pages", 27, 136, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
$Radio6 = GUICtrlCreateRadio("6 Pages", 102, 136, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
$Radio7 = GUICtrlCreateRadio("7 Pages", 181, 136, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
$Radio8 = GUICtrlCreateRadio("8 Pages", 256, 136, 73, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Georgia")
$Button1 = GUICtrlCreateButton("THANK YOU!!!", 108, 168, 147, 41)
GUICtrlSetFont(-1, 12, 800, 2, "Georgia")
GUICtrlSetColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            START()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func START()
    GUICtrlRead($Radio1, $GUI_Checked)
    GUICtrlRead($Radio2, $GUI_Checked)
    GUICtrlRead($Radio3, $GUI_Checked)
    GUICtrlRead($Radio4, $GUI_Checked)
    GUICtrlRead($Radio5, $GUI_Checked)
    GUICtrlRead($Radio6, $GUI_Checked)
    GUICtrlRead($Radio7, $GUI_Checked)
    GUICtrlRead($Radio8, $GUI_Checked)

    Select
        Case $Radio1 = $GUI_Checked
            MsgBox(0, "radio1", "pressed")
            page1()
        Case $Radio2 = $GUI_Checked
            MsgBox(0, "radio2", "pressed")
            page1()
            page2()
        Case $Radio3 = $GUI_Checked
            MsgBox(0, "radio3", "pressed")
            page1()
            page2()
            page3()
        Case $Radio4 = $GUI_Checked
            MsgBox(0, "radio4", "pressed")
            page1()
            page2()
            page3()
            page4()
        Case $Radio5 = $GUI_Checked
            MsgBox(0, "radio5", "pressed")
            page1()
            page2()
            page3()
            page4()
            page5()
        Case $Radio6 = $GUI_Checked
            MsgBox(0, "radio6", "pressed")
            page1()
            page2()
            page3()
            page4()
            page5()
            page6()
        Case $Radio7 = $GUI_Checked
            MsgBox(0, "radio7", "pressed")
            page1()
            page2()
            page3()
            page4()
            page5()
            page6()
            page7()
        Case $Radio8 = $GUI_Checked
            MsgBox(0, "radio8", "pressed")
            page1()
            page2()
            page3()
            page4()
            page5()
            page6()
            page7()
            page8()
    EndSelect
EndFunc  ;==>START

Func page1()
    $oIE = _IECreate($sURL1)
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>page1

Func page2()
    $oIE = _IECreate($sURL2)
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>page2

Func page3()
    $oIE = _IECreate($sURL3)
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>page3

Func page4()
    $oIE = _IECreate($sURL4)
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>page4

Func page5()
    $oIE = _IECreate($sURL5)
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>page5

Func page6()
    $oIE = _IECreate($sURL6)
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>page6

Func page7()
    $oIE = _IECreate($sURL7)
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>page7

Func page8()
    $oIE = _IECreate($sURL8)
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>page8

Share this post


Link to post
Share on other sites



see... I TOLD ya it would be a dumbass question...

thx a lot Authenticity!! IF U were a girl, I'd kiss you!!!

atleast, I would try :-)

Share this post


Link to post
Share on other sites

k, time to clean up the next step...

Select
        Case BitAND(GUICtrlRead($Radio1), $GUI_CHECKED); Will evaluate to 1 := True or 0 := False
            MsgBox(0, "radio1", "pressed")
            $oIE = _IECreate($sURL1)
            add()
        Case BitAND(GUICtrlRead($Radio2), $GUI_CHECKED); Same
            MsgBox(0, "radio2", "pressed")
            $oIE = _IECreate($sURL2)
            add()
        Case BitAND(GUICtrlRead($Radio3), $GUI_CHECKED); Same
            MsgBox(0, "radio3", "pressed")
            $oIE = _IECreate($sURL3)
            add()
        Case BitAND(GUICtrlRead($Radio4), $GUI_CHECKED); Same
            MsgBox(0, "radio4", "pressed")
            $oIE = _IECreate($sURL4)
            add()
        Case BitAND(GUICtrlRead($Radio5), $GUI_CHECKED); Same
            MsgBox(0, "radio5", "pressed")
            $oIE = _IECreate($sURL5)
            add()
        Case BitAND(GUICtrlRead($Radio6), $GUI_CHECKED); Same
            MsgBox(0, "radio6", "pressed")
            $oIE = _IECreate($sURL6)
            add()
        Case BitAND(GUICtrlRead($Radio7), $GUI_CHECKED); Same
            MsgBox(0, "radio7", "pressed")
            $oIE = _IECreate($sURL7)
            add()
        Case BitAND(GUICtrlRead($Radio8), $GUI_CHECKED); Same
            MsgBox(0, "radio8", "pressed")
            $oIE = _IECreate($sURL8)
            add()
EndSelect
EndFunc  ;==>START

Func add()
    
    $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        If StringInStr($oLink.href, $sSearch) Then
            $new_link = StringReplace($oLink.href, $sSearch, $sReplace)
            ConsoleWrite("$new_link = " & $new_link & @LF)
            Sleep(10000)
            $oIE.Navigate2($new_link, $navOpenInNewTab)
        EndIf
    Next
    Sleep(10000)
    _IEQuit($oIE)
EndFunc  ;==>add

if button 2 is pressed it should do both 1 AND 2

what's the easiest way to code this instead of adding

$oIE = _IECreate($sURL8)
            add()

that to every radiobutton check?

Share this post


Link to post
Share on other sites

You don't have to, just make your script event handled:

Opt('GuiOnEventMode', 1)

Dim $Radio = 0
Dim $GUI = GUICreate('Test', 100, 100)
Dim $Radio1 = GUICtrlCreateRadio('Radio1', 20, 20, 60, 23)
Dim $Radio2 = GUICtrlCreateRadio('Radio2', 20, 53, 60, 23)

GUICtrlSetOnEvent($Radio1, '_SetRadioSelect')
GUICtrlSetOnEvent($Radio2, '_SetRadioSelect')

GUISetOnEvent(-3, '_EXIT') ; GUI_EVENT_CLOSE
GUISetState()

While 1
    Sleep(20)
WEnd

Func _SetRadioSelect()
    ConsoleWrite(@GUI_CtrlId & @LF)
    $Radio = @GUI_CtrlId
    ConsoleWrite(GUICtrlRead($Radio) & @LF)
EndFunc

Func _EXIT()
    GUIDelete()
    Exit
EndFunc

This way you don't need to write case for each radio button.

Share this post


Link to post
Share on other sites

If I understand the question correctly, store $sURL in an array and:

Case BitAND(GUICtrlRead($Radio5), $GUI_CHECKED); Same
            MsgBox(0, "radio5", "pressed")
            For $i = 0 to 4
                $oIE = _IECreate($sURL[$i])
                add()
            Next

Share this post


Link to post
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
Sign in to follow this  
Followers 0