SumTingWong Posted October 11, 2004 Share Posted October 11, 2004 (edited) Just want to mention that it is now possible to call ShellExecute with DllCall. Example: $ret = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, "string", "", _ "string", "C:\Your Doc.doc", "string", "", _ "string", "", "long", @SW_SHOWNORMAL) Edited October 11, 2004 by pacman Link to comment Share on other sites More sharing options...
CyberSlug Posted October 11, 2004 Share Posted October 11, 2004 Can DllCall let us open Control Panel applets in a hidden state? Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
ezzetabi Posted October 11, 2004 Share Posted October 11, 2004 (edited) An other idea:In this version you can use also "Verbs", arguments and a different starting dir.$sVerb = '' $sFile = 'cmd' $sArguments = ' /k dir' $sStartingDir = 'e:\' $aRet = DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", $sVerb, _ "string", $sFile, "string", $sArguments, "string", $sStartingDir, "long", @SW_SHOWNORMAL) If $aRet[0] <= 32 Then MsgBox(0,'','Error executing ' & $aRet[3]) EndIfPacman? What $iRet should include? I always see it as a empty string... Edit: Ok, as MSDN say here it is actually a interger... But I can't read the value anyway.Edit2: As Autoit help says it is a array. And this solves the problem. Modified the script allowing a error message if something goes wrong. Edited October 11, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
SumTingWong Posted October 11, 2004 Author Share Posted October 11, 2004 I tried: $ret = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, "string", "", _ "string", @SystemDir & "\DESK.CPL", "string", "", _ "string", "", "long", @SW_HIDE) but it didn't work so I guess the answer is no :"> Link to comment Share on other sites More sharing options...
ezzetabi Posted October 13, 2004 Share Posted October 13, 2004 Does this works in Win98? Pacman? Link to comment Share on other sites More sharing options...
sPeziFisH Posted October 13, 2004 Share Posted October 13, 2004 According to ShellExecute-description @ msdnand to the fact that Win98 also has a Desk.cpl it should work - but that's just a dispensable guess Link to comment Share on other sites More sharing options...
SumTingWong Posted October 13, 2004 Author Share Posted October 13, 2004 What he said above ^^^ Link to comment Share on other sites More sharing options...
SlimShady Posted January 28, 2005 Share Posted January 28, 2005 (edited) I improved ezzetabi's ShellExecute.It now works almost exactly like Run.No full path necessary and you can hide, minimize the application window.And ofcourse the purpose of this function: run non-executables.The ShellExecute UDF and it's dependent function are attached uploaded.Here are some examples.#include "_ShellExecute.au3" ;Example 1 _ShellExecute('notepad') Sleep(5000) ;Example 2 _ShellExecute('ping 127.0.0.1') Sleep(5000) ;Example 3 _ShellExecute('cmd /c START notepad', @SystemDir, @SW_HIDE) Sleep(5000) ;Example 4 _ShellExecute(@ProgramFilesDir & '\AutoIt3\AutoIt.chm') Sleep(5000) ;Example 5 _ShellExecute('http://www.autoitscript.com', @SystemDir)I just uploaded my latest version here: http://www.autoitscript.com/fileman/users/SlimShady/_ShellExecute.au3 Edited November 16, 2005 by SlimShady Link to comment Share on other sites More sharing options...
fmen Posted October 18, 2005 Share Posted October 18, 2005 Thanks for the UDF. I had a similar request/problem several months ago. It is a great addition to autoit. Link to comment Share on other sites More sharing options...
eRKa Posted November 14, 2005 Share Posted November 14, 2005 _ShellExecute seems to have some problems, if the filename contains spaces, is that right? I tried to call it with the argument 'winword "testfile 01.doc"', but the application start failed - to say it more correctly: winword started, but wasn't able to find the file. I also tried 'winword "testfile{SPACE}01.doc"' - but it was the same. As far as i understand it, the space is interpretet as a separator for arguments, right? But that shouldn't be, if there is a fileextension (.doc in this case) on the right side of the string, or not? cu Link to comment Share on other sites More sharing options...
w0uter Posted November 14, 2005 Share Posted November 14, 2005 (edited) 1. try a dos name (filegetshortname, or something like that) 2. try %20 instead of a space Edited November 15, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
jefhal Posted November 15, 2005 Share Posted November 15, 2005 (edited) Just comment out the code as below. However, this will ruin the point of these steps (cheezy hack) ...;~ If ValidFilename($sCmd) Then ;~ $sArg = "" ;~ Else ;~ $sNewCmd = ValidFilename($sCmd, 1) ;~ If StringInStr($sNewCmd, @LF) Then ;~ $sNewCmd = StringSplit($sNewCmd, @LF) ;~ $sCmd = $sNewCmd[1] ;~ $sArg = $sNewCmd[2] ;~ Else $sArg = "" ;~ EndIf ;~ EndIfNotice, one line above is NOT commented out! Now it will allow this to run:_ShellExecute('C:\Documents and settings\Jeff\My Documents\Collective exp.doc', @DocumentsCommonDir) Edited November 15, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
eRKa Posted November 16, 2005 Share Posted November 16, 2005 @w0uter: %20 doesn't work; i didn' t check the other option yet (short dos-name) @jefhal: ok, that works for the moment (if you doesn't wantto add arguments), but at the end it should be possible to add arguments. thx Link to comment Share on other sites More sharing options...
SlimShady Posted November 16, 2005 Share Posted November 16, 2005 _ShellExecute seems to have some problems, if the filename contains spaces, is that right?No.I tried to call it with the argument 'winword "testfile 01.doc"'Why? Use Run() or RunWait() instead., but the application start failed -obviously.to say it more correctly: winword started, but wasn't able to find the file.It's very important to always use a full path.Not only with this function, all functions and applications.I also tried 'winword "testfile{SPACE}01.doc"' - but it was the same. As far as i understand it, the space is interpretet as a separator for arguments, right?True.But that shouldn't be, if there is a fileextension (.doc in this case) on the right side of the string, or not?You're talking very weird now.If you have spaces in a filename or path, surround it wth quotes.Example:"C:\Program Files\AutoIt3\AutoIt3.exe"Run('"C:\Program Files\AutoIt3\AutoIt3.exe" "' & @DesktopDir & '\Test.au3"')or#include "_ShellExecute.au3" _ShellExecute('"' & @DesktopDir & '\Test.au3"')I discovered that the old version did not work well.I just uploaded my latest version here: http://www.autoitscript.com/fileman/users/SlimShady/_ShellExecute.au3 Link to comment Share on other sites More sharing options...
randallc Posted December 17, 2005 Share Posted December 17, 2005 Hi, So is this quicker than "Run" or just more flexible? Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
w0uter Posted December 18, 2005 Share Posted December 18, 2005 more flexible. run can only create processes while this can also run like .txt/.mp3 My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
sinvos Posted December 20, 2005 Share Posted December 20, 2005 _ShellExecute seems to have some problems, if the filename contains spaces, is that right? I tried to call it with the argument 'winword "testfile 01.doc"', but the application start failed - to say it more correctly: winword started, but wasn't able to find the file. I also tried 'winword "testfile{SPACE}01.doc"' - but it was the same. As far as i understand it, the space is interpretet as a separator for arguments, right? But that shouldn't be, if there is a fileextension (.doc in this case) on the right side of the string, or not? cuThe reason it failed is because used it wrong below i wrote a example and it works so i hope this can help on what ever your trying to do. $run = "winword.exe"; executable you want to run $args = "path\testfile 01.doc"; arguments $verb = "Open"; other valide functions are edit, print, or just leave it blank $dir = ""; path of executabe can leave blank if it's in the system path, c:\windows\, c:\windows\system32 etc.. $sw = 3; hide = 0, maximize = 3, minimize = 6 $dll = DllOpen("shell32.dll") $ret = Dllcall($dll,"long","ShellExecuteA", _ "hwnd",0, _ "str",$func, _ "str",$run, _ "str",$args, _ "str",$dir, _ "int",$sw) DllClose($dll) thats one way or you can change run to $run = "path\testfile 01.doc and leave $args blank and use defaulted application. 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