ruslanas402 Posted September 4, 2016 Share Posted September 4, 2016 Hello everyone, don't even know how to ask. My code is: #include <String.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') $x = 16 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') ;$actualdata2 = _StringBetween($a, 'href="', '&') $Checkbox1 = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Somehow I need to open webpages where checkbox is checked by presing button view, I think I need somehow asign $actualdata with $actualdata2. Any ideas would be very appreciated Link to comment Share on other sites More sharing options...
ruslanas402 Posted September 4, 2016 Author Share Posted September 4, 2016 I think I'm not the first person with this issue, it has to be solved somewhere already. Just give me some links please Link to comment Share on other sites More sharing options...
Developers Jos Posted September 4, 2016 Developers Share Posted September 4, 2016 Little impatient? Store the handles in that loop into an Array like: $Checkbox[$a] = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) And then do a For..Next in the Message loop check for any of these handles. This is also done in this way in SciTEConfig.au3 that comes with the full version of SciTE4AutoIt3. Jos ruslanas402 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ruslanas402 Posted September 4, 2016 Author Share Posted September 4, 2016 (edited) 40 minutes ago, Jos said: Little impatient? Store the handles in that loop into an Array like: $Checkbox[$a] = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) And then do a For..Next in the Message loop check for any of these handles. This is also done in this way in SciTEConfig.au3 that comes with the full version of SciTE4AutoIt3. Jos Hi Jos, I'm not just thought nobody will answer. Thx for advice, but still I'm in dark. $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') Global $Checkbox1[100] $x = 16 $a = 0 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') ;$actualdata2 = _StringBetween($a, 'href="', '&') $Checkbox1[$a] = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 $a = $a + 1 Next Am I going to right direction? I didn't uderstand what you meant by saying "Message loop check for any of these handles" Edited September 4, 2016 by ruslanas402 Link to comment Share on other sites More sharing options...
Developers Jos Posted September 4, 2016 Developers Share Posted September 4, 2016 (edited) 12 minutes ago, ruslanas402 said: $a = $a + 1 You don't want to do that as the For ... Next will fill $a with content. add another variable for the counting ($y). Just redim your array to the correct number after the initial For...Next like: $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') Global $Checkbox1[100] $x = 16 $y = 0 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') ;$actualdata2 = _StringBetween($a, 'href="', '&') $Checkbox1[$a] = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 $y = $y + 1 Next ReDim $Checkbox1[$y-1] Then add something like this in your message loop: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch ; check whether a button is pressed For $x = 0 to UBound($Checkbox1)-1 If $nMsg = $Checkbox1[$x] Then ; do what you want to do for Button pressed EndIf next WEnd Edited September 4, 2016 by Jos ruslanas402 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ruslanas402 Posted September 4, 2016 Author Share Posted September 4, 2016 5 hours ago, Jos said: ; do what you want to do for Button pressed I'm giving up. My final best code $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') Global $Checkbox1[200] $x = 16 $y = 0 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') $actualdata2 = _StringBetween($a, 'href="', '&') $Checkbox1[$a] = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 $y = $y + 1 Next ReDim $Checkbox1[$y-1] GUISetState(@SW_SHOW) Sleep(1000) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch ; check whether a button is pressed For $x = 0 to UBound($Checkbox1)-1 If $nMsg = $Checkbox1[$x] Then ; do what you want to do for Button pressed _IECreate("www.youtube.com/" & $actualdata2) EndIf next WEnd But instead of opening selected boxes, it just opens "youtube.com" website constantly Link to comment Share on other sites More sharing options...
AutoBert Posted September 4, 2016 Share Posted September 4, 2016 try $_IECreate("www.youtube.com/" & $actualdata2[$x]) you can also insert a Consolewrite for checking the url: ConsoleWrite("www.youtube.com/" & $actualdata2[$x]&@crlf) you can also use _ArrayDisplay to see if the arrays: $FirstChunks, $actualdata and $actualdata2 has expected elements. ruslanas402 1 Link to comment Share on other sites More sharing options...
ruslanas402 Posted September 4, 2016 Author Share Posted September 4, 2016 Nothing happens I think I should make variables $actualdata and $actualdata2 to 2D dimensional arrays, but HOW:? So far my code: expandcollapse popup#include <String.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') Global $Checkbox1[200] $x = 16 $y = 0 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') $actualdata2 = _StringBetween($a, 'href="', '&') $Checkbox1[$a] = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 $y = $y + 1 Next ReDim $Checkbox1[$y-1] GUISetState(@SW_SHOW) Sleep(1000) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch ; check whether a button is pressed For $x = 0 to UBound($Checkbox1)-1 If $nMsg = $Checkbox1[$x] Then ; do what you want to do for Button pressed ConsoleWrite("www.youtube.com/" & $actualdata2[$x]&@crlf) EndIf next WEnd Try yourself mate, playlist isn't private Link to comment Share on other sites More sharing options...
AutoBert Posted September 4, 2016 Share Posted September 4, 2016 Test this script: expandcollapse popup#include <GUIConstantsEx.au3> #include <IE.au3> #include <String.au3> #include <Array.au3> $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') ;_ArrayDisplay($FirstChunks, '$FirstChunks') Global $Checkbox1[UBound($FirstChunks)][2] $x = 16 $y = 0 $iCheck = 0 For $a = 0 To UBound($FirstChunks) - 1 $actualdata = _StringBetween($FirstChunks[$a], '">', '</a>') If Not IsArray($actualdata) Then ContinueLoop $actualdata2 = _StringBetween($FirstChunks[$a], 'href="', '&') If Not IsArray($actualdata2) Then ContinueLoop $Checkbox1[$iCheck][0] = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $Checkbox1[$iCheck][1] = $actualdata2[0] $iCheck += 1 $x = $x + 20 $y = $y + 1 Next ReDim $Checkbox1[$iCheck][2] ;maybe some checkboxes aren't created (avoiding corupt data using ContinueLoop) _ArrayDisplay($Checkbox1,'checkbox ids |URL-watchpart') GUISetState(@SW_SHOW) Sleep(1000) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; check whether a button is pressed For $x = 0 To UBound($Checkbox1) - 1 ConsoleWrite('X: ' & $x & @TAB & $Checkbox1[$x][0] & @TAB) If BitAND(GUICtrlRead($Checkbox1[$x][0]), $GUI_CHECKED) = $GUI_CHECKED Then ConsoleWrite('is checked') ; do what you want to do for Button pressed ConsoleWrite("www.youtube.com/" & $Checkbox1[$x][1] & @CRLF) _IECreate("www.youtube.com/" & $Checkbox1[$x][1]) GUICtrlSetState($Checkbox1[$x][0], $GUI_UNCHECKED) ;so you have toc check again and press view ExitLoop ;as you can't see all tut's at same time Else ConsoleWrite('is not checked') EndIf ConsoleWrite('press View' & @CRLF) Next EndSwitch WEnd it should work like expected, but i can't test my internet is to poor (64 kbs). ruslanas402 1 Link to comment Share on other sites More sharing options...
ruslanas402 Posted September 5, 2016 Author Share Posted September 5, 2016 You amazing man. Thank you so much, it does exactly as I wanted I knew it should use two dimensional arays. Just couldn't figure out how to combine them. Sorry for internet connection Link to comment Share on other sites More sharing options...
AutoBert Posted September 5, 2016 Share Posted September 5, 2016 1 hour ago, ruslanas402 said: You amazing man. Glad i could help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now