Page 1 of 2

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

Posted: 21 Sep 2018, 12:07
by User
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!

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

Posted: 21 Sep 2018, 13:31
by TheDewd
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.

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

Posted: 21 Sep 2018, 14:18
by User
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!

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

Posted: 21 Sep 2018, 15:35
by HotKeyIt
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.

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

Posted: 21 Sep 2018, 17:57
by User
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"?

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

Posted: 21 Sep 2018, 17:59
by User
Oh, and I forgot to ask:

Can I use the AHK_L compiler to compile AHK_H.exe?

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

Posted: 22 Sep 2018, 00:45
by User
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 118 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

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

Posted: 22 Sep 2018, 05:03
by HotKeyIt
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.

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

Posted: 22 Sep 2018, 05:09
by HotKeyIt
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

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

Posted: 22 Sep 2018, 14:17
by User
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!

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

Posted: 23 Sep 2018, 17:51
by User
HotKeyIt wrote:Yes there is always this problem with false positives.
Are you sure that your files were not somehow compromised or something?

The detection rate is too high:

AHK_H (1.1.30.00) github commit
https://www.virustotal.com/#/file/5e184 ... /detection
https://www.virustotal.com/en/file/5e18 ... 537742754/

AHK_H (1.1.23.05) github commit
https://www.virustotal.com/#/file/08703 ... /detection
https://www.virustotal.com/en/file/0870 ... /analysis/

The file was downloaded from here https://hotkeyit.github.io/v2/

Launching VirusTotal Monitor, a service to mitigate false positives

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

Posted: 24 Sep 2018, 14:09
by HotKeyIt
This is what I get when I compress it locally with zip: https://www.virustotal.com/de/file/80e0 ... 537815898/

EDIT:
Checking the files individually the most detection are in AutoHotkeySC.bin: https://www.virustotal.com/#/file/437d1 ... /detection

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

Posted: 24 Sep 2018, 16:06
by User
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!

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

Posted: 25 Sep 2018, 15:30
by Asmodeus
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.

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

Posted: 25 Sep 2018, 16:00
by User
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!)

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

Posted: 25 Sep 2018, 16:19
by User
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!

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

Posted: 25 Sep 2018, 16:22
by HotKeyIt
I have now changed to the latest VC 2017 (v141_xp) and it seems to be better now, hope this helps:
AHK_H v1.1.30.00: https://www.virustotal.com/#/file/8c14a ... /detection
AHK_H v2.099: https://www.virustotal.com/#/file/2f89d ... /detection

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

Posted: 25 Sep 2018, 16:28
by Asmodeus
@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.

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

Posted: 25 Sep 2018, 16:34
by User
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!

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

Posted: 25 Sep 2018, 16:37
by User
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