stealFunc - steal only the required functions from a script

Post your working scripts, libraries and tools
User avatar
Avi
Posts: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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] [Download] (Script.ahk)GeSHi © Codebox Plus

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] [Download] (Script.ahk)GeSHi © Codebox Plus

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.
Clipjump Clipboard Manager : More Scripts

Image
User avatar
Learning one
Posts: 118
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: 81
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: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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 !!
Clipjump Clipboard Manager : More Scripts

Image
User avatar
Avi
Posts: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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
Clipjump Clipboard Manager : More Scripts

Image
User avatar
Avi
Posts: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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.
Clipjump Clipboard Manager : More Scripts

Image
User avatar
Avi
Posts: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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
Clipjump Clipboard Manager : More Scripts

Image
User avatar
Avi
Posts: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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.
Clipjump Clipboard Manager : More Scripts

Image
User avatar
MilesAhead
Posts: 226
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: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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.
Clipjump Clipboard Manager : More Scripts

Image
User avatar
MilesAhead
Posts: 226
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: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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 ?
Clipjump Clipboard Manager : More Scripts

Image
User avatar
joedf
Posts: 5414
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

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

06 Jan 2014, 13:07

This is quite an interesting concept :)
User avatar
Avi
Posts: 192
Joined: 30 Sep 2013, 09:51
Facebook: avi.aryan.ap
Google: +AviAryan
GitHub: aviaryan
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.
Clipjump Clipboard Manager : More Scripts

Image

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 8 guests