BobbyBao Posted November 5, 2009 Share Posted November 5, 2009 (edited) Hello guys, I am a beginner of AutoIt, but have become an AutoIt lover I'v written some simple code about opening a new IE window and losing focus subsequently: $oIE = _IECreate($url) _IELoadWait ($oIE, 0, 10000) $oIE.Blur() but an error appears as below: ==> The requested action with this object has failed.: $oIE.Blur() $oIE.Blur()^ ERROR >Exit code: 1 Time: 16.601 I have tried the function _IEAction($oIE, "blur") as well which caused the same error. Can anybody know how to fix problem up? Thanks! Bobby Edited November 5, 2009 by BobbyBao Link to comment Share on other sites More sharing options...
BrettF Posted November 5, 2009 Share Posted November 5, 2009 Welcome to the forums. I'm not sure how you are meant to loose focus to the whole window like that, but maybe you should try WinSetState? Blur should only work on a control object, if my understanding of it is correct. If you want to start it hidden just use the following _IECreate line by changing $f_visible to = 0. Like so: _IECreate ("www.autoitscript.com", 1, 1, 0) Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
BobbyBao Posted November 5, 2009 Author Share Posted November 5, 2009 Welcome to the forums.I'm not sure how you are meant to loose focus to the whole window like that, but maybe you should try WinSetState? Blur should only work on a control object, if my understanding of it is correct.If you want to start it hidden just use the following _IECreate line by changing $f_visible to = 0. Like so:_IECreate ("www.autoitscript.com", 1, 1, 0)Hi Brett,Thank you for that quick response Sorry if I'm being a bit dense...I just want to open up a new IE window at background without getting focus rather than hidding it. The focus should only be left on my current working stuff. Is there any better way to do that?Regards,Bobby Link to comment Share on other sites More sharing options...
exodius Posted November 5, 2009 Share Posted November 5, 2009 I'm not sure that you can do that directly with AutoIt... Although you could inject some javascript into the page to make it a pop-behind window. http://javascript.internet.com/page-details/go-behind-popup.html Link to comment Share on other sites More sharing options...
BrettF Posted November 5, 2009 Share Posted November 5, 2009 Hows this go for you? expandcollapse popup#include <IE.au3> #Include <Array.au3> $iPID = -1 $sURL = "www.google.com" $old_list = ProcessList ("iexplore.exe") $oIE = _IECreate ($sURL) $new_list = ProcessList ("iexplore.exe") For $i = 1 to $new_list[0][0] $afound = _ArraySearch ($old_list, $new_list[$i][1]) If @error Then $iPID = $new_list[$i][1] ExitLoop EndIf Next $hWnd = _GetHwndFromPID($iPID) ;MINIMIZE WinSetState($hWnd, "", @SW_MINIMIZE) Func _GetHwndFromPID($PID) $hWnd = 0 $winlist = WinList() Do For $i = 1 To $winlist[0][0] If $winlist[$i][0] <> "" Then $iPID2 = WinGetProcess($winlist[$i][1]) If $iPID2 = $PID Then $hWnd = $winlist[$i][1] ExitLoop EndIf EndIf Next Until $hWnd <> 0 Return $hWnd EndFunc;==>_GetHwndFromPID Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jvanegmond Posted November 5, 2009 Share Posted November 5, 2009 Hows this go for you? expandcollapse popup#include <IE.au3> #Include <Array.au3> $iPID = -1 $sURL = "www.google.com" $old_list = ProcessList ("iexplore.exe") $oIE = _IECreate ($sURL) $new_list = ProcessList ("iexplore.exe") For $i = 1 to $new_list[0][0] $afound = _ArraySearch ($old_list, $new_list[$i][1]) If @error Then $iPID = $new_list[$i][1] ExitLoop EndIf Next $hWnd = _GetHwndFromPID($iPID) ;MINIMIZE WinSetState($hWnd, "", @SW_MINIMIZE) Func _GetHwndFromPID($PID) $hWnd = 0 $winlist = WinList() Do For $i = 1 To $winlist[0][0] If $winlist[$i][0] <> "" Then $iPID2 = WinGetProcess($winlist[$i][1]) If $iPID2 = $PID Then $hWnd = $winlist[$i][1] ExitLoop EndIf EndIf Next Until $hWnd <> 0 Return $hWnd EndFunc;==>_GetHwndFromPID #include <IE.au3> $sURL = "www.google.com" $oIE = _IECreate ($sURL) $hWnd = _IEPropertyGet($oIE, "hwnd") WinSetState($hWnd, "", @SW_MINIMIZE) github.com/jvanegmond Link to comment Share on other sites More sharing options...
BrettF Posted November 5, 2009 Share Posted November 5, 2009 #include <IE.au3> $sURL = "www.google.com" $oIE = _IECreate ($sURL) $hWnd = _IEPropertyGet($oIE, "hwnd") WinSetState($hWnd, "", @SW_MINIMIZE) Oh shh you... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Bert Posted November 5, 2009 Share Posted November 5, 2009 The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now