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.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

https://gyazo.com/7b019a2821887e6fd25552eb9d4cab0f

To save you the time instead of needed to check if the website doesn't allow bots, I have already checked. It doesn't have any rules against it.

Edited by ssah8

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

#12 ·  Posted

Can anyone reply?

Share this post


Link to post
Share on other sites

#13 ·  Posted

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

#14 ·  Posted

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

#15 ·  Posted

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

#16 ·  Posted

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

#17 ·  Posted

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

#18 ·  Posted

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

#19 ·  Posted

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

    • rusdady
      Browser (IE) HTML document ready event
      By rusdady
      Hi.
      Is there a way in autoit script to wait while browser's html document fully loaded, instead of putting script in Sleep?
      I have this code:
              
      Sleep(8000) $oDocument=_UIA_getFirstObjectOfElement($oIE,$cDocumentWindow, $treescope_subtree) Sleep(8000) If not isobj($oDocument) Then _UIA_DumpThemAll($oIE,$treescope_subtree) Else ...... EndIf  
      I do not like this - Sleep(8000). Sometimes it takes 2 seconds to load, sometimes it takes over 8 seconds...
      I would like to have something that would wait when html document is ready/loaded.
      Thank you.
    • pecsenye
      Hide IE browser forever
      By pecsenye
      Hello,
      I have a script, its working well.
      When I start running the script the random website is loading and then the browser is hiding. (That's OK for me.)
      Then the script is sleeping for a random time. (That's OK for me.)
       
      My problem is:
      After the next website is loading, then the browser is visible again. I can see the browser for a few moments. (until the website is finish the loading.)
       
      My question is:
      How can I solve this problem? (Hide IE browser forever :))
       
      Code:
                              Global $var[4]
                              $var[1] = "http://google.com"
                              $var[2] = "http://google.com"
                              $var[3] = "http://google.com"
                              $x = Random(1, 3, 1)
                              ShellExecute($var[$x])
                              Local $hWnd = WinWait("[CLASS:IEFrame]", "Google", 10)
                              WinSetState($hWnd, "", @SW_HIDE)
                              Sleep(Random(5000, 8000, 1))
                            Global $var[4]
                              $var[1] = "http://google.com"
                              $var[2] = "http://google.com"
                              $var[3] = "http://google.com"
                              $x = Random(1, 3, 1)
                              ShellExecute($var[$x])
                              Local $hWnd = WinWait("[CLASS:IEFrame]", "Google", 10)
                              WinSetState($hWnd, "", @SW_HIDE)
                              Sleep(Random(5000, 8000, 1))
       
      Thanks for  helping!
       
    • confuseis
      Dealing with unexpected pop up windows
      By confuseis
      Hi
      Im looking to open a web site in internet explorer.  Sometimes though other pop up windows appear and interfere.  In Internet explorer for example a pop up "Welcome to Internet Explorer 8"  will occur and this throws things off as I want to send text into web page after it opens.
      To counter this I am running internet explorer with extensions off to stop these windows from appearing but with mixed success.
      I need to be certain I can open internet explorer and search this web page, and send/enter a string of text into that web page. withot other Internet explorer sub windows throwing things off.,
      In the below example I am reading a sting of text from a text file and entering it into internet explorer.   This works sometimes and not others due to unforeseen windows spawining.
      If you know anything drop me a line
      Thanks 
      Confuseis
      #include <array.au3>
      #include <file.au3>
      #include <MsgBoxConstants.au3>
       
      run("C:\Program Files\Internet Explorer\iexplore.exe -extoff -noframemerging https://some.website.com")
      ; read the username from the preexisting text file
      Local Const $sFilePath = "\scripts\TextInput.txt"
      Local $hFileOpen=FileOpen($sFilePath, $FO_Read)
      Local $sFileRead=FileReadLine($hFileOpen, 1)
      FileClose($hFileOpen)
      Sleep(2000)
      Send($sFileRead)
    • drego
      NetSession UDF ~ Per-Process Embedded Browser Settings (Proxy/Agent/Etc.)
      By drego
      NetSession UDF 0.9d
      (Set embedded browser Internet options on a per-process basis)
       
      Welcome to NetSession UDF! With this UDF we provide you with previously unexposed Internet options for your autoit processes which will apply to embedded browser controls created with _IECreateEmbedded. For instance, you can now set a proxy and user-agent for all for your Autoit application's embedded browsers without using the registry settings. This means that you can now have multiple proxy settings for multiple programs/processses, giving each process it's own proxy/agent/other settings for your embedded browser controls and change them within each application as many times as you like. In other words, dynamic per-program (Not shared) Internet settings for any application containing an embedded browser control. There's also a function to clear all of your browser's cookies as well as all flash cookies.
      Versions:
      Version 0.9 includes the ability to set an HTTP/SOCKS4/SOCKS5 proxy and browser agent for individual AutoIt processes that can all be running at the same time with different settings. This is easy to use. This UDF started out as code that I worked on years ago and now we're bringing it back to life as a UDF with new features planned. Version 0.9b now has the new _ClearCookies function which will remove all IE and Flash cookies. Version 0.9c has added the "#include-once" directive as a UDF should and an optimization to the _ClearCookies function thanks to jdelaney. _ClearCookies has also been changed to return TRUE or FALSE rather than strings, not pause script execution when deleting IE cookies, and the hidden window flag added for Its shell command. Version 0.9d has the added function _UseTOR. This release comes just minutes after the last release because it slipped my mind that it was on the Planned Features list and is easy to add. This new function simply envokes _SetProxy with the proper parameters for TOR with the option to change the port if your install of TOR isn't using the default port number; otherwise, no parameter is necessary. This will likely be the last release until we have more updates to the DLL/Windows API calls.  
      At the moment this UDF makes use of urlmon.dll to apply settings to your application executables. Our goal is to expose all functionality of this DLL as well as possibly expand into more functionality using other Windows API elements.
      Important: If you wish to change the settings of an IE control more than once during the life if your program you might have to refresh the IE control or GUI of your app before applying the next change. This was the case years ago. I'll do some testing on this and publish an update to the UDF or add an example of a refresh to the Example Usage.
      Example usage & notes:
      #include <NetSession-0.9d.au3> ; Let's include IE.au3 just for this example assuming you're making an embedded browser. #include <IE.au3> ; In this example you would create your embedded IE object and use as follows. _SetProxy('108.247.158.12:8080') ; Now your proxy is set. This would be an HTTP proxy. For SOCKS you would use: _SetProxy('socks=108.247.158.12:1080') ; Or if you have TOR running and would like to use it as your proxy simply use: _UseTOR() ; But if your TOR isn't running on default port 9150 (Like if you changed it to 9292) you must specify your TOR port: _UseTOR(9292) ; The following is an example of setting your user agent: _SetUserAgent('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36') ; At this point any browsing you perform will use the previously set proxy and user agent. Such as: _IENavigate($ie,"http://www.ipchicken.com") ; If your proxy or SOCKS requires authentication you would add the proxy auth to the URL like this: _IENavigate($ie,"http://ProxyUser:ProxyPass@www.ipchicken.com") ; Let's clear all browser & Flash cookies _ClearCookies() ; Note that you can change these settings as many times as you need to in your application and these ; settings will only be applied to the .exe they were set from. This means you don't have to change ; the system-wide proxy or user-agent settings and can have per-.exe embedded browser settings. I welcome anyone who wants to contribute. Any suggestions will be much appreciated.
      The UDF NetSession-0.9d.au3 is attached to this post. The filename will always reflect the version number and this thread post will be kept up to date. I've chosen 0.9 because at this point we only need to figure out one more thing to consider it a complete 1.0. Version 1.0 will include an advanced authentication mechanism for proxies and socks servers (Better than passing proxy auth via the URL). The reason we want to use the authentication capabilities of the DLL is because when you pass authentication via the URL you can't access HTTPS sites through the proxy (You can if no proxy auth is required).
      If you can help make this UDF better by improving authentication as just previously mentioned or add any other functionality PLEASE don't hesitate to reply to this thread with some code. Here are the references to how this UDF came about and where you would look to help improve it:
      http://msdn.microsoft.com/en-us/library/ms775125%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa385148%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa385328%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa383630%28v=vs.85%29.aspx http://support.microsoft.com/kb/226473  
      Current Functions:
      _SetProxy(string $Proxy) - Sets an HTTP or SOCKS server for embedded IE browsers in the current process. _SetUserAgent(string $Agent) - Sets the user/browser agent for embedded IE browsers in the current process. _ClearCookies() - Deletes all IE and system Flash cookies. Returns a Boolean value. _UseTOR(int $TORPort = 9150) - Sets TOR as your proxy. You must have TOR running. $TORPort is only necessary if your TOR isn't using default 9150. TOR can be downloaded here: https://www.torproject.org/download/download-easy.html Planned Features:
      Proxy authentication via DLL rather than passing to URL. Function to set HTTP referrer. Support for other (Non-IE) embedded browsers. An ease-of-use function for setting TOR as the proxy server (This can currently be done manually). (Done) Compatability: All known versions of Windows since 2000/XP (Possibly earlier versions as well). Note: The settings applied by this UDF do not appear to affect functions such as InetGet. For those functions you would want to use HttpSetProxy. This UDF is for browser controls (which HttpSetProxy does not affect). Also, the browser must be embedded into the application as with _IECreateEmbedded. It will not work with a new window created with _IECreate.
      System Requirements:
      The existance of urlmon.dll on the system usually located in WindowsSystem32 Releases:
      NetSession-0.9.au3 {OLD}
      NetSession-0.9b.au3 {OLD}
      NetSession-0.9c.au3 {OLD}
      NetSession-0.9d.au3 {Newest}
          The changes in each version are detailed near the top of this post.
      !!! WE NEED HELP FOR THE NEXT RELEASE !!!
      Here's our current (not working) attempt to use a proxy's username & password without passing it in the URL. Without this capability we can't browse to HTTPS sites if proxy auth is required:

       Please help if you can 
      Happy coding!
    • 4b0082
      Working in Hidden Browser Windows
      By 4b0082
      I'm trying to create a pretty simple program that checks for a specific string of text on a website every couple of minutes, but I've never worked with hidden browsers before and I'm not sure how to go about doing it.
      My script's going to follow this basic programming:
      Open website. Scan for text. If text is found, open alert window. If text isn't found, wait five minutes and scan again. I just want this to actively monitor a website in the background, but up to this point all of my experience is working with visually active, directly engaged windows. I want this program to essentially be invisible until it detects that string of text without interfering with anything else I'm doing.

      Can someone point me in the right direction?