Jump to content

Recommended Posts

Posted (edited)

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
Posted

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.

Posted (edited)

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
Posted

Yeah it just simply has to launch,

I wanna write the application in a way that it can be only launched from the website, if this isn't possible then just simply open it through a link button or launch from desktop/working dir

Posted (edited)

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
Posted

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!

Posted

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).
Posted (edited)

alright i dont get how this is complicated at all. ShellExecute() is more than enough for what you need here. i was able for instance to launch skypes web api features using ShellExecute()

Edited by lionfaggot
Posted (edited)

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
Posted

Although it opens now, It also immediately closes.

Any solutions for that perhaps?

And without the script I told you to insert in your application?
Posted

And without the script I told you to insert in your application?

The exact same thing happens, The script works like a charm!

Only thing is I can only use myapp: and not myapp: with "//"

But that's not a big deal,

Posted

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. 

Posted

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)

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
  • Recently Browsing   0 members

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