Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

#exclude for Excluding Components


  • Please log in to reply
22 replies to this topic
  • Guests
  • Last active:
  • Joined: --
My suggestion is to make a directive which enables to exclude a specified component so that it reduces the compiled script size.

For example, for a script which does not use GUI commands,
#exclude GUI
then the commands and the functions related to GUI won't be available in the script but it saves the size of the script.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
I really don't think that's practical. AutoHotkey is compiled with everything. There's no feasable way to remove features from the byte code. HotKeyIt made a DLL version of AutoHotkey. One build of it is called 'mini' which removes a lot of those features and provides smaller size and faster load times. Here's a link.
<!-- m -->http://www.autohotke...topic43049.html<!-- m -->
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

  • Guests
  • Last active:
  • Joined: --

I really don't think that's practical.

Reducing sizes is practical. Otherwise, we don't need any compressors.

There's no feasable way to remove features from the byte code.

HotKeyIt made a DLL version of AutoHotkey. One build of it is called 'mini' which removes a lot of those features and provides smaller size and faster load times.

Then it's feasible.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008

Then it's feasible.

No. It's only do-able by compiling your own AutoHotkeySC.bin with a C++ compiler. It can't be done at script compile time.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

  • Guests
  • Last active:
  • Joined: --

It's only do-able

So it's feasible. I'm not interested in listening technical excuses but how it can be achieved.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008

I'm not interested in listening technical excuses but how it can be achieved.

Ok. Here's what you need:
[*:lfjlc1ya]MSVC++ express compiler/IDE 2008/2010 -- Other compilers could be used but this is the one used normally to compile AutoHotkey
[*:lfjlc1ya]The full AutoHotkey source with certain parts removed or using #ifdef tags.
[*:lfjlc1ya]AHK2EXE compiler, the binary is fine
[*:lfjlc1ya]A script that processes the directives, removes them from the source and makes makes note of them. They will be passed to the C++ compiler as command line arguments. It then runs the compiler on the C++ AutoHotkey source and compiles your AutoHotkey code with the new AutoHotkeySC.bin.
If you have the knowledge to modify the C++ code, please post it here (or a new topic) when you're done.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

Tuncay
  • Members
  • 1945 posts
  • Last active: Feb 08 2015 03:49 PM
  • Joined: 07 Nov 2006

It's only do-able

So it's feasible. I'm not interested in listening technical excuses but how it can be achieved.

