Jump to content

How can I change this function to have IE start hidden?


Recommended Posts

This is the function I've written so far

Func _IECreateNew($s_url = "about:blank", $invisible = 0)
    ; Create an IE browser in a new process, attach to it and navigate to specified URL
    ; Returns browser object on success
    ; Returns 0 on failure and sets @error to 1 (timeout waiting for browser)  or 2 (attach failed)

    Local $h_IEhandle, $o_IE
    Local $Random1 = Random(100000, 999999, 1)
    Local $Random2 = Random(100000, 999999, 1)
    If $invisible Then
        ;;;;
    Else
        Local $RunWebsite = Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe about:blank" & $Random1 & "-" & $Random2 & " -noframemerging -private")
    EndIf

    If Not WinWait("Navigation Canceled - Internet Explorer - [InPrivate]", "", 60) Then ; Expected IE window did not appear
        Return SetError(1, 0, 0)
    EndIf

    ;$h_IEhandle = WinGetHandle("Navigation Canceled - Internet Explorer - [InPrivate]")
    Do
        $o_IE = _IEAttach("about:blank" & $Random1 & "-" & $Random2, "url")
        Sleep(250)
    Until IsObj($o_IE)

    _IENavigate($o_IE, $s_url)
    Return $o_IE
EndFunc   ;==>_IECreateNew

What can I do to make it start off hidden??

Link to comment
Share on other sites

6 hours ago, AutoBert said:

Use the showflag in run func or after you have the object variable of IE set visible to false:

$oIE.visible = False

 

$RunWebsite.visible = False

Doesn't work

What would I replace '$oIE' or '$RunWebsite' with

 

EDIT

I fixed it by 

    If $invisible Then
        $o_IE.visible = False
    EndIf

After I attach to the browser, but this way, the IE still flashes open for a sec. I want it to OPEN hidden, not turn hidden after being opened.

Edited by Dgameman1
Link to comment
Share on other sites

What I've been able to find, is that if you run this command through powershell, a hidden IE window will open and navigate to a certain page.

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://launchurl")
Link to comment
Share on other sites

On 4/2/2016 at 10:23 AM, Dgameman1 said:

What I've been able to find, is that if you run this command through powershell, a hidden IE window will open and navigate to a certain page.


$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://launchurl")

You can do the same thing with IECreate. But i dont see here to start it with the parameters. In the above example where do you put the parameters ?

Link to comment
Share on other sites

Just now, Juvigy said:

You can do the same thing with IECreate. But i dont see here to start it with the parameters. In the above example where do you put the parameters ?

I already wrote why I'm not able to do this with IECreate.

I also already wrote where I put the above code. 

 

On 4/2/2016 at 0:23 AM, Dgameman1 said:

What I've been able to find, is that if you run this command through powershell, a hidden IE window will open and navigate to a certain page.


$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://launchurl")

 

Link to comment
Share on other sites

43 minutes ago, Juvigy said:

The above code in PS does exactly what IECREATE would do - i dont see where and how you put the parameters like in this PS

-noframemerging -private

What...?

How would I go about doing that in IECREATE then?

And I posted saying

What I've been able to find, is that if you run this command through powershell, a hidden IE window will open and navigate to a certain page.

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://launchurl")

 

Lmao, are you even reading my posts?

Link to comment
Share on other sites

17 hours ago, JohnOne said:

Is there a reason why you don't just start IE with powershell command and then attach to it?

Because I can't figure out how to do it correctly :>

The following AutoiIt code opens up IE already hidden.

Run("powershell.exe -Command New-Object -com internetexplorer.application")

I don't know how to navigation and the 

-noframemerging -private

parameters in that same line though.

Making it navigate in the same line is

Run("powershell.exe -Command   Start-Process -FilePath 'C:\Program Files\Internet Explorer\iexplore.exe ' 'http://www.google.com'")

But that doesn't start IE as hidden

Edited by Dgameman1
Link to comment
Share on other sites

Are you reading mine ? This PS code :

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://launchurl")

Is the same as the Autoit code:

_IECreate("http://launchurl",0,0,0,0)

 

Link to comment
Share on other sites

10 hours ago, Juvigy said:

Are you reading mine ? This PS code :

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://launchurl")

Is the same as the Autoit code:

_IECreate("http://launchurl",0,0,0,0)

 

Yes. I understand. I've said multiple times that I clearly understand what you're saying. I'm the one that even wrote about it first.

I said...

What I've been able to find, is that if you run this command through powershell, a hidden IE window will open and navigate to a certain page.

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://launchurl")

No where did I say that, that was the answer to my problem. All I said was that's what I was able to figure out with PowerShell. Not that this is what I wanted to do.

So, If you're clearly hell bent on telling me that _IECreate can do this, please, show me how I can use _IECreate to create a browser that starts off HIDDEN, (Not becomes hidden after it opens, like others have kept telling me to do), with the parameters 

-noframemerging -private

 

Thanks!

Link to comment
Share on other sites

1 hour ago, JohnOne said:

When I do that code in powershell, it does indeed start hidden, but as soon as navigate, it becomes visible.

This is what i was able to come up with so far

$PowerShellCommand = "Start-Process -WindowStyle Hidden -FilePath 'C:\Program Files\Internet Explorer\iexplore.exe' 'google.com -noframemerging -private'"

Run("powershell.exe -Command " & $PowerShellCommand)

The issue with this is that the -WindowStyle Hidden doesn't work, but that's a powershell issue. And now powershell is visible lol. I don't want anything visible

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...