Sunaj Posted October 21, 2006 Share Posted October 21, 2006 Hi, trying to get the following code to work as expected, I just cannot seem to get the final parameter to work - no matter what I do the browser (IE) seem to start up on top?! I have looked at w0uter's _INetBrowse but is has the same problem for me. Reason why I use the DllCall instead of normal Run is that the code I'm writing needs to be able to adapt to different browsers installed on different computers.$s_URL = "http://www.autoitscript.com/" DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", 'open',"string", $s_URL, "string", '', "string", @WorkingDir, "long", @SW_MINIMIZE) [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
Developers Jos Posted October 21, 2006 Developers Share Posted October 21, 2006 (edited) You are not starting a program, but a file.. That means that : nShowCmd [in] Flags that specify how an application is to be displayed when it is opened. If lpFile specifies a document file, the flag is simply passed to the associated application. It is up to the application to decide how to handle it. Edited October 21, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Sunaj Posted October 21, 2006 Author Share Posted October 21, 2006 (edited) Ok, I see, just hadn't seen that nfo snippet. Thanks Now for the important part: Do you have any idea as to how to accomplish what I'm trying to do with having the default browser startup with a given URL in the background..?! You are not starting a program, but a file..That means that : Edited October 21, 2006 by Sunaj [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
PaulIA Posted October 21, 2006 Share Posted October 21, 2006 You are not starting a program, but a file..Actually, he is opening a web site, not a file. ShellExecute will use the extension of whatever is passed to it and determine the correct program to use to open it.Looking at the ShellExecute API:SW_MINIMIZE - Minimizes the specified window and activates the next top-level window in the Z order.SW_SHOWMINIMIZED - Activates the window and displays it as a minimized window.Have you tried passing SW_SHOWMINIMIZED instead of SW_MINIMIZE?I'm more used to using ShellExecuteEX, so you might want to take a look at that API call too. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
this-is-me Posted October 21, 2006 Share Posted October 21, 2006 Actually, you can use the new ShellExecute function in the beta version of AutoIt and you won't have to use DllCall at all. Who else would I be? Link to comment Share on other sites More sharing options...
Sunaj Posted October 21, 2006 Author Share Posted October 21, 2006 (edited) Hi PaulIA & this-is-me, hmm, yea, I tried all the various parameters incl. SW_SHOWMINIMIZED, still no party.. Anyways, I'll give ShellExecuteEX a look if I cannot get the new beta ShellExecute function that this-is-me mentioned to work! Guess this feature would be neat for many AutoIt developers btw..Actually, he is opening a web site, not a file. ShellExecute will use the extension of whatever is passed to it and determine the correct program to use to open it.Looking at the ShellExecute API:Have you tried passing SW_SHOWMINIMIZED instead of SW_MINIMIZE?I'm more used to using ShellExecuteEX, so you might want to take a look at that API call too. Edited October 21, 2006 by Sunaj [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
Sunaj Posted October 21, 2006 Author Share Posted October 21, 2006 Well, the new beta ShellExecute reacts exactly as a manual DllCall.. meaning this does not fix it.. starting to think that manual detection of browser from a registry key will yield better results. Anyone?Hi PaulIA & this-is-me, hmm, yea, I tried all the various parameters incl. SW_SHOWMINIMIZED, still no party.. Anyways, I'll give ShellExecuteEX a look if I cannot get the new beta ShellExecute function that this-is-me mentioned to work! Guess this feature would be neat for many AutoIt developers btw.. [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
this-is-me Posted October 21, 2006 Share Posted October 21, 2006 @Sunaj, do you have the browser running when you launch that script? Who else would I be? Link to comment Share on other sites More sharing options...
MHz Posted October 22, 2006 Share Posted October 22, 2006 This works _ShellExecute('iexplore', 'http://www.autoitscript.com/', '', 'open', @SW_MINIMIZE) Func _ShellExecute($filename, $parameters = '', $workingdir = '', $verb = 'open', $showflag = @SW_SHOWNORMAL) $aRet = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", $verb, _ "string", $filename, _ "string", $parameters, _ "string", $workingdir, _ "int", $showflag) Return SetError(@error, 0, '') EndFunc as it starts minimized but it is ignoring parameters passed. Link to comment Share on other sites More sharing options...
this-is-me Posted October 22, 2006 Share Posted October 22, 2006 (edited) @MHz, you must have an older version of the beta or an older version of Internet Explorer than I have because with beta v3.2.1.8 and Internet Explorer 7, It does indeed accept the command line parameters.However, you did not read the request from the OP, because he wanted code that would "needs to be able to adapt to different browsers installed on different computers". This is not the type of code you provided, therefore your code is erroneous.EDIT: @Sunaj, the only time the code did not indeed open the browser not minimized on my computer was when the browser was not already open, due to a setting in Internet Explorer that opens any new website in an existing Internet Explorer window. Edited October 22, 2006 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
MHz Posted October 22, 2006 Share Posted October 22, 2006 (edited) @MHz, you must have an older version of the beta or an older version of Internet Explorer than I have because with beta v3.2.1.8 and Internet Explorer 7, It does indeed accept the command line parameters.However, you did not read the request from the OP, because he wanted code that would "needs to be able to adapt to different browsers installed on different computers". This is not the type of code you provided, therefore your code is erroneous.You are several beta versions into the future and have no chance of minimizing a website, but you can minimize an application. And do note IE mentioned in the 1st post.AutoIt 3.2.1.10 here and parameters are not accepted by ShellExecute().Edit:Added mention of ShellExecute(). Edited October 22, 2006 by MHz Link to comment Share on other sites More sharing options...
this-is-me Posted October 22, 2006 Share Posted October 22, 2006 @MHz, the OP does mention IE as an example, however, he goes on to explain: Reason why I use the DllCall instead of normal Run is that the code I'm writing needs to be able to adapt to different browsers installed on different computers.I also do not understand your statement "have no chance of minimizing a website". This is not what we are talking about at all. We are speaking about launching the default browser in a minimized state. As for differences in scripting, If you look at the helpfile for ShellExecute, it does specify that you need not input a verb to allow it to work correctly. In the beta, I can use the following code and it works flawlessly: ShellExecute('http://www.autoitscript.com/', '', '', '', @SW_MINIMIZE) Let me be rightly understood, I am not trying to pick a fight, I simply am trying to iron out the differences in our attempts to answer the OP's question. Who else would I be? Link to comment Share on other sites More sharing options...
Sunaj Posted October 24, 2006 Author Share Posted October 24, 2006 (edited) @this-is-me, @MHz, thanks for your help on this one (late reply due to me not having access to comp. during this weekend). Unfortunately this-is-me is right in pointing out that the script (despite working great) provided by MHz does not solve my problem.. Also, this code by this-is-me seems to be IE7 only which does not really fit the bill either (at least not till everyone has upgraded.. which I guess will take about a decade). (also, it does not matter whether IE6/Firefox is open or not - still pops up in front of everything else) So.. wrote the following registry polling script to allow for app control AND different browsers.. the regexp (which btw took me... time... to get right) is necessary because Firefox writes its default reg-entry in a different way than IE. Code $string = RegRead ( "HKEY_CLASSES_ROOT\HTTP\shell\open\command", "" ) $pattern = '(?i).(\:)(.*)exe' ; dont know how to get smily off here... $result = StringRegExp($string, $pattern,2) If @error Then MsgBox(48, 'Error', "Default browser not set") EndIf $DefaultBrowser = $result[0] Run($DefaultBrowser & " " & "http://www.autoitscript.com/", "", @SW_MINIMIZE) Still, despite having gained control over IE6/7 it seems that Firefox(1.5.0.7) completely ignores all the @SW's - it even ignores its opening parameters when changing a normal desktop link to "Run: Minimized" so I guess it does not accept any kind of opening window control at all!! .... @MHz, the OP does mention IE as an example, however, he goes on to explain: .... Edited October 24, 2006 by Sunaj [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
Zedna Posted October 25, 2006 Share Posted October 25, 2006 Why not use simple way:Run(@ComSpec & " /c " & 'start www.autoitscript.com/forum/', "", @SW_HIDE)Look at my about_hyperlink.au3 from my signature ... Resources UDF ResourcesEx UDF AutoIt Forum Search 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