sshrum Posted February 21, 2010 Share Posted February 21, 2010 Saw a post about this a while back but made mine a bit more flexible. This is mainly for use with intranet/local web pages: If you want to be able to launch files (including uncompiled autoit scripts) from a link in a web page while avoiding that annoying Windows security popup, you need to do 2 things: build a launcher app and prepend your HREF filenames with 'autoit:' Step 1: The following code is my launcher. #NoTrayIcon #Include <Misc.au3> ; _isPressed() if $CmdLineRaw = "" Then $name="autoit" $command=@ScriptFullPath $tkey="HKEY_CLASSES_ROOT\"&$name RegWrite($tkey) RegWrite($tkey,"","REG_SZ","URL: "&$name&" protocol") RegWrite($tkey,"URL Protocol","REG_SZ","") RegWrite($tkey&"\shell") RegWrite($tkey&"\shell\open") RegWrite($tkey&"\shell\open\command") RegWrite($tkey&"\shell\open\command","","REG_SZ",'"'&$command&'" %1') Else $cmdlineraw = StringReplace($cmdlineraw, "autoit:", "") $cmdlineraw = StringReplace($cmdlineraw, "%20", " ") $cmdlineraw = StringReplace($cmdlineraw, "%5e", "^") $cmdlineraw = StringReplace($cmdlineraw, "/", "\") switch stringright($CmdLineRaw, 4) case ".au3" $sAutoIT = regread("HKLM\Software\Autoit v3\AutoIT", "InstallDir") if $sAutoIT <> "" Then If _IsPressed(11) Then ShellExecute($CmdLineRaw, "", @ScriptDir, "edit") else ShellExecute($CmdLineRaw, "", @ScriptDir, "run") endif Else msgbox(0,stringtrimright(@scriptname,4), "AutoIT v3 InstallDir registry entry not found. In order to run *uncompiled* (.au3) files, you must have AutoITScript installed. Please visit autoitscript.com and download/install the engine. Otherwise, you'll only be able to use *compiled* (.exe) addons") EndIf Case Else ShellExecute($CmdLineRaw) EndSwitch endif Note: I added stringreplace() for spaces, ^, and forward slashes (some browsers convert these chars to codes...if anyone knows a better way to convert the web-friendly codes to normal chars, please let me know) Compile the exe and then run it once...nothing visible will occur but the app will associate the 'autoit:' protocol to the launcher app. Step 2: Now build a webpage with a link to a file. Typically your address call would look like: a href="c:\somefile.txt" Prepend the file ref with 'autoit:' a href="autoit:c:\somefile.txt" Whenever you click on the link, it will run the launcher that will strip off the 'autoit:' part and invoke shellexecute("c:\somefile.txt") which will react as if you dbl-clicked on the file itself. Associated file types will launch the parent app. Unassociated file types will prompt for a app to run with. '.au3' files are the only special case. Links to filenames with .au3 will invoke a .au3 registry 'run' cmd (this is great if you don't wanna have to constantly compile scripts and run them straight). Holding down the CTRL key and clicking a '.au3' URL link will invoke a .au3 registry 'edit' cmd (such as loading the script into ScITe if that is how your system is set up). This works great for me as I can now create web-based interfaces for my media suite while still being able to quickly open my scripts for editing directly from the web page I create. Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
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
Already have an account? Sign in here.Sign In Now