camilla Posted January 26, 2014 Share Posted January 26, 2014 hi everybody, i'm codding a test script to run a default web browser in hidden mode then show it and this is my code : Func _GetDefBrowser() Local Static $s_reg = RegRead("HKCRhttpshellopencommand", "") Return StringRegExpReplace($s_reg, "(.*?x22)(.*?[/])*(.*?)(x22.*?z)", "$3") EndFunc Hidshow() Func Hidshow() shellexecute(_GetDefBrowser(),'-new-window "www.autoitscript.fr"',"","",@SW_HIDE) ; Wait 1 seconds for the Target link window to appear. Local $hWnd = WinWait("[CLASS:MozillaWindowClass]", "", 10) Local $hWnd = WinWait("[CLASS:Chrome_WidgetWin_1]", "", 10) Local $hWnd = WinWait("[CLASS:IEFrame]", "", 10) ; Wait for 5 seconds Sleep(50000) ; Set the state of the Target link window to "show". WinSetState($hWnd, "", @SW_SHOW) ; Wait for 2 seconds. Sleep(2000) ; Close the Target link window using the handle returned by WinWait. WinClose($hWnd) EndFunc ;==>end this code works with Firefox but it fails with chrome it didn't hide the GUI any idea thank you in advance for youur help Link to comment Share on other sites More sharing options...
camilla Posted January 26, 2014 Author Share Posted January 26, 2014 any idea???? Link to comment Share on other sites More sharing options...
camilla Posted January 26, 2014 Author Share Posted January 26, 2014 i think there is a bug in Autoit even this code doesn't run google chrome in hidden ShellExecute("C:UsersMypcAppDataLocalGoogleChromeApplicationchrome.exe " , " http:/www.google.fr", "", "", @SW_HIDE) 43 views with no answers Link to comment Share on other sites More sharing options...
Terenz Posted January 26, 2014 Share Posted January 26, 2014 (edited) If someone want to just to read is a problem for you? It's not a bug of autoit, chrome spawn more then one process. This work for me: _Start_Minimized_Chrome() Sleep(2000) _Maximize_Chrome() Func _Start_Minimized_Chrome() Run(@ScriptDir & "\chrome.exe") WinWait("[CLASS:Chrome_WidgetWin_1]", "") Local $WinList = WinList() For $i = 1 To $WinList[0][0] If $WinList[$i][0] <> "" And StringInStr($WinList[$i][0], " - Google Chrome", 1) Then WinSetState($WinList[$i][1], "", @SW_MINIMIZE) Next EndFunc ;==>_Start_Minimized_Chrome Func _Maximize_Chrome() WinSetState("[CLASS:Chrome_WidgetWin_1]", "", @SW_MAXIMIZE) EndFunc ;==>_Maximize_Chrome Replace minimize and maximize with what you need EDIT: Don't "bump" your post multiple time in a day or Melba will be angry Edited January 26, 2014 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
camilla Posted January 27, 2014 Author Share Posted January 27, 2014 (edited) Terenz If someone want to just to read is a problem for you? It's not a bug of autoit, chrome spawn more then one process. This work for me: thank you for your answer ,but it doesn't work for me this is my code: #include<_GetDefBrowser.au3> _Start_Minimized_Chrome() Sleep(2000) Func _Start_Minimized_Chrome() shellexecute(_GetDefBrowser(),' "www.autoitscript.fr"',"","",@SW_HIDE) WinWait("[CLASS:Chrome_WidgetWin_1]", "") Local $WinList = WinList() For $i = 1 To $WinList[0][0] If $WinList[$i][0] <> "" And StringInStr($WinList[$i][0], " - Google Chrome", 1) Then WinSetState($WinList[$i][1], "", @SW_HIDE) Next EndFunc ;==>_Start_Minimized_Chrome i did Replace minimize and maximize with what you need ( @SW_HIDE) and it didn't work and chrome still run normal Edited January 27, 2014 by camilla Link to comment Share on other sites More sharing options...
Terenz Posted January 27, 2014 Share Posted January 27, 2014 (edited) Is strange. Try with this "debug" code: _Start_Minimized_Chrome() Func _Start_Minimized_Chrome() ShellExecute(@ScriptDir & "\chrome.exe", ' "www.autoitscript.fr"') WinWait("[CLASS:Chrome_WidgetWin_1]", "") Local $WinList = WinList() For $i = 1 To $WinList[0][0] If $WinList[$i][0] <> "" And IsVisible($WinList[$i][0]) Then ConsoleWrite("Title=" & $WinList[$i][0] & @LF & "Handle=" & $WinList[$i][1] & @CRLF) $case = MsgBox(4+262144, "Details", "Do you want to hide this window? " & @CRLF & "Title=" & $WinList[$i][0] & @LF & "Handle=" & $WinList[$i][1]) Switch $case Case 6 ; Yes WinSetState($WinList[$i][1], "", @SW_HIDE) ExitLoop Case 7 ;No ContinueLoop EndSwitch EndIf Next EndFunc ;==>_Start_Minimized_Chrome Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Return 0 EndFunc ;==>IsVisible If i click Yes for this window: Title=No Title - Google Chrome Handle=0x001D031A It will be correcty hidden, for this reason i have used StringInStr with " - Google Chrome", the handle is always different Check what name work for you Edited January 27, 2014 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
JohnOne Posted January 27, 2014 Share Posted January 27, 2014 (edited) I don't know about hiding the window, but if you want to visit a site with default browser then, it's as simple as... ShellExecute("http://domain.ext") The way you appear to be trying it, you might have better luck starting hidden with Run() function. Edited January 27, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
camilla Posted January 27, 2014 Author Share Posted January 27, 2014 JohnOne thank you ,but i know how to visite a site Terenz still not working just install chrome and try the code and you will see the result thank for your help Link to comment Share on other sites More sharing options...
Terenz Posted January 27, 2014 Share Posted January 27, 2014 camilla lol do you think i don't have try it before post? Both work on my system and sure i have chrome installed. Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
camilla Posted January 27, 2014 Author Share Posted January 27, 2014 lol, i'm using win7 x86 and they are not work chrome run in normal mode using your first script or second one even if i clicked on yes on your second code chrome still run normal and it is not hide Link to comment Share on other sites More sharing options...
mikell Posted January 27, 2014 Share Posted January 27, 2014 (edited) Maybe you can use this brute trick to get the title of the future window before launching the browser #include <WinAPIShellEx.au3> ;Opt("WinTitleMatchMode", 2) ;HttpSetUserAgent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)") $txt = BinaryToString(InetRead("http://www.google.fr", 4)) ;$txt = BinaryToString(InetRead("http://www.autoitscript.fr", 4)) $title = StringRegExpReplace($txt, '(?s).+<title>([\w\h]+).+', "$1") _WinAPI_ShellExecute(_GetDefBrowser(), " http://www.google.fr", "", "", @SW_HIDE) ;_WinAPI_ShellExecute(_GetDefBrowser(), " http://www.autoitscript.fr", "", "", @SW_HIDE) $hWnd = WinWait($title) msgbox(0,"", "the window " & $title & " is hidden") Sleep(2000) msgbox(0,"", "and now show it" ) WinSetState($hWnd, "", @SW_SHOW) Func _GetDefBrowser() Local Static $s_reg = RegRead("HKCR\http\shell\open\command", "") Return StringRegExpReplace($s_reg, "(.*?\x22)(.*?[\\/])*(.*?)(\x22.*?\z)", "$3") EndFunc BTW here ShellExecute doesn't work with @SW_HIDE but _WinAPI_ShellExecute does Edited January 27, 2014 by mikell Link to comment Share on other sites More sharing options...
Bert Posted January 27, 2014 Share Posted January 27, 2014 You can simply specify the code to run in IE. That way you don't have to worry about other web browsers. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
camilla Posted January 27, 2014 Author Share Posted January 27, 2014 mikell thank you for your help,but i'm unlucky it oesn't work for me too MBALZESHARI Yeah, that was my solution to this problem. if the default browser is chrome than try to run firefox if it is not installed try to run in explorer IE Link to comment Share on other sites More sharing options...
Bert Posted January 28, 2014 Share Posted January 28, 2014 Just run it in IE no matter what. IE is on just about every machine anyway so it would be easy to do it if you just use one browser. 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