youtuber

Single, single url opening with button question

7 posts in this topic

Hello I want to open the site every time i click on the button

Case $Button4
If GUICtrlRead($Button4) = "Next site" Then
            $sitelisturl = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF)
            GUICtrlSetData($Button4, "Open Site")
            GUICtrlSetData($Input1, $sitelisturl)
Else
ShellExecute(GUICtrlRead($Input1))
GUICtrlSetData($Button4, "Next site")
EndIf

 

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

I want to do something like this

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 473, 327, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 64, 72, 329, 169)
GUICtrlSetData(-1, "")
$Input1 = GUICtrlCreateInput("", 64, 32, 329, 21)
$Button4 = GUICtrlCreateButton("Open Site", 72, 256, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

Case $Button4
        If GUICtrlRead($Button4) = "Next site" Then
            $sitelisturl = GUICtrlRead($Edit1, @LF)
            GUICtrlSetData($Button4, "Open Site")
            GUICtrlSetData($Input1, $sitelisturl)
Else
ShellExecute(GUICtrlRead($Input1))
GUICtrlSetData($Button4, "Next site")
EndIf

    EndSwitch
WEnd

 

Edited by youtuber

Share this post


Link to post
Share on other sites

Not sure the way you chose is very convenient... but this works

#include <GUIConstantsEx.au3>
#include <StringConstants.au3>
#Include <Array.au3>

; sample list
$sList = "https://www.autoitscript.com" & @crlf & "https://www.google.com"

$Form1 = GUICreate("Form1", 473, 327, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 64, 72, 329, 169)
GUICtrlSetData($Edit1, $sList)
$Input1 = GUICtrlCreateInput("", 64, 32, 329, 21)
$Button4 = GUICtrlCreateButton("Next Site", 72, 256, 75, 25)
GUISetState(@SW_SHOWNA)

$aList = StringSplit(GUICtrlRead($Edit1), @crlf, $STR_ENTIRESPLIT)
;_ArrayDisplay($aList)
$n = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button4
             If GUICtrlRead($Button4) = "Next site" Then
                  $n += 1
                  GUICtrlSetData($Input1, $aList[$n] )
                  GUICtrlSetData($Button4, "Open Site")
             Else
                  ShellExecute(GUICtrlRead($Input1))
                  GUICtrlSetData($Button4, "Next site")
            EndIf

    EndSwitch
WEnd

 

1 person likes this

Share this post


Link to post
Share on other sites

@mikell thank you


How should I be for a message box when the links end?
Thank you

#include <GUIConstantsEx.au3>
#include <StringConstants.au3>

$sList = "https://www.autoitscript.com" & @crlf & "https://www.google.com"

$Form1 = GUICreate("Form1", 473, 327, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 64, 72, 329, 169)
GUICtrlSetData($Edit1, $sList)
$Input1 = GUICtrlCreateInput("", 64, 32, 329, 21)
$Button4 = GUICtrlCreateButton("Next Site", 72, 256, 75, 25)
GUISetState(@SW_SHOWNA)

$aList = StringSplit(GUICtrlRead($Edit1), @crlf, $STR_ENTIRESPLIT)
$n = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button4
             If GUICtrlRead($Button4) = "Next site" Then
                  $n += 1
                  GUICtrlSetData($Input1, $aList[$n] )
                  If @error Then
         MsgBox(0,"finish","links it is over")
                  GUICtrlSetData($Button4, "Open Site")
             Else
                  ShellExecute(GUICtrlRead($Input1))
                  GUICtrlSetData($Button4, "Next site")
            EndIf
EndIf
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

Remember the StringSplit, the number of sites is in $aList[0]  :)

Case $Button4
             If GUICtrlRead($Button4) = "Next site" Then
                  $n += 1
                  If $n > $aList[0] Then
                          MsgBox(0,"finish","links it is over")
                          Continueloop
                  EndIf
                  GUICtrlSetData($Input1, $aList[$n] )
                  GUICtrlSetData($Button4, "Open Site")
             Else
                  ShellExecute(GUICtrlRead($Input1))
                  GUICtrlSetData($Button4, "Next site")
            EndIf

 

1 person likes this

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