Skorm92 Posted August 17, 2013 Posted August 17, 2013 (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: 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 August 17, 2013 by Skorm92
FireFox Posted August 17, 2013 Posted August 17, 2013 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.
Skorm92 Posted August 17, 2013 Author Posted August 17, 2013 (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 August 17, 2013 by Skorm92
FireFox Posted August 17, 2013 Posted August 17, 2013 You want to link the url protocol to your application right?
Skorm92 Posted August 17, 2013 Author Posted August 17, 2013 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
FireFox Posted August 17, 2013 Posted August 17, 2013 (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"') NextAnd to restrict the launch by the URL protocol :See attachment, I can't post it...Br, FireFox.example.au3 Edited August 17, 2013 by FireFox
Skorm92 Posted August 17, 2013 Author Posted August 17, 2013 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 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!
FireFox Posted August 17, 2013 Posted August 17, 2013 I realized that I let the program name in the code... please check the review.Br, FireFox.
FireFox Posted August 17, 2013 Posted August 17, 2013 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 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).
lionfaggot Posted August 17, 2013 Posted August 17, 2013 (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 August 17, 2013 by lionfaggot
FireFox Posted August 17, 2013 Posted August 17, 2013 It's not applicable if he wants to launch his application through an url on the same computer.
FireFox Posted August 17, 2013 Posted August 17, 2013 I said "If" basing on the first post, maybe it's not the case, we'll see.
Skorm92 Posted August 18, 2013 Author Posted August 18, 2013 (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 August 18, 2013 by Skorm92
FireFox Posted August 18, 2013 Posted August 18, 2013 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?
Skorm92 Posted August 18, 2013 Author Posted August 18, 2013 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,
FireFox Posted August 18, 2013 Posted August 18, 2013 Huh? I don't understand what's the problem with the double slashes.
Skorm92 Posted August 18, 2013 Author Posted August 18, 2013 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.
FireFox Posted August 18, 2013 Posted August 18, 2013 Can you debug your application with MsgBoxes to see where it closes?
Skorm92 Posted August 18, 2013 Author Posted August 18, 2013 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)
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