AutoHotkey Community

It is currently May 26th, 2012, 5:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: March 29th, 2008, 6:58 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775


Edit: The previous < 45 line code is here: ROD-45L.ahk


Last edited by SKAN on May 23rd, 2008, 4:51 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2008, 7:36 pm 
Offline

Joined: November 6th, 2005, 6:43 pm
Posts: 72
Pish, a real hacker would have done it without creating a temporary file. Just kidding, very impressive. :P

(on the serious side... can we have something like MemoryLoadLibrary() built-in to AHK?)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2008, 9:35 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
interiot wrote:
a real hacker would have done it without creating a temporary file


That is not a temporary, but the resultant file. I do not see any meaning in creating a resource file in memory and not write it back to disk.
For record: empty.dll ( 2560 bytes ) was created in RosAsm ( only DllMain ) with ASM source stripped off to save some bytes. Have avoided the dependency by including the DLL as a compressed 1480 byte function.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2008, 8:59 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
Do you plan to develop this any further? :)

A few things I have learned:
  • Named resources aren't worth the trouble:
    • UpdateResource will succeed with lower-case resource names, but you can't reference the resources unless the names are upper-case. (Names seem to be case-insensitive when referencing existing resources.)
    • UpdateResource seems to clip the last character of the resource name. Consistently on XP and Vista, if I pass "NAME", it uses "NAM", so I instead pass "NAME." expecting the "." to be discarded. (I hope I am doing something wrong, but that seems unlikely given that the lpName parameter is a simple null-terminated string.)
  • Internet Explorer controls and ShowHtmlDialog seem able to read images regardless of the resource type. I've tried bmp, png, jpg and gif, with success.
  • Bitmap resources (RT_BITMAP=2) are in the same format as .bmp files, excluding the BITMAPFILEHEADER. In other words, discard the first 14 bytes.
  • Icon resources are a little trickier. Icons in Win32 explains the ICO format in addition to the RT_GROUP_ICON and RT_ICON resource formats.

I also have a custom build of Ahk2Exe which allows a custom bin file to be specified on the command line. I'll upload it if you're interested. (UpdateResource may be applied to AutoHotkeySC.bin the same way it is applied to a resource DLL.)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2008, 2:17 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Quote:
A few things I have learned:


Highly resourceful. Thanks. Most of my success with resources came with brute-force methods.

Lexikos wrote:
Do you plan to develop this any further? :)


I had wished as follows:

Quote:
Dear Mr.Chris,

This is my Wish.

I request a change in behaviour of ahk2exe.exe :
Within Windows Explorer, when I select Compile Script from the context menu, if AutoHotkeySC.bin exists on the same folder as the script, then that version should be used for compilation.

This is to facilitate multiple projects that require seperate internal resources.

Thanks.


I am thinking in following lines:
The user will have to code the script with resource building in the begining part:

Code:
Resource_BeginUpdate( params )

.. one command for each resource

Resource_EndUpdate()


resource.ahk will be the standard library that should take care of :

    1) either creating a empty resource.dll in a_scriptdir
    or copy autohotkeysc.bin to a_scriptdir
    2) add / modify / delete resources as user specification
    3) create a project.ini in a_scriptdir so that these lib functions do not get triggered on every run ( Resource_BeginUpdate() would hash check the source files to see if an update is required )
    4) the project.ini or ( whatever name ) would also be stored as RCDATA resource.
    5) there should be no dllcalls for the user ( atleast for the data retrieval part ) .. but only resource_*() functions that would help to fetch data with single line.
    6) the user would not be dealing with any numbers.. but only filenames and or aliases. the library would take care of assigning numbers
    7) the above would be made possible because resource_*() functions would be referring project.ini stored inside the PE

support for minimum: ICON,BITMAP,VERSION,RCDATA.

