Jump to content

2 windows with same name


ssah8
 Share

Recommended Posts

12 minutes ago, Juvigy said:

Try something like this:

Local $i = 1
While 1
    $oIE = _IEAttach("", "instance", $i)
    If @error = $_IEStatus_NoMatch Then
        $oIE = 0
        ExitLoop
    EndIf
    ConsoleWrite(_IEPropertyGet($oIE, "locationurl") &@CRLF)
    ConsoleWrite(_IEPropertyGet($oIE, "hwnd") &@CRLF)
    $i += 1
WEnd

 

What should "instance" be?

Link to comment
Share on other sites

33 minutes ago, Juvigy said:

Parameter. This code will attach to all open windows and output the handle and the url. You will see that the 2 windows with the same name have different handles.

What if the url is different for every user? Based on the user who uses the bot, a different link will show up. It will show up a link with a /(username) in the end. 

Link to comment
Share on other sites

You wanted to attach when 2 windows with the same name - this is how you do it.  It doesnt matter the link - you attach to all with a loop. Then you identify your window and put an IF inside and return the correct object.

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("YTMonster | Bot", 330, 245, 192, 124)
$Group1 = GUICtrlCreateGroup("Login", 0, 0, 137, 169)
$username = GUICtrlCreateInput("Username", 8, 48, 121, 21)
$password = GUICtrlCreateInput("Password", 8, 80, 121, 21)
$Login1 = GUICtrlCreateButton("Login", 8, 112, 123, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Start", 136, 0, 185, 169)
$Pic1 = GUICtrlCreatePic("C:\Users\Admin\Desktop\147863078766323.jpg", 144, 16, 172, 52)
$start = GUICtrlCreateButton("Start", 144, 80, 171, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Points", 8, 176, 169, 65)
$points1 = GUICtrlCreateLabel("0", 16, 200, 15, 29)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("Made by DanCodes", 192, 200, 98, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
logintosite()

Func logintosite()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Login1
            Global $oIE = _IECreate("https://www.ytmonster.net/login")

            $username1 = GUICtrlRead($username)
            $password1 = GUICtrlRead($password)

            $emailform = _IEGetObjByName($oIE, "usernames")
            $usernameform = _IEGetObjByName($oIE, "passwords")


            _IEFormElementSetValue($emailform, $username1)
            _IEFormElementSetValue($usernameform, $password1)


            Case $start

               Local $oInputs = _IETagNameGetCollection($oIE, "button")
               For $oInput In $oInputs
                  If $oInput.classname == "btn btn-success" Then _IEAction($oInput, "click")
               next

               sleep(10000)

               _IENavigate($oIE, "https://www.ytmonster.net/download")

               sleep(3000)

               Local $oInputs = _IETagNameGetCollection($oIE, "div")
               For $oInput In $oInputs
                  If $oInput.classname == "btn btn-large btn-primary" Then _IEAction($oInput, "click")
               Next

               sleep(3000)

               Local $oInputs = _IETagNameGetCollection($oIE, "button")
               For $oInput In $oInputs
                  If $oInput.classname == "button blue" Then _IEAction($oInput, "click")
               Next

               Local $i = 1
               While 1
                  $oIE2 = _IEAttach("", "instance", $i)
                  If @error = $_IEStatus_NoMatch Then
                     $oIE = 0
                     ExitLoop
               EndIf
               ConsoleWrite(_IEPropertyGet($oIE, "locationurl") &@CRLF)
               ConsoleWrite(_IEPropertyGet($oIE, "hwnd") &@CRLF)
               $i += 1
               WEnd


               Local $oInputs = _IETagNameGetCollection($oIE2, "div")
               For $oInput In $oInputs
                  If $oInput.classname == "btn btn-success btn-sm" Then _IEAction($oInput, "click")
               Next

               sleep(2000)


   EndSwitch
WEnd
EndFunc

So as you can see at the end of the code, I inserted your code. But AutoIt gives me this error:

--> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IETagNameGetCollection, $_IESTATUS_InvalidDataType
"C:\Users\Admin\Desktop\My Programs\YTMonster Bot\YTMonster bot.au3" (87) : ==> Variable must be of type "Object".:
For $oInput In $oInputs
For $oInput In $oInputs^ ERROR
>Exit code: 1    Time: 46.46

Link to comment
Share on other sites

1 minute ago, Juvigy said:

Of course. It depends what exactly you want to do. It just illustrates how to attach to " 2 windows with the same "

Sorry for posting 2 posts quickly after each other, please read my previous post.

Link to comment
Share on other sites

This is because my code attaches to the windows , display the urls and then set the object to 0. So you need to put an IF inside and when the attached window is the right one - to return the IE object and exit the loop. Post the URLs that my code produces and tell me to which one you want to attach

Link to comment
Share on other sites

5 minutes ago, Juvigy said:

This is because my code attaches to the windows , display the urls and then set the object to 0. So you need to put an IF inside and when the attached window is the right one - to return the IE object and exit the loop. Post the URLs that my code produces and tell me to which one you want to attach

Your code produces those two links:

https://www.ytmonster.net/download
0x00090B5C
https://www.ytmonster.net/download
0x00090B5C

(which are the same)

That link is the link before it clicks on the button. The button has this url https://www.ytmonster.net/client/

Edited by ssah8
Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("YTMonster | Bot", 330, 245, 192, 124)
$Group1 = GUICtrlCreateGroup("Login", 0, 0, 137, 169)
$username = GUICtrlCreateInput("Username", 8, 48, 121, 21)
$password = GUICtrlCreateInput("Password", 8, 80, 121, 21)
$Login1 = GUICtrlCreateButton("Login", 8, 112, 123, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Start", 136, 0, 185, 169)
$Pic1 = GUICtrlCreatePic("C:\Users\Admin\Desktop\147863078766323.jpg", 144, 16, 172, 52)
$start = GUICtrlCreateButton("Start", 144, 80, 171, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Points", 8, 176, 169, 65)
$points1 = GUICtrlCreateLabel("0", 16, 200, 15, 29)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("Made by DanCodes", 192, 200, 98, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
logintosite()

Func logintosite()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Login1
            Global $oIE = _IECreate("https://www.ytmonster.net/login")

            $username1 = GUICtrlRead($username)
            $password1 = GUICtrlRead($password)

            $emailform = _IEGetObjByName($oIE, "usernames")
            $usernameform = _IEGetObjByName($oIE, "passwords")


            _IEFormElementSetValue($emailform, $username1)
            _IEFormElementSetValue($usernameform, $password1)


            Case $start

               Local $oInputs = _IETagNameGetCollection($oIE, "button")
               For $oInput In $oInputs
                  If $oInput.classname == "btn btn-success" Then _IEAction($oInput, "click")
               next

               sleep(10000)

               _IENavigate($oIE, "https://www.ytmonster.net/download")

               sleep(3000)

               Local $oInputs = _IETagNameGetCollection($oIE, "div")
               For $oInput In $oInputs
                  If $oInput.classname == "btn btn-large btn-primary" Then _IEAction($oInput, "click")
               Next

               sleep(3000)
               
               Local $i = 1
               While 1
                  $oIE2 = _IEAttach("", "instance", $i)
                  If @error = $_IEStatus_NoMatch Then
                     $oIE = 0
                     ExitLoop
               EndIf
               ConsoleWrite(_IEPropertyGet($oIE2, "locationurl") &@CRLF)
               ConsoleWrite(_IEPropertyGet($oIE2, "hwnd") &@CRLF)
               $i += 1
               WEnd

               Local $oInputs = _IETagNameGetCollection($oIE, "button")
               For $oInput In $oInputs
                  If $oInput.classname == "button blue" Then _IEAction($oInput, "click")
               Next
            
               Local $oInputs = _IETagNameGetCollection($oIE2, "div")
               For $oInput In $oInputs
                  If $oInput.classname == "btn btn-success btn-sm" Then _IEAction($oInput, "click")
               Next

               sleep(2000)


   EndSwitch
WEnd
EndFunc

I changed the placement of your code. Because I want to interact with the first popup. At that popup, there is another button, that if clicked, it opens up a YouTube video to like. So, I need to paste your code after the popup aswell, to get the handle of the next popup. All this sounds so confusing xD

Output still the same, so, here is the output you asked for:

https://www.ytmonster.net/download
0x001E09E0
https://www.ytmonster.net/client/ssah8
0x000E0BC4
--> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch

The first one is before it clicks the first button. The second is the first popup (which I want to interact with).

Link to comment
Share on other sites

OK , so check with my code before you click the button and save the handles of the existing windows. After you click the button check again - you will have one more compared to the first list. That is the one you need. So if when you first check you have 2 windows with handles 1='xxxxx' , 2 = 'yyyyy' and then you have 3 windows windows with handles 1='xxxxx' , 2 = 'yyyyy' , 3 'zzzzzz' - compare the 2 arrays and attach to the unique element 'zzzzz'. I am not sure , but it may be easier to attach to the last element on the second check. I think the newest window is always last - test that to verify!

Link to comment
Share on other sites

That's easy;

Local $i = 1
While 1
    $oIE = _IEAttach("","instance", $i)
    If @error = $_IEStatus_NoMatch Then
        $oIE = 0
        ExitLoop
    EndIf
    ConsoleWrite(_IEPropertyGet($oIE, "locationurl") &@CRLF)
    $i += 1
WEnd
$oIE = _IEAttach("", "instance", $i-1)
ConsoleWrite(_IEPropertyGet($oIE, "locationurl") &@CRLF)

 

Link to comment
Share on other sites

  • Moderators

As the OP has been banned from the forum, and was pursuing a line of questioning against the forum rules, I am locking this thread.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...