Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Running files (including .au3) from web pages (...locally)


  • Please log in to reply
4 replies to this topic

#1 sshrum

sshrum

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 538 posts

Posted 21 February 2010 - 08:59 AM

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.

Plain Text         
#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 :: Shrum Consultingsean[at]shrum[dot]net :: http://www.shrum.net---------------Skinner: 'Oh, brandishing your buttocks is only making me angrier!'Me: 'Make it idiot-proof, and someone will make a better idiot'Me (sort of): 'Give a man a fish and you feed him for a day. Teach a man to fish and he'll snag some part of his body with a rusty hook, get tetanus, and surely die'---------------All my published AU3-based apps and utilities







#2 gcue

gcue

    just a wannabe

  • Active Members
  • PipPipPipPipPipPip
  • 1,901 posts

Posted 22 February 2010 - 01:31 AM

sounds interesting - ill try it out =)

thanks for sharing

#3 Shafayat

Shafayat

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 22 February 2010 - 05:47 PM

It is great. I learned a lot from it. I mean eventhough I do not need to run autoit scripts from lan. But your script teaches how to set up a custom protocol. I appreciate that bit very much.
[Not using this account any more. Using "iShafayet" instead]

#4 Michel Claveau

Michel Claveau

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 352 posts

Posted 22 February 2010 - 06:29 PM

Hi!

See: old_message

#5 sshrum

sshrum

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 538 posts

Posted 08 March 2010 - 08:40 PM

@ Michel Claveau

That's the one...I should've included a link to the originating one, my bad. Thx.
Sean Shrum :: Shrum Consultingsean[at]shrum[dot]net :: http://www.shrum.net---------------Skinner: 'Oh, brandishing your buttocks is only making me angrier!'Me: 'Make it idiot-proof, and someone will make a better idiot'Me (sort of): 'Give a man a fish and you feed him for a day. Teach a man to fish and he'll snag some part of his body with a rusty hook, get tetanus, and surely die'---------------All my published AU3-based apps and utilities




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users