stealFunc - steal only the required functions from a script

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

stealFunc - steal only the required functions from a script

29 Dec 2013, 08:43

stealFunc v0.12

stealFunc is a function-oriented script (tool) to extract only the required functions from an ahk library .
It recursively processes the library file to only extract functions that are minimally needed.
From v0.1 , it has feature to scan a autohotkey script snippet and extract the foreign functions that are used in that script from another given script.

EXAMPLE USE -
The following function is based on the gdip library

Code: Select all

SetImagetoClipboard( pImage ){
	;Sets some Image file to Clipboard
	PToken := Gdip_Startup()
	pBitmap := Gdip_CreateBitmapFromFile(pImage)
	Gdip_SetBitmaptoClipboard(pBitmap)
	Gdip_DisposeImage( pBitmap )
	Gdip_Shutdown( PToken)
}
As you see it uses the following functions from Gdip lib-
Gdip_Startup
Gdip_CreateBitmapFromFile
Gdip_DisposeImage
Gdip_shutdown
gdip_setbitmaptoclipboard
These functions in the lib may be dependent on other functions in the lib which in turn may be dependent on more functions and so on...
Extracting only the needed functions manually can get tedious.
So to shorten the process, I made this script which is presented as function .

Code: Select all

return_script := stealFunc(function_list, function_file) 
;EXAMPLE
Clipboard := stealFunc("Gdip_Startup`nGdip_SetBitmaptoClipboard`nGdip_CreateBitmapFromFile`nGdip_DisposeImage`nGdip_Shutdown", "<path_to_gdip_lib>")
The script also has a gui added for user convenience and can be commented out anytime.


Below are screenshots of the GUI in action.
Spoiler
Tip - To check if the extracted file is OK and doesn't contain bugs, run it as a separate script. If everything is OK , you will not see an error.


DOWNLOAD Script

DOCUMENTATION
Last edited by Avi on 08 Aug 2014, 05:02, edited 6 times in total.
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image
User avatar
Learning one
Posts: 173
Joined: 04 Oct 2013, 13:59
Location: Croatia
Contact:

Re: stealFunc - steal only the required functions from a scr

30 Dec 2013, 13:29

Good idea and good job Avi! :) Thanks for sharing. :)
User avatar
budRich
Posts: 82
Joined: 29 Sep 2013, 16:52
Location: Wermland
Contact:

Re: stealFunc - steal only the required functions from a scr

30 Dec 2013, 15:45

This will come in handy, thank you wizard.
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

Re: stealFunc - steal only the required functions from a scr

30 Dec 2013, 23:51

LearningOne wrote:Good idea and good job Avi! :) Thanks for sharing. :)
Thanks
budRich wrote:This will come in handy, thank you wizard.
:D Yes it does come handy. I formerly used gdip.ahk worth 95 kb in Clipjump compiled exe but now I find that what I really needed was just 12 kb. !! Huge Save !!
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

Re: stealFunc - steal only the required functions from a scr

31 Dec 2013, 01:03

v0.1
  • Added feature to extract used functions from an ahk script (snippet) in addition to listing them manually. This should make the process a lot faster. See Documentation for more info
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

Re: stealFunc - steal only the required functions from a scr

02 Jan 2014, 05:51

Guest10 wrote:any other examples? :ugeek:
I have only tried it on Gdip and SM_Maths as I needed them. Just now tried it on another lib RichEdit for creating an example. I will soon put them in the documentation.
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

Re: stealFunc - steal only the required functions from a scr

02 Jan 2014, 06:44

stealFunc v0.12
* added `r to the output
* little bug fix with block comments
* fixed bugs with nested functions
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

Re: stealFunc - steal only the required functions from a scr

02 Jan 2014, 06:45

Guest10 wrote:any other examples? :ugeek:
please see documentation. Now I provide 3 examples and thanks to you, I discovered 2 bugs while making them.
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image
User avatar
MilesAhead
Posts: 232
Joined: 03 Oct 2013, 09:44

Re: stealFunc - steal only the required functions from a scr

03 Jan 2014, 10:54

Script link works but Documentation just hangs.
"My plan is to ghostwrite my biography. Then hire another writer to put his
name on it and take the blame."

- MilesAhead
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

Re: stealFunc - steal only the required functions from a scr

04 Jan 2014, 02:09

MilesAhead wrote:Script link works but Documentation just hangs.
What do you mean ? Is the doc link invalid OR is an example is doc hanging the script ?
There was an error in example 1 (5 gdip functions) of the doc which I have fixed now.
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image
User avatar
MilesAhead
Posts: 232
Joined: 03 Oct 2013, 09:44

Re: stealFunc - steal only the required functions from a scr

04 Jan 2014, 15:34

I mean when I click the link Documentation I watch my cursor spin forever. I could get the script. Not the docs.
"My plan is to ghostwrite my biography. Then hire another writer to put his
name on it and take the blame."

- MilesAhead
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

Re: stealFunc - steal only the required functions from a scr

05 Jan 2014, 00:25

MilesAhead wrote:I mean when I click the link Documentation I watch my cursor spin forever. I could get the script. Not the docs.
I don't know . The page is light and loads quickly.
Tried URLDownloadToFile ?
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image
User avatar
joedf
Posts: 8953
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: stealFunc - steal only the required functions from a scr

06 Jan 2014, 13:07

This is quite an interesting concept :)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
Avi
Posts: 193
Joined: 30 Sep 2013, 09:51
Location: India
Contact:

Re: stealFunc - steal only the required functions from a scr

07 Jan 2014, 07:38

joedf wrote:This is quite an interesting concept :)
:D :D I know.
Writes at Dev Letters

Clipjump Clipboard Manager : More Scripts (updated 2019)

Image

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 255 guests