What I wonder is:
How to delete the lines between ( and including ) Resource_BeginUpdate() / Resource_EndUpdate() before the script is passed to ahk2exe ?
Resource_BeginUpdate() could check A_IsCompiled and play dead.. but still it will be unneccessary code inside a compiled script.
maybe a new directive that would automatically comment out / ignore a block of commands ( only if A_IsCompiled is true )

Quote:
I also have a custom build of Ahk2Exe which allows a custom bin file to be specified on the command line. I'll upload it if you're interested.


sure ... sure.

Quote:
(UpdateResource may be applied to AutoHotkeySC.bin the same way it is applied to a resource DLL.)


I am aware of.. but
1) I do not compile my scripts. 2) It did not interest me much because my wish was not considered..
but I am very much interested now, because you can make things happen. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2008, 3:01 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
Ahk2Exe_L.zip
Ahk2Exe_L_src.zip
It should be put in the Compiler directory to support function libraries, but you may rename it to coexist with the original Ahk2Exe.
SKAN wrote:
What I wonder is:
How to delete the lines between ( and including ) Resource_BeginUpdate() / Resource_EndUpdate() before the script is passed to ahk2exe ?
Why not use a separate resource script?
Quote:
maybe a new directive that would automatically comment out / ignore a block of commands ( only if A_IsCompiled is true )
That could be done with pre-processing. See for example AHK preprocessor.
Quote:
I do not compile my scripts.
Nor do I, which is why I put a higher priority on finishing my other projects.

I also realised it is possible to extract FileInstall'd files; AutoHotkey itself may simply call FileExtractToMem, which is normally only used to load the script. I think it seems more appropriate to natively support "resources" embedded using FileInstall.

On the other hand, native support for PE resources (perhaps similar to the res protocol) could be used by compiled or uncompiled scripts, with resource DLLs, script-embedded resources or both.

There would probably be a lot of code overlap, so it would be worth supporting both.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2008, 8:14 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Lexikos wrote:


Thanks Lexikos. :D

I will reply after trying it out, but may I know the parameter, please.

:)

Edit: Oh! Okay.. it is in readme.txt along with source.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2008, 4:56 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Dear Lexikos, :)

Earlier I wrote:
I will reply after trying it out


I am still interested!.. though I have to learn/work a lot more ..
Thanks for the tip on RT_BITMAP. I have implemented it and also RT_ICON/RT_GROUP_ICON

The title post has been updated.

Regards, :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2008, 12:47 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
Be warned that my custom build of Ahk2Exe does not support the /NoDecompile option. As far as I can tell, it is not implemented in the downloadable Ahk2Exe source. :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2008, 1:33 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
OH!.. :shock:

I can somewhat understand the concern of Mr.Chris

Did you try my script Lexikos ?

I need some info. I found how to obtain hFont from raw TTF bytestream. It works fine with WM_SETFONT on AHK control.

You have already shown how to refer images from HTML .. but how to use an embedded font .. i.e., use it from HTML ?

I did not try, but my best guess is that WM_SETFONT would not work on an IE control. :roll:

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2008, 8:28 am 
Did you try font embedding with the res-protocol yet?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2008, 8:58 am 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
you've done it finally !
i didn't tried it yet but i believe that i'll need it someday when i making gui scripts for public
though it's resource only, non-programmers can make dlls now.
how sweet it is :) thanks for sharing SKAN!

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 25th, 2008, 2:08 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
n-l-i-d wrote:
Did you try font embedding with the res-protocol yet?


er.. can you repeat the link, please.

heresy wrote:
i didn't tried it yet but i believe that i'll need it someday when i making gui scripts for public


Right now IconEx deals only with resource-icons.., I need to make it read .ICO files too. When done, this script would be built into IconEx

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 25th, 2008, 4:35 pm 
.eot/WEFT (embedded open type), and res protocol (don't know if this works)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 25th, 2008, 5:11 pm 
Offline

Joined: July 14th, 2006, 12:31 am
Posts: 290
Location: Berlin
could i use your work in compile_ahk to manual add resources to a script when it is compiled? a reference to you in the credits would be obvious :-)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group