Upcoming Ahk2Exe changes
Re: Upcoming Ahk2Exe changes
The FileInstall that is never executed is just an old trick. you no longer to use that because of the directives
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]
Re: Upcoming Ahk2Exe changes
No.2. Do i still need to use ;@Ahk2Exe-AddResource SNAP.wav ?
Yes.3. Should the function call "PlaySound ( Sound)" be used to play the sound instead of "SoundPlay" ?
No. If you put into autoexec section, then the file will be extracted.4. Shouldn't "FileInstall, SNAP.wav, - " be in the autoexec section at the top of my code along with "ResRead( Sound, "SNAP.wav" )" ?
If you want to put in autoexec section, use this instead:
Code: Select all
If !A_IsCompiled
FileInstall, SNAP.wav, -
Re: Upcoming Ahk2Exe changes
Ok so i got the script playing sounds from the autoexec section; however, when i use PlaySound (SoundRef) in the "hotkey" section they NEVER play. Also this ONLY works in XP sound wise and not in 8.1 at all (no sounds are played in ANY section) even though i do see win 8.1 has the winmm.dll . Any thoughts ?
Re: Upcoming Ahk2Exe changes
Make sure you have executed ResRead( Sound, "test.wav" ) before PlaySound.Skrell wrote:when i use PlaySound (SoundRef) in the "hotkey" section they NEVER play
Re: Upcoming Ahk2Exe changes
Here try this:
Code: Select all
#NoEnv
ResRead( tada, "tada.wav" )
return
#p::
PlaySound(tada)
return
PlaySound( ByRef Sound ) {
Return DllCall( "winmm.dll\PlaySound" ( A_IsUnicode ? "W" : "A" ), UInt,&Sound, UInt,0
, UInt, 0x6 ) ; SND_MEMORY := 0x4 | SND_NODEFAULT := 0x2
}
FileInstall, C:\Windows\Media\tada.wav, -
ResRead( ByRef Var, Key ) {
VarSetCapacity( Var, 128 ), VarSetCapacity( Var, 0 )
If ! ( A_IsCompiled ) {
FileGetSize, nSize, %Key%
FileRead, Var, *c %Key%
Return nSize
}
If hMod := DllCall( "GetModuleHandle", UInt,0 )
If hRes := DllCall( "FindResource", UInt,hMod, Str,Key, UInt,10 )
If hData := DllCall( "LoadResource", UInt,hMod, UInt,hRes )
If pData := DllCall( "LockResource", UInt,hData )
Return VarSetCapacity( Var, nSize := DllCall( "SizeofResource", UInt,hMod, UInt,hRes ) )
, DllCall( "RtlMoveMemory", Str,Var, UInt,pData, UInt,nSize )
Return 0
}
Re: Upcoming Ahk2Exe changes
Code: Select all
ResRead(tada, "C:\Windows\Media\tada.wav")
Re: Upcoming Ahk2Exe changes
I'm trying to execute the wav from within the compiled executable that's why I did that. There should be a fileinstall function in my code which is supposed to build the wav into the executable then I'm trying to make a reference to it so that I can play it with PlaySound.HotKeyIt wrote:Code: Select all
ResRead(tada, "C:\Windows\Media\tada.wav")
Re: Upcoming Ahk2Exe changes
The recource will be called the same as FileInstall, so you cannot use "tada.wav", you will need the full path
Re: Upcoming Ahk2Exe changes
Omg.... I had no idea!! I'll try that asap!HotKeyIt wrote:The recource will be called the same as FileInstall, so you cannot use "tada.wav", you will need the full path
Did you get it working with my hotkey code and your adjustment?
*UPDATE* this still does NOT work for a compiled executable. Please try it for yourself.
what version of windows and what version of the ahk2exe compiler are you using ? Is there some flag or something i need to set for the compiler?
I've tried it now on both win7 and win8.1 PCs and neither work for the compiled version. There is definitely some small thing i'm missing here.
Re: Upcoming Ahk2Exe changes
Found the problem btw! The ResRead function does NOT work with 64bit OSes!
Re: Upcoming Ahk2Exe changes
Hope it will support to adding resources to other Resource Type.
Syntax:
Example usage:
Syntax:
Code: Select all
;@Ahk2Exe-AddResourceEx [File], [Resource Type], [Resource ID]
Code: Select all
;@Ahk2Exe-AddResourceEx image\test.gif, GIF, 110
;@Ahk2Exe-AddResourceEx image\test.png, PNG, 456
- Attachments
-
- 2015-08-30_114428.png (3.89 KiB) Viewed 20845 times
Re: Upcoming Ahk2Exe changes
It already supported!tmplinshi wrote:Hope it will support to adding resources to other Resource Type.
Syntax:Example usage:Code: Select all
;@Ahk2Exe-AddResourceEx [File], [Resource Type], [Resource ID]
Code: Select all
;@Ahk2Exe-AddResourceEx image\test.gif, GIF, 110 ;@Ahk2Exe-AddResourceEx image\test.png, PNG, 456
Code: Select all
;@Ahk2Exe-AddResource *GIF image\gif.gif, 110
;@Ahk2Exe-AddResource *PNG image\gif.gif, 456
Re: Upcoming Ahk2Exe changes
Hi
what's the current state of this project?
The link in the first post is from January, the latest changes at Github are from August. The help at http://fincs.ahk4.net/Ahk2ExeDirectives.htm says "only BMP and DIB" as resource, the posting above says "also GIF and PNG" ....
Please update us with current information
what's the current state of this project?
The link in the first post is from January, the latest changes at Github are from August. The help at http://fincs.ahk4.net/Ahk2ExeDirectives.htm says "only BMP and DIB" as resource, the posting above says "also GIF and PNG" ....
Please update us with current information
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
Re: Upcoming Ahk2Exe changes
If I compile my autohotkey script to exe, will it work at every computer?
Re: Upcoming Ahk2Exe changes
It should.
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]
-
- Posts: 463
- Joined: 24 Jan 2014, 22:28
Re: Upcoming Ahk2Exe changes
Well.. more or less. Obviously it would only run under Windows.
And I think AHK_L dropped official support for everything prior to XP at some point.
And if you compile it as 64bit, it won't run on 32bit computers.
And I think AHK_L dropped official support for everything prior to XP at some point.
And if you compile it as 64bit, it won't run on 32bit computers.
Re: Upcoming Ahk2Exe changes
I want get the text from the html resource of the compiled script.
I was able to get it from another script with
but i want it from the same exe. Like the Sound.wave Example
I tried this, but there seems to be something wrong
Thanks for advice
Code: Select all
;@Ahk2Exe-AddResource test.html
;compiled to test.exe
Code: Select all
msgbox % getResource("test.exe","#23","test.html")
return
getResource(inFilePath,resourceType,resourceId){
;https://msdn.microsoft.com/en-us/library/windows/desktop/ms648009%28v=vs.85%29.aspx
;inFilePath somefile.exe
;resourceType #23 for html; #10 js,css, >AUTOHOTKEY SCRIPT<
;resourceId Ex.: resource test.html .. >AUTOHOTKEY SCRIPT<
hModule := DllCall("LoadLibrary", Str,inFilePath)
hResInfo := DllCall("FindResource", UInt,hModule, Str,resourceId, Str,resourceType)
hResData := DllCall("LoadResource", UInt,hModule, UInt,hResInfo)
pResData := DllCall("LockResource", UInt,hResData)
resSize := DllCall("SizeofResource", UInt,hModule, UInt,hResInfo)
return StrGet(pResData, resSize, "UTF-8")
}
I tried this, but there seems to be something wrong
Code: Select all
get2Resource(resourceType,resourceId){
;----
hModule := DllCall("GetModuleHandle", Uint,0)
;hModule := DllCall("GetModuleHandle", Ptr,0)
;hResInfo := DllCall("FindResource", UInt,hModule, Str,resourceId, Str,resourceType)
hResInfo := DllCall("FindResource", UInt,hModule, Str,resourceId, UInt,23)
;----
hResData := DllCall("LoadResource", UInt,hModule, UInt,hResInfo)
pResData := DllCall("LockResource", UInt,hResData)
resSize := DllCall("SizeofResource", UInt,hModule, UInt,hResInfo)
return StrGet(pResData, resSize, "UTF-8")
}
Re: Upcoming Ahk2Exe changes
Code: Select all
;@Ahk2Exe-AddResource test.html
msgbox, % ResRead( "test.html" , "23")
return
ResRead(Key, resourceType) {
;for textresources only
If ! ( A_IsCompiled )
FileRead, Var, %Key%
return Var
if hMod := DllCall( "GetModuleHandle", ptr, 0, ptr )
if hRes := DllCall("FindResource", Ptr, 0, Str, Key, Ptr, resourceType, UPtr)
if hData:= DllCall("LoadResource", Ptr, 0, Ptr, hRes, UPtr)
if pData :=DllCall("LockResource", Ptr, hData, UPtr)
if nSize :=DllCall("SizeofResource", ptr, hMod, ptr, hres, uint)
return StrGet(pData, nSize, "UTF-8")
Return 0
}
}
Edit: The former function only worked with X32.
This ResRead() read Textresources also with X64 Autohotkey.
Re: Upcoming Ahk2Exe changes
I changed the above function to work with X32 and X64 Autohotkey.
I think it would be nice to integrate something like this in AHK2exe and add a Varname to the resource directive. So it will be very easy to access a embedded resource like text, html, images, sound and others.
I think it would be nice to integrate something like this in AHK2exe and add a Varname to the resource directive. So it will be very easy to access a embedded resource like text, html, images, sound and others.
Re: Upcoming Ahk2Exe changes
I combined the example from tmplinshi with mine from above to get text and binary resources with one function.
Code: Select all
;@Ahk2Exe-AddResource test.html
;@Ahk2Exe-AddResource C:\Windows\Media\tada.wav
;@Ahk2Exe-AddResource C:\Program Files (x86)\Microsoft Office\Office14\MEDIA\APPLAUSE.WAV
;http://www.angusj.com/resourcehacker/
;https://autohotkey.com/boards/viewtopic.php?f=24&t=521
If !A_IsCompiled
{
FileRead, tada, *c C:\Windows\Media\tada.wav
FileRead, tada1, *c C:\Program Files (x86)\Microsoft Office\Office14\MEDIA\APPLAUSE.WAV
FileRead, test, test.html
}
else
{
ResRead(tada, "tada.wav" , 10)
ResRead(tada1, "APPLAUSE.wav" , 10)
ResRead(test, "test.html" , 23)
}
#p::PlaySound(tada)
!p::PlaySound(tada1)
^p::msgbox, % test
return
ResRead( ByRef Var, Key , resourceType) {
;resourceType as in fincs directives.ahk: 2 bmp,dib ; 23 htm,html,mht ; 24 manifest; 10 for the rest
VarSetCapacity( Var, 128 ), VarSetCapacity( Var, 0 )
SplitPath, Key, , , ext
bin=1
; define textfile extensions
if ext in txt,js,css,html,htm,mht
bin=0
if hMod := DllCall( "GetModuleHandle", ptr, 0, ptr )
if hRes := DllCall("FindResource", Ptr, 0, Str, Key, Ptr, resourceType, UPtr)
if hData:= DllCall("LoadResource", Ptr, 0, Ptr, hRes, UPtr)
if pData :=DllCall("LockResource", Ptr, hData, UPtr)
if !bin
if nSize :=DllCall("SizeofResource", "ptr", hMod, "ptr", hres, "uint")
Return Var := StrGet(pData, nSize, "UTF-8")
if bin
Return VarSetCapacity( Var, nSize := DllCall( "SizeofResource", UInt,hMod, UInt,hRes ) )
, DllCall( "RtlMoveMemory", Str,Var, UInt,pData, UInt,nSize )
Return 0
}
PlaySound( ByRef Sound ) {
Return DllCall( "winmm.dll\PlaySound" ( A_IsUnicode ? "W" : "A" ), UInt,&Sound, UInt,0
, UInt, 0x6 ) ; SND_MEMORY := 0x4 | SND_NODEFAULT := 0x2
}
Who is online
Users browsing this forum: No registered users and 17 guests