Jump to content
ruslanas402

Open webpages by checking boxes

Recommended Posts

ruslanas402

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="', '&amp;')
   $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 :)

Share this post


Link to post
Share on other sites
ruslanas402

I think I'm not the first person with this issue, it has to be solved somewhere already. Just give me some links please :)

Share this post


Link to post
Share on other sites
Jos

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 

  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ruslanas402
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="', '&amp;')
   $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 by ruslanas402

Share this post


Link to post
Share on other sites
Jos
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="', '&amp;')
   $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 by Jos
  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ruslanas402
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="', '&amp;')
   $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

Share this post


Link to post
Share on other sites
AutoBert

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.

  • Like 1

Share this post


Link to post
Share on other sites
ruslanas402

Nothing happens I think I should make variables $actualdata and $actualdata2 to 2D dimensional arrays, but HOW:?

So far my code:

#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="', '&amp;')
   $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 :)

Share this post


Link to post
Share on other sites
AutoBert

Test this script:

#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="', '&amp;')
    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).

  • Like 1

Share this post


Link to post
Share on other sites
ruslanas402

You amazing man.  Thank you so much, it does exactly as I wanted I knew it should use two dimensional arays. :D Just couldn't figure out how to combine them. :) Sorry for internet connection  :P

Share this post


Link to post
Share on other sites
AutoBert
1 hour ago, ruslanas402 said:

You amazing man.

Glad i could help. :)

 

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

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I am trying to grab the id "in2xk_26" however it the characters before the underscore always change. (in the name too)
      Is there a way I can find a id or name by the last 3 charcters?
      Using something like "stringright?"
      So I would want to search for just "_26" in this case.
      This is assuming that there are no other _26
       

      #include <Excel.au3> #include <IE.au3> #include <GUIConstantsEx.au3> Global $iMousespeed = 25,$target = "",$TagName = "",$Value = "",$Atrribute = "" $oIE = _IEAttach("MEDITECH") $TagName = "input" $Value = "in2xk_26" $Attribute = "id" $tags = $oIE.document.GetElementsByTagName($TagName) ;TagName ------ MAKE SURE TO NAME THESE For $tag in $tags $class_value = $tag.GetAttribute($Attribute) ;Attribute ------ MAKE SURE TO NAME THESE If string($class_value) = $Value Then ;Value ------ MAKE SURE TO NAME THESE $target = $tag $iScreenX = _IEPropertyGet($target, "screenx") $iScreenY = _IEPropertyGet($target, "screeny") $iWidth = _IEPropertyGet($target, "width") $iHeight = _IEPropertyGet($target, "height") $oMouseCords = MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed) MouseClick($MOUSE_CLICK_LEFT) ExitLoop EndIf Next  
       
    • SkysLastChance
      By SkysLastChance
      I was wondering how I read data inside of a iframe. I would like to be able to click something inside a iframe. However, I can't even find the tag. 
      The id and name change all the time so I can't use those. 
      The code highlighted in blue is what I am trying to click. (second picture)
      Here is what I have tried.
      $target = "" $tags = $oIE.document.GetElementsByTagName("div") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "s_92 altstyle s_93 s_94" Then $target = $tag ConsoleWrite("Tag Found " & $target.outerText&@CRLF) ExitLoop EndIf Next  

       
       

    • SkysLastChance
      By SkysLastChance
       
      WinActivate("MEDITECH - Internet Explorer") Sleep (500) $oIE = _IEAttach("MEDITECH") $oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton") _IEAction($oDiv1, "click") I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?
       

    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I have an inquiry and I hope to find the answer here
      I want to create a graphical user interface
      but I want to hide the system menu
      I mean the window menu
      Is this possible?
      If is possible please give me how to do that
      Thanks in advance
    • Iceburg
      By Iceburg
      Hi everyone, I'm at best a noobie.  I have read through the Array helps, and specifically the 2D array help file, and I'm struggling to get my code working.
      I have an array that is read from a file, thats working great.  I'm trying to do some math on the array, so I can find the largest, average, lowest, day over day change %, etc.
      The array read working fine, I get 43 lines, line 0 is 44, and then I get data that looks like
      0519 $10,000
      0520 $10,001
      0521 $10,002
      The data in this array is a single 1D array, breaking it out into 2 columns so I can do the math is what I can get to happen.  
      How do I reference the array to store this data?  Second, how do I assign this data to the appropriate row/column?
      Thanks in advance.
      Dim $all_cash_amounts[UBound($aInput)][2] Dim $max_amount_in_account Dim $min_amount_in_account _FileReadToArray($LC_Check_file_path, $aInput) _ArrayDisplay($aInput) local $date = StringRegExp($aInput[1], "(\d\d\d\d)", 1) local $cash = StringRegExp($aInput[1], "\d+\s(-?[0-9\.\,]+)", 1) ConsoleWrite("Date is: " & $date & @CRLF) For $i = 1 To UBound($aInput)-1     $date = StringRegExp($aInput[$i], "(\d\d\d\d)", 1)     $all_cash_amounts[$i][2] = $date[$i][0], $cash[$i][1]      Next _ArrayDisplay($all_cash_amounts)  
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.