Jump to content

[Q] Launch application from browser


Recommended Posts

Hello AutoIT community!

I've been studying autoit script for a month or so now, and I was wondering if auto it can support the launch of its compiled script through (any) browser,

Like for example:

520ec721d55c7.jpg

Would launch the compiled script called "myapp"

I couldn't find any related info on this or I haven't been searching that good.

Either case, I'd like some help on this one! =)

Thanks in advance!

Edited by Skorm92
Link to comment
Share on other sites

Hi,

Welcome to the autoit forum :)

What you're looking for is called URL Protocol, it's not related to autoit but to Windows.

If you launch an autoit script through this kind of address, you will have the address in the $CmdLine (command line) array.

Br, FireFox.

Link to comment
Share on other sites

Thank you for your reply!

So what would be (in a non pro soft dev way) the easiest way to let the application simply launch only? So just execute the application without further tasks once it opened.

I hope I don't go out of my league asking this since I don't know if this a merely hard thing to accomplish.

Edited by Skorm92
Link to comment
Share on other sites

I made this for a project, so here is the code to add the URL protocol :

Local $sMyProgram = @ScriptFullPath, $sProgName = "My Program"

Local $aURLProtocol[5] = ["HKCR", _
        "HKLM\SOFTWARE\Classes", _
        "HKCR\Wow6432Node", _
        "HKLM\SOFTWARE\Classes\Wow6432Node", _
        "HKLM\SOFTWARE\Wow6432Node\Classes"]
 
For $i = 0 To UBound($aURLProtocol) - 1
    If $i = 2 And @OSArch = "X86" Then ExitLoop
 
    RegWrite($aURLProtocol[$i] & "\" & $sProgName)
    RegWrite($aURLProtocol[$i] & "\" & $sProgName, "", "REG_SZ", "URL:" & $sProgName)
    RegWrite($aURLProtocol[$i] & "\" & $sProgName, "URL Protocol", "REG_SZ")
    RegWrite($aURLProtocol[$i] & "\" & $sProgName & "\DefaultIcon")
    RegWrite($aURLProtocol[$i] & "\" & $sProgName & "\DefaultIcon", "", "REG_SZ", StringRegExpReplace($sMyProgram, "^.*\\", ""))
    RegWrite($aURLProtocol[$i] & "\" & $sProgName & "\Shell")
    RegWrite($aURLProtocol[$i] & "\" & $sProgName & "\Shell\Open")
    RegWrite($aURLProtocol[$i] & "\" & $sProgName & "\Shell\Open\Command")
    RegWrite($aURLProtocol[$i] & "\" & $sProgName & "\Shell\Open\Command", "", "REG_SZ", '"' & $sMyProgram & '" "%1"')
Next
And to restrict the launch by the URL protocol :

See attachment, I can't post it...

Br, FireFox.

example.au3

Edited by FireFox
Link to comment
Share on other sites

Thank you alot! Once I get home from work i'll check it straight away.

As I look at it now, it'll probably take a while for me to understand what the script exactly does and how it functions :P

I think I can sort it out,

If not than I'll post back here,

Thank you for the (amazingly fast) reply's and help!

Link to comment
Share on other sites

As I look at it now, it'll probably take a while for me to understand what the script exactly does and how it functions :P

There's nothing really important to understand, just note that it registers the URL protocol in the registry (at different places) so that some applications can handle it (like the web browsers).
Link to comment
Share on other sites

Yes I want my script to execute through a browser,

I.E. Clicking on a "play" button on my website should execute my application.

So clicking on a link with my URL protocol should execute the program,

I tried your script, the URL Protocol script that writes in the reg,

And chrome asks me if I am sure of executing the program,

but the app simply doesn't open. even when I give permission.

 

EDIT:

I made a minor change to your script to make it work,

RegWrite($aURLProtocol[$i] & "\" & $sProgName, "", "REG_SZ", "URL: " & $sProgName & " " & "Protocol")
    RegWrite($aURLProtocol[$i] & "\" & $sProgName, "URL Protocol", "REG_SZ", "")

did the trick,

Although it opens now, It also immediately closes.

Any solutions for that perhaps?

Edited by Skorm92
Link to comment
Share on other sites

If i add the double slashes to my href. and to the script you provided. then the application doesn't open.

If I only use myapp: (both my href and in the script) it successfully executes,

But it's not a major thing that I have to start it with myapp:,

The problem is that the application closes immediately after launch.

Whilst it runs fluently when I open the exe manually or use "Go" in SciTE editor. 

Link to comment
Share on other sites

That got me a little further,

It seems that the executable can't load any resources (jpg files from "content" dir)

I placed MsgBoxes between every image that it has to load and there are no images showing up.

While if I run the application directly it loads every image one by one (after each MsgBox)

Link to comment
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...