ruslanas402

Open webpages by checking boxes

11 posts in this topic

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



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

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 

1 person likes this

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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="', '&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

#5 ·  Posted (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="', '&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
1 person likes this

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

Share this post


Link to post
Share on other sites
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

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.

1 person likes this

Share this post


Link to post
Share on other sites

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

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

1 person likes this

Share this post


Link to post
Share on other sites

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

    • Dimmae
      By Dimmae
      Hello,
      at first: i'm new here, so please forgive me my mistakes, and show them to me, just that i can learn to do better in the future.
      Now to my Problem: i have an excel sheet, where i just need some columns for further actions, but i have no idea how to add single columns to a new array.
      I found the following code(the one i just added as a file) from 'water' in this forum, but i wont get how i could add multiple columns into a new array.
      The biggest problem in my situation is that i dont know the count of the rows i need for the array, i just got a fix number of rows, which is 4.
       
      Hope you can help me, and sry again for this 'unlucky illustration'.
       
      btw: how can i add code shown as code here, instead of posting it as a attached file?.
       
       
       
      autoit-select-column.au3
      defects.xlsx
    • IAMK
      By IAMK
      Hello,
       
      I have a script which uses a GUI with two buttons. It gets shown and hidden., and pressing the buttons (including their hotkeys) highlights the button, making you able to press enter the next time.
      However, I don't want that.
       
      I've tried using WinActivate() to make enter do things on another program, but the enter is still tied to the AutoIT GUI (which still has the button highlighted).
       
      Here's the important part of my code:
      $MY_GUI = GUICreate("Check.exe", 400, 300, ((@DesktopWidth / 2) - 200), -500) WinSetOnTop($MY_GUI, "", 1) ;Keeps the window on the top. $Button1 = GUICtrlCreateButton("Pass (Ctrl+P)", 40, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Fail (Ctrl+F)", 240, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $GUIText = GUICtrlCreateLabel("", 20, 10, 360, 230) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") GUICtrlSetData($GUIText, Execute($stepMessage[$step])) $showGUI = "True" GUISetState(@SW_SHOW) While($showGUI = "True") $buttonPressed = GUIGetMsg() Switch $buttonPressed Case $Button1 ;Pass $pass = "True" $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) Case $Button2 ;Fail $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) While($message = "") $message = InputBox("Check.exe", "Please enter the reason the step failed." & @CRLF, "", "", 300, 200, ((@DesktopWidth / 2) - 150), -400) WEnd Return $message EndSwitch WEnd Local $pass = "False" ;Whether "Pass" or "Fail" was pressed. Local $failLog = xxxfunc($pass) ;Returns a message to log if the step failed. ##THIS CALLS THE CODE SNIPPET ABOVE## FileWrite($file, _Now() & ": Step " & $step & getStatus($pass) & "and took " & Ceiling(TimerDiff($timer) / 1000) & " seconds." & @CRLF) If($failLog <> "") Then FileWrite($file, "Logged comment: " & $failLog & @CRLF) EndIf WinActivate("[TITLE:ProgramName]") ;Hotkeys: HotKeySet("^{p}", "pressPass") HotKeySet("^{f}", "pressFail") Func pressPass() $buttonPressed = $Button1 EndFunc Func pressFail() $buttonPressed = $Button2 EndFunc  
      The GUI's button/hotkey pressing works correctly.
      The same WinActivate code works in another script of mine.
      Together, WinActivate is not take "Active" away from the GUI's last-pressed button. How do I fix this?
       
      Thank you in advance.
    • nassausky
      By nassausky
      Hi all,
       
      Anyone have any idea how to close all open tabs except a specific one I manually open.  Assuming I don't know what is open in all the tabs except just the one I want to keep open.
       
      I didn't want to use sendkeys and I was trying to use the following code to list the title (or url) of the 3 open tabs and  after I got that part working I would just close the other 2. This sample only displays the title of the first open tab
      #include <IE.au3> Const $ie_new_in_tab = 0x0800 $oIE = _IECreate("https://www.autoitscript.com") __IENavigate($oIE, "https://www.autoitscript.com/forum/", 1, $ie_new_in_tab) ;(obj,url,wait,param) __IENavigate($oIE, "https://www.google.com/", 1, $ie_new_in_tab) ;(obj,url,wait,param) Local $aIE[1] $aIE[0] = 0 Local $i = 1, $oIE While 1     $oIE = _IEAttach("", "instance", $i)     If @error = $_IEStatus_NoMatch Then ExitLoop     ConsoleWrite(_IEPropertyGet($oIE, "title") & @CRLF)     ReDim $aIE[$i + 1]     $aIE[$i] = $oIE ;each item holds object     $aIE[0] = $i ;first item holds count     $i += 1 WEnd MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0]) ; This doesn't return the list of tabs in the console just the first tab  
      Thanks for any and all help
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys this is my gui and i need the numeric value typed in the highlighted  inputbox. if this value is greater than 1 i need to perform some operations
      \
       
      Here is the summary about that field which i got from wininfo tool

      i tried writing the code as shown below.. but the msgbox is popping up empty value..when the same code is pasted under some button action i am able to access the value present in the field..but when placed alone as written in the attached script i am unable to fetch it... 

      here i am using the valu present in the field

      can you guys tell me what's wrong??? or how can i get that value?
       
      My_GUI.au3