Sign in to follow this  
Followers 0
ssah8

2 windows with same name

38 posts in this topic

Hello.

I am trying to attach a window, but the problem is that there is already another window with the exakt same title. How do I do that?

(_IEAttach)

Share this post


Link to post
Share on other sites



How do I get the window handle? And how would the _IEAttach look like?

Share this post


Link to post
Share on other sites

WinGetHandle is one way.  You'll need to find someway to distinguish between the windows if they have the same name by say checking contents of window (controls and data) Try searching for some examples.

According to the help file article for _IEAttach(), the second parameter allows you to select the "mode" of operation,  So, by providing the window handle as the first param and providing the string "hwnd", guess what should happen?

Share this post


Link to post
Share on other sites

Where do I see the handle in the window info tool?

Share this post


Link to post
Share on other sites

$oIE2 = _IEAttach(0x00000000001A0C30, "embedded", 0)

This gives me this message:

"C:\Users\Admin\Desktop\backup.au3" (74) : ==> Variable must be of type "Object".:
For $oInput In $oInputs
For $oInput In $oInputs^ ERROR

 

Share this post


Link to post
Share on other sites

Post a screenshot of the AutoIt Window Info tool when you hover over the window in question.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

There might be a problem in the code, that screws up everything. I can paste the whole program here:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.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

               $oIE2 = _IEAttach(0x00000000001A0C30, "embedded", 0)

               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

Now, with the new GUI, this error pops out, which is really weird

Unknown function name.:
Global $oIE = _IECreate("https://www.ytmonster.net/login")
Global $oIE = ^ ERROR

Edited by ssah8
Changed the GUI

Share this post


Link to post
Share on other sites

Can anyone reply?

Share this post


Link to post
Share on other sites

ssah8,

Please do not bump your own threads within 24 hours.

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare.  You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online.  Be patient and someone will answer eventually.  Or if not - tough!

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
1 minute ago, Melba23 said:

ssah8,

Please do not bump your own threads within 24 hours.

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare.  You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online.  Be patient and someone will answer eventually.  Or if not - tough!

M23

 

Didn't think about that, sorry.

Share this post


Link to post
Share on other sites
2 hours ago, ssah8 said:

Unknown function name.:
Global $oIE = _IECreate("https://www.ytmonster.net/login")
Global $oIE = ^ ERROR

Looks like you forgot an include ...

Share this post


Link to post
Share on other sites
1 minute ago, mikell said:

Looks like you forgot an include ...

Haha, yeah, oh im stupid xD

Share this post


Link to post
Share on other sites

Now, the main question still remains unanswered.

Due there have been many questions, I will clarify what my main is:

#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

               $handle = 0x00000000001A0C30

               $oIE2 = _IEAttach(0x00000000001A0C30, "embedded", 0)

               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

That is the code, the whole code, the whole program (far away from finished). In order for me to move on, I have to get past the _IEAttach problem. 

This is what I currently have: $oIE2 = _IEAttach(0x00000000001A0C30, "embedded", 0)

This is of course not the right way, that's why AutoIT crashes on me. Now, can anyone please tell me what's wrong with the _IEAttach line? It's probably something very simple.

Share this post


Link to post
Share on other sites

The handle you are providing to the _IEAttach function is dynamic (it should change each execution at runtime).  You'll need a method to get the handle of the new window each time.

5 hours ago, spudw2k said:

WinGetHandle is one way.

If there isn't an easy way to distinguish between the "parent" and new IE windows within the confines of the function above you may have to get fancy and do some running process analysis.

Share this post


Link to post
Share on other sites

So could you provde we with an example on how to get the handle of a specific browser window?

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Similar Content

    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
      Brian
    • BlazerV60
      By BlazerV60
      Hello all,
      I've been trying to figure out how to launch Google Chrome in the background (hidden) but it doesn't seem possible. I've tried the following methods:
      ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", "", "", @SW_HIDE) Also I've tried:
      ShellExecute(@ComSpec, "/c start chrome.exe","","",@SW_HIDE) Lastly I tried:
      RunWait('"'&@ProgramFilesDir&'\Google\Chrome\Application\chrome.exe" --silent-launch',@ScriptDir)  
      But all of them launch my chrome browser without hiding it. Does anyone know a workaround for this or if AutoIT just can't Chrome? 
      Bonus points if you know how to make it launch chrome hidden and make it go to https://www.autoitscript.com
       
      Thank you,
      Brian
    • BOUNCER
      By BOUNCER
      I'm trying to get the output data from https://www.guilded.gg but it uses a web app that generates that output on the fly and this doesn't show up in the page source.
      Only in web inspector of each browser does this data show up. How do I read this data in autoit (equivalent to the web inspector)
       
      thank you
    • ur
      By ur
      We can select elements in IE using their IDs as below.
      Local $oDiv = _IEGetObjById($oIE, "x-auto-16-input") But to one button in the webpage, there is no ID to it.
      In selenium we have option to select this element using the CssSelector and clicked the button using below code in c# selenium.
      driver.FindElement(By.CssSelector("button.x-btn-text")).Click(); What is the alternative for this in AUtoIT?
    • whiskas
      By whiskas
      Hi all,
      I just upgraded to windows 10 and am using Edge as my browser now. Updated my scripts, but I can not unhide a minimized Edge window with the script anymore.
      WinSetState ( "titlle","", @SW_MAXIMIZE ) works fine, but not if it is minimized. Tried same with SW_SHOW, doesn't work.
      WinExists("title","") -> returns 1, so it is finding my window.
       
              WinWait($title,$text,$timeout)
              If Not WinActive($title,$text) Then WinActivate($title,$text)
              WinWaitActive($title,$text,$timeout)
      Doesn't work also, so I think I tried all but cant get the window back
      Any help would be appreciated