jamesstp20 0 Posted September 12, 2010 (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 September 12, 2010 by jamesstp20 Share this post Link to post Share on other sites
seandisanti 6 Posted September 12, 2010 that URL you're acting upon... is it a link, the address bar of the current window, or ??? Share this post Link to post Share on other sites
jamesstp20 0 Posted September 12, 2010 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 Share this post Link to post Share on other sites
Tvern 11 Posted September 12, 2010 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 Share this post Link to post Share on other sites
jamesstp20 0 Posted September 12, 2010 (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 expandcollapse popup#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 September 12, 2010 by jamesstp20 Share this post Link to post Share on other sites
Richard Robertson 187 Posted September 12, 2010 If StringRegExp($LienYoutubeRead, "^http://www.youtube.com/watch?v=*+$") 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 Share this post Link to post Share on other sites
Tvern 11 Posted September 12, 2010 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 Share this post Link to post Share on other sites
Richard Robertson 187 Posted September 13, 2010 Well I wrote it rather quickly and didn't check it. The problem was my ? after watch. I forgot to escape it. Glad you got it working though. Share this post Link to post Share on other sites
jamesstp20 0 Posted September 13, 2010 Thanks i Will try Share this post Link to post Share on other sites