Jump to content

Recommended Posts

Posted (edited)

Hello i'm trying to do something like this:

If $LienYoutubeRead = "http://www.http://www.youtube.com/watch?v=" & Not = "" Then

...

Or

If $LienYoutubeRead = "http://www.http://www.youtube.com/watch?v=" & <> "" Then

..

For Exemple:

If the GuICtrlCreateInput = http://www.http://www.youtube.com/watch?v=

Then do nothing

If the GuICtrlCreateInput = http://www.http://www.youtube.com/watch?v=ffdsdf

Do something

If the GuICtrlCreateInput = http://www.http://www.youtube.com/watch?v=lklk

Do something

If the GuICtrlCreateInput = http://www.http://fhkjhfdfdkjnfsd.com/

Do nothing

But i don't know how :S

Thanks and i hope you will understand what i'm trying to do ;)

Edited by jamesstp20
Posted

No its a website URL

If the GuICtrlCreateInput = http://www.http://www.youtube.com/watch?v=

Then do nothing

If the GuICtrlCreateInput = http://www.http://www.youtube.com/watch?v=ffdsdf

Do something

If the GuICtrlCreateInput = http://www.http://www.youtube.com/watch?v=lklk

Do something

If the GuICtrlCreateInput = http://www.http://fhkjhfdfdkjnfsd.com/

Do nothing

Thanks

Posted

4 things:

1. "&" is the operator to concatenate two strings. To evaluate if multiple statements are all true, use "And"

2. When using "And" every statement has to be valid on it's own:

If $var > 1 And < 2 Then ;this is not proper syntax
If $var > 1 And $var < 2 Then ;this is proper syntax and would be true if $var is between 1 and 2

3. When posting code, consider [ autoit] and [ /autoit] tags. They're nice!

4. For something like this I'd use a Switch statement like this:

$LienYoutubeRead = InputBox("Input required","Please enter a valid Youtube url")
Switch $LienYoutubeRead ;this is the variable we will look at in every case.
    Case "" ;the variable is empty
        MsgBox(0,"error","you must specify an youtube url!") ;react to the empty variable
    Case "http://www.http://www.youtube.com/watch?v="
        MsgBox(0,"error","that url isn't meant to work")
    Case "http://www.http://www.youtube.com/watch?v=sddffd"
        MsgBox(0,"success!","that one works")
    Case "http://www.http://www.lalalala.com"
        MsgBox(0,"error","that's not even a youtube url")
    Case Else ;this will be true if none of the others are.
        MsgBox(0,"error","i don't even know what to do with that")
EndSwitch
Posted (edited)

Look at the function _GetTitle(). Please i just wan't to be sure that the Youtube URL is good or not.. Its why i'm using a IF and not case + switch :S

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

$GUI = GUICreate("JST Youtube Downloader", 606, 199, 192, 124)
GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI")
GUICtrlSetColor(-1, 0x1E3287)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$LabelTitre = GUICtrlCreateLabel("Youtube Downloader Par Jamesst20", 175, 8, 255, 25)
GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI")
$TitreVideoYoutube = GUICtrlCreateLabel("", 48, 88, 518, 24)
GUICtrlSetFont(-1, 11, 400, 0, "Segoe UI")

$Group1 = GUICtrlCreateGroup("Téléchargement de la Vidéo de Youtube", 32, 56, 545, 121, $BS_CENTER)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$LienYoutube = GUICtrlCreateInput("http://www.", 48, 120, 409, 21)

$DownloadButton = GUICtrlCreateButton("Download", 472, 120, 89, 21, $WS_GROUP)
GUICtrlSetOnEvent(-1, "_GetTitle")

$ProgressBar = GUICtrlCreateProgress(48, 152, 513, 17)


GUISetState(@SW_SHOW)



While 1
Sleep(1)

WEnd

Func _Exit()
    Exit
EndFunc

Func _GetTitle()
    $LienYoutubeRead = GUICtrlRead($LienYoutube)
    If $LienYoutubeRead = "http://www.youtube.com/watch?v=" Then ;Verify if the URL of youtube is good.. How to? Please Help me
        $oIETitre = _IECreate($LienYoutubeRead,0,1,0)
        Sleep(2000)
        _IENavigate($oIETitre, "javascript:fv=document.getElementById('watch-headline-title').innerText;" ,0)
        ConsoleWrite("1")
        Sleep(1000)
        ConsoleWrite("2")
        $Titredetecter = _IEBodyReadText($oIETitre)
        ConsoleWrite("3")
        MsgBox(0, "", $Titredetecter)
        ConsoleWrite("4")
        GUICtrlSetData($TitreVideoYoutube, $Titredetecter)
      EndIf
        EndFunc
Edited by jamesstp20
Posted

I don't realy understand some parts of your StringRegExp pattern, but it returns false for me all the times.

This one works for me though:

If StringRegExp($LienYoutubeRead, "\A\Qhttp://www.youtube.com/watch?v=\E.+") Then   
    ; it has text after the v= 
Else    
    ; it doesn't have text after the v= or it might not even match the YouTube link
EndIf

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