Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

21 Sep 2018, 12:07

Hi,

When a "AHK.exe" file is directly executed (example, when a user double-click it), it automatically executes the "AHK.ahk" file that is in the same folder!

Lets say "IncludedScript.ahk" was packed inside "AHK.exe", how to force "AHK.exe" to execute "IncludedScript.ahk" script instead "AHK.ahk" when it is directly executed?

Then, in "IncludedScript.ahk" I can use codes like:

run, AHK.exe "AHK.ahk"
or
run, AHK.exe "Temp.ahk"

Thanks!
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

21 Sep 2018, 13:31

You can create a shortcut to the executable file and then specify the path to a specific script:

Shortcut Path:

Code: Select all

C:\Program Files\AutoHotkey\AutoHotkey.exe C:\Path\To\Script\File.ahk
Another option could be to create a script where you can specify the other script you want to execute, and then compile that script into a new executable file.
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

21 Sep 2018, 14:18

TheDewd wrote:.
Thanks for your reply, but

As the title says, when "AHK.exe" is directly executed (example, when a user double-click it), it must not be executed through a shortcut!

"compiling", I really want to avoid it!

It would be nice to do everything with just 1 "AHK.exe" file!

But, if it is really not possible, that's ok too, I can live with that!

Thanks!
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?  Topic is solved

21 Sep 2018, 15:35

You can do that in AHK_H, you can compile using AutoHotkey.exe then included script will run when you double click it.
Then you can use /E switch to execute a different script than compiled run, AHK.exe /E "AHK.ahk", see http://hotkeyit.github.io/v2/docs/AHKH_Features.htm
Original AutoHotkey is only capable to be compiled with AutoHotkeySC.bin. In AutoHotkey_H any AutoHotkey binary (AutoHotkey.dll, AutoHotkey.exe, AutoHotkeySC.bin) can be compiled.
This allows keeping full functionality of AutoHotkey including executing other scripts. Compiled AutoHotkey.exe and AutoHotkey.dll can use /E switch to execute different script than compiled one.
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

21 Sep 2018, 17:57

HotKeyIt wrote:.
I will try AHK_H!

Just to let you know, Avast detects the ".bin" and ".exe" files from "win32a" folder as virus!

By the way, is the "Win32w" and "x64w" the same as "Win32Unicode" and "x64Unicode"?

As for the "win32a", I suppose it is for "win32Ansi"?
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

21 Sep 2018, 17:59

Oh, and I forgot to ask:

Can I use the AHK_L compiler to compile AHK_H.exe?
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

22 Sep 2018, 00:45

HotKeyIt wrote:.
Well, this "/E" switch for "AHK_H" compiled scripts will definitely forces me to use "AHK_H" more oftenly!

For me, this is incredible that "AHK_L" can't do such thing!

Anyway, I think that, the "Compiler" folder should contain an "Ahk2Exe.exe" file included, because, in my case, I was trying to execute "Ahk2Exe.ahk" and getting the following error:

Image