But you ask someone to implement that feature for you. New features are implemented only if the benefit overweights the costs and your suggestion would be very seldom needed. Technical problems, time and knowledge can make it pain to implement a feature you asked. I personally don`t see any need for this. We have nothing against fresh or simple and effective ideas.

Why is the size of the compiled scripts that important to you? If you need many portable scripts, then why not making a single portable starter script, which runs the original ahk script with the AutoHotkey.exe interpreter.

No signature.


  • Guests
  • Last active:
  • Joined: --

If you need many portable scripts, then why not making a single portable starter script, which runs the original ahk script with the AutoHotkey.exe interpreter.

<!-- m -->http://www.autohotke... ... Q#Portable<!-- m --> :D

  • Guests
  • Last active:
  • Joined: --

your suggestion would be very seldom needed.

How did you measure that? It could be so only for you but would not be for others.

Technical problems, time and knowledge can make it pain to implement a feature you asked.

Then don't implement it if you are an developer of AHK. My suggestion and the idea is for those who understand the benefits.

Why is the size of the compiled scripts that important to you?

Sizes of compiled scripts become important when they are distributed. The bigger the sizes are, the more they consume the server resources.

If you need many portable scripts

Me? no, my users do. And they don't want to spend their valuable time to learn unnecessary programming matters. Simpler, the better.

Tuncay
  • Members
  • 1945 posts
  • Last active: Feb 08 2015 03:49 PM
  • Joined: 07 Nov 2006

your suggestion would be very seldom needed.

How did you measure that? It could be so only for you but would not be for others.

Same question back. ;) How can you measure that it could be so only for me? These are assumptions. Like you did, I do mine and say it.

Then don't implement it if you are an developer of AHK. My suggestion and the idea is for those who understand the benefits.

I am not an developer of AutoHotkey. Its perfectly ok to suggest something. But its perfectly ok too, to speak one's mind. So I did.

Sizes of compiled scripts become important when they are distributed. The bigger the sizes are, the more they consume the server resources.

Ok, thats a good reason (for end user). In my case, If I distributed scripts in exe form, I never had problems with it and no one asked for size. To me personally, the size is ok.

Me? no, my users do. And they don't want to spend their valuable time to learn unnecessary programming matters. Simpler, the better.

Thats true. I had just gave a workaround example. But I do not understand why your consumer should need learn anything for that? But that is all another story. Its off-topic here.

I just said my own opinion, nothing against you. Follow your suggestion. Thats the only way to make progress.

No signature.


  • Guests
  • Last active:
  • Joined: --

Sizes of compiled scripts become important when they are distributed. The bigger the sizes are, the more they consume the server resources.

How much would you expect to save? My uneducated guess is a few KB on a total of a few hundred KB. Get real.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008

Sizes of compiled scripts become important when they are distributed. The bigger the sizes are, the more they consume the server resources.

How much would you expect to save? My uneducated guess is a few KB on a total of a few hundred KB. Get real.

Looking at the the two versions of AutoHotkey.dll, which are essentially AutoHotkey_L, specifically the 32bit Unicode for this example (most common); here's the differences.

The size difference is 149kb in size. The regular is 945kb and the Mini is 796kb. The differences in features following are quoted from AutoHotkey.dll help file:

Hotkey (as well as Hotkey + Hotstring functionality), Gui…, GuiControl[Get], Menu..., TrayIcon, FileInstall, ListVars, ListLines, ListHotkeys, KeyHistory, SplashImage, SplashText..., Progress, PixelSearch, PixelGetColor, InputBox, FileSelect and FolderSelect dialogs, Input, BlockInput MouseMove[Off], Build in variables related to Hotkeys and Icons as well as Gui, A_ThisHotkey..., A_IsSuspended, A_Icon....



Note that the above attempts to be unbiased information.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

  • Guests
  • Last active:
  • Joined: --

Same question back.

Then don't generalize your personal opinion.

New features are implemented only if the benefit overweights the costs

I am not an developer of AutoHotkey

So you even don't know what the benefit is and what the costs are and was saying that.

I never had problems with it and no one asked for size.

You'll understand if you have a file donwloaded a thousand times a day and get complained by the hosting company to upgrade the plan which charges extra fees.

I do not understand why your consumer should need learn anything for that?

Do I have to tell them to download and get AutoHotkey.exe, just in order to make my program lightweight? That would instantly lose their interests using the program. They don't want extra stuff and a complicated procedure to run a single program.

How much would you expect to save? My uneducated guess is a few KB on a total of a few hundred KB. Get real.

It should depend on the developer's skill.

  • Guests
  • Last active:
  • Joined: --
<!-- m -->http://www.autohotke... ... 376#465376<!-- m -->

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Generally I like the idea (that is why I did AutoHotkeyMini.dll).
Using my source files it is very easy to compile AutoHotkeyMini.exe but all you get is ~150 kb less exe size and faster load times but also less functionality.

I had similar idea to remove nearly all functions and commands as well as some build in variables that can be coded in pure ahk (or included via dlls).
Note using pure AHK code we would lose performance :!:

There are many function that can be rewritten quite easy but some like Gui command will need a lot of work, many other can be replaced with existing functions in our forum, for example TT() can replace ToolTip command.

I even started a while back to code some but have not got many yet :(
#include <_Struct>


PixelGetColor,c,335,49 ; 
MsgBox %  c " ?= " PixelGetColor(335,49)
MsgBox % A_IsAdmin()
MsgBox % A_IPAddress(1) "`n" A_IPAddress(2) "`n" A_IPAddress(3) "`n" A_IPAddress(4)