I was already giving up on this, but then I saw this post of yours that helped me to make the compiler work! (Configurations I used below:)
98_ z_ Compiled with AHK_H.png
(31.33 KiB) Downloaded 347 times
Compiling using ".exe" instead ".bin" is great, but there is one problem with the former, for example, in windows "taskmanager" or while choosing a program to execute an extension, "AHK_H" shows up instead the compiled script ".exe" file name!
Taskmnager - open with.png
(26.7 KiB) Downloaded 347 times
The code below is a simple Calculator script that can be used with "AHK_L" and "AHK_H"! But, to make it work compiled, the script file must be compiled with "AHK_H.exe"! (The compiled script will not work if compiled with "AHK_H.bin"! The script must not be compiled with "AHK_L" simply because it will not work! Compiled "AHK_L" scripts don't support [Script Filename], "/E" switch or whatever !)

The compiled Calculator script, the ".rar" file below, creates a temp ".ahk" file script in the same directory, and then execute it, then, the executed ".ahk" script automatically deletes the temp ".ahk" file!
Calculator.rar
(1.4 MiB) Downloaded 110 times
Image

Code: Select all

File := "#_ TempCalculatorScript"

if RegExMatch(A_ScriptName, "\.ahk$")
File .= ".ahk"

gui, add, edit, w400 h200 vEditControl, . "Calc = "  1 + 2 + 3  "``n"   `n. "Calc = "  3 + 4 + 5  "``n"   `n. "Calc = "  5 + 6 + 7  "``n"

gui, add, button, gRun, Run

gui, show

send {Tab}

return

run:	;_____________ run ______________

guicontrolget, UserInput,, EditControl

UserInput := ""
. "gui, add, edit, w200 h100, % """"`n" UserInput  "`n" 
. "gui, show"    "`n" 
. "send {Down}"  "`n"
. "return"   "`n"
. "`n" 
. "guiclose:	`;_____________ gui close ___________"   "`n" 
. "exitapp"        "`n" 


FileDelete, % File

if RegExMatch(A_ScriptName, "\.ahk$")
{
FileAppend , % UserInput, % File
run, % File 
}
else if RegExMatch(A_ScriptName, "\.exe$")
{
UserInput :=  "FileDelete, % A_ScriptName `n`n" UserInput
FileAppend , % UserInput, % File

run, % A_ScriptName " /E """ File """"
;for compiled scripts, "/E" is necessary to run "File" (not Supported by AHK_L)
;(each "" represents one literal ")

	;FileDelete, % File	;Not recommended to be used here (force the executed script to delete the file instead, see example above!)
}

				

return

guiclose:	;________________ gui close ________________
exitapp
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

22 Sep 2018, 05:03

User wrote:Just to let you know, Avast detects the ".bin" and ".exe" files from "win32a" folder as virus!

By the way, is the "Win32w" and "x64w" the same as "Win32Unicode" and "x64Unicode"?

As for the "win32a", I suppose it is for "win32Ansi"?
Yes there is always this problem with false positives.
Correct w=Unicode, a=ANSI.
User wrote:Can I use the AHK_L compiler to compile AHK_H.exe?
No.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

22 Sep 2018, 05:09

User wrote:Compiling using ".exe" instead ".bin" is great, but there is one problem with the former, for example, in windows "taskmanager" or while choosing a program to execute an extension, "AHK_H" shows up instead the compiled script ".exe" file name!
You can use ;@Ahk2Exe-SetDescription AutoHotkey Calculator to change that, see https://autohotkey.com/boards/viewtopic.php?f=24&t=521
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

22 Sep 2018, 14:17

HotKeyIt wrote:You can use ;@Ahk2Exe-SetDescription AutoHotkey Calculator to change that, see https://autohotkey.com/boards/viewtopic.php?f=24&t=521
Indeed, it works!

But, I think that Version Infos (such as: name, description, version, Copyright, OrigFilename) from "AutoHotKey.exe" file should be removed automatically by the compiler itself!

Anyway, the link below is for anyone who wants to compile their scripts with "AHK_H (1.1.30.00)" on the go!

(Password = v) - AHK_H (1.1.23.05).rar (for those like me who still use AHK_L 1.1.23.05)
(Password = v) - AHK_H (1.1.30.00).rar

The file is password protected in order to prevent Antiviruses from blocking the download! (Password = v)
Note that, False Positives detection rate for AHK_H is too high! (Google VirusTotal 25/60 detection found!)

- extract .rar file
- go to "compiler" folder and run 'Ahk2Exe.exe"
- select your .ahk script, your .ico, etc
- for the base file bin, select "Version Infos (Removed).exe.bin" from "Win32w (Unicode)" or "x64w (Unicode)" folder!
- Compile

The compiled ".exe" files will not contain the original "AHK_H.exe" version Infos, because they were removed from "Version Infos (Removed).exe.bin" files!

Thanks!
Last edited by User on 23 Sep 2018, 22:33, edited 2 times in total.
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

24 Sep 2018, 16:06

HotKeyIt wrote:AutoHotkeySC.bin
In my case, I just need the files below:

- The compiler files
- "Version Infos (Removed).exe.bin" 32bit Unicode (maybe later I may need the 64bit version)
- "mpress.exe" (maybe I may need, seems to be useful)

Fortunately for me, the files above are not being detected by Avast installed in my computer!
Asmodeus
Posts: 57
Joined: 19 Oct 2015, 15:53

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

25 Sep 2018, 15:30

i have created a nasty one line virus, to dominate the world.
i did a detection test and unfortunately i got caught, damn it! :facepalm:

joking aside, is there anything we can do? Reporting false positives does not seem to help at all.
I used to neglect the chinese vendors, but feel a bit uncomfortable using AHK at work because of the McAffe hit.
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

25 Sep 2018, 16:00

Asmodeus wrote:joking aside, is there anything we can do? Reporting false positives does not seem to help at all.
I used to neglect the chinese vendors, but feel a bit uncomfortable using AHK at work because of the McAffe hit.
I suspect that when a new version of AHK is released, since the hash value (such as SHA-256, etc, etc) of the files change, Antiviruses software simply automatically detect the new files as virus because the files new hash values are not in their database???

Well, so far, almost all my ".exe" files compiled with AHK_L 1.1.23.05 are not being detected in VirusTotal.com!

Believe me, reporting false positives sometimes works! (The problem is that, at every new version released, since the hash value of the ".exe" file changes, it is highly probable that it will be detected again as virus!)
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

25 Sep 2018, 16:19

msgbox Haha - AHK_L 1.1.23.05.exe (1detection)
https://www.virustotal.com/#/file/052ab ... /detection

msgbox Haha - AHK_H 1.1.23.05.exe (1 detection)
https://www.virustotal.com/#/file/25714 ... /detection

msgbox Haha - AHK_H 1.1.30.00.exe (3 detection)
https://www.virustotal.com/#/file/9e450 ... /detection

The ".exe" files above are 32bit unicode version!
Last edited by User on 25 Sep 2018, 16:26, edited 1 time in total.
Asmodeus
Posts: 57
Joined: 19 Oct 2015, 15:53

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

25 Sep 2018, 16:28

@User: I did some some tests myself meanwhile v1.1.30 6 hits, v1.1.27.4 5 hits, v1.1.26.1 3 hits. I don't think it's a good idea to use an old compiler, I haven't checked but I guess bugs were fixed, enhancements added, etc. in the newer versions...
@HotKeyIt: sorry I don't get it, your first upload has 10 detections.
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

25 Sep 2018, 16:34

HotKeyIt wrote:I have now changed to the latest VC 2017 (v141_xp) and it seems to be better now, hope this helps:
Seems much better! I myself will use this new version instead the older one!
User
Posts: 407
Joined: 26 Jun 2017, 08:12

Re: Is it possible to run by default a script file inside a normal AHK.exe file when it is directly executed?

25 Sep 2018, 16:37

Asmodeus wrote:@HotKeyIt: sorry I don't get it, your first upload has 10 detections.
nope, 28 detections:
https://www.virustotal.com/#/file/5e184 ... /detection

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: dunnerca, wilkster and 137 guests