A_AhkDir(){
	return SubStr(A_AhkPath,1,InStr(A_AhkPath,"\",1,0)-1)
}

A_CoordMode(Option,mode="~"){
	static CoordModeToolTip:=0,CoordModePixel:=0,CoordModeMouse:=0,CoordModeCaret:=0,CoordModeMenu:=0
	If mode=~
		Return CoordMode%option%
	CoordMode%option%:=mode="Screen"?1:0
}

PixelGetColor(aX,aY,aOptions=""){
	global _Struct
	ErrorLevel:=0 ;Set default ErrorLevel.
	if !A_CoordMode("Pixel") ;Using relative vs. screen coordinates.
	{
		rect:=new _Struct("left,top,right,bottom")
		if (!DllCall("GetWindowRect","Uint",DllCall("GetForegroundWindow"),"UInt",rect[]))
			return
		aX += rect.left
		aY += rect.top
	}
	If InStr(Options,"Alt")
		use_alt_mode=1
	If !(hdc:=(use_alt_mode ? DllCall("CreateDC","Str","DISPLAY","Uint",0,"Uint",0,"Uint",0) : DllCall("GetDC","Uint",0)))
		return
	color := DllCall("GetPixel","Uint",hdc,"UInt",aX,"Uint",aY)

	if (use_alt_mode)
		DllCall("DeleteDC","Uint",hdc)
	else
		DllCall("ReleaseDC","Uint",0,"Uint",hdc)
	Format:=A_FormatInteger
	SetFormat,Integer,H
	color:=(InStr(Options,"RGB") ? (((Color&255)<<16)+(((Color>>8)&255)<<8)+(Color>>16)) : (color))
	SetFormat,Integer,%Format%
	If color=0x0
		color:= "0x000000"
	else if Strlen(color)<8
		color:=(Strlen(color)>4 ? "0x00" : "0x0000") SubStr(color,3)

	ErrorLevel=0
	return color ""
}

A_ISAdmin(){
	static SC_MANAGER_LOCK = 0x8,ERROR_SERVICE_DATABASE_LOCKED = 1055
	h:=DllCall("Advapi32\OpenSCManager","UInt",0,"UInt",0,"UInt",SC_MANAGER_LOCK)
	If (h){
		If lock:=DllCall("Advapi32\LockServiceDatabase","UPTR",h)
			return:=1,DllCall("Advapi32\UnlockServiceDatabase","UPTR",lock)
		else if (A_LastError=ERROR_SERVICE_DATABASE_LOCKED)
			return:=1
		DllCall("Advapi32\CloseServiceHandle","UPTR",h)
	}
	return return?return:0
}
A_IPAddress(adapter_index=1){
	global _Struct
	static wsadata:=new _Struct("WORD wVersion,WORD wHighVersion,char szDescription[257],char szSystemStatus[129],USHORT iMaxSockets,USHORT iMaxUdpDg,char *lpVendorInfo"),temp:=VarSetCapacity(start,2),host_name:=new _Struct("char[256]"),inaddr:=new _Struct("{struct{uchar s_b1,uchar s_b2,uchar s_b3,uchar s_b4},struct{ushort s_w1,ushort s_w2},ulong S_addr}")
	if (DllCall("Ws2_32\WSAStartup","USHORT",1,"UInt", wsadata[])) ;Failed (it returns 0 on success).
		return -1
	DllCall("Ws2_32\gethostname","UInt",host_name[],"Int", 256)
	lpHost:=Struct("UPTR *h_name,UPTR *h_aliases,short h_addrtype,short h_length,uint[4] *h_addr_list",DllCall("Ws2_32\gethostbyname","UInt",host_name[],"Cdecl UInt"))
	adapter_count=0
	while (lpHost.h_addr_list[adapter_count+1])
		++adapter_count
	if (adapter_index > adapter_count)
		return "0.0.0.0"
	else {
		inaddr[]:=lpHost.h_addr_list[adapter_index]
		Return Asc(inaddr.s_b1) "." Asc(inaddr.s_b2) "." Asc(inaddr.s_b3) "." Asc(inaddr.s_b4)
	}
}

So we would need many interested users, especially advanced users, who could help to convert nearly all functions and commands from AutoHotkey source to pure AHK code.
After this, having AutoHotkeyMini.dll where many features are already excluded, it should be very easy to compile the smaller AutoHotkey.exe that will be probably 2/5 smaller so around 500 kb.

Now the big question, is it worth it :?: