Jump to content

resource udf


 Share

Recommended Posts

i have put resources.au3 in the include folder, and put reshacker.exe in the autoit directory, but this script still does not play the sound :) any clue why?

#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_File_Add=C:\WINDOWS\Media\ding.wav, sound, TEST_WAV_1
#AutoIt3Wrapper_Run_After=c:\upx.exe  --compress-resources=1 "%out%"


#include "resources.au3"
 
_ResourcePlaySound("TEST_WAV_1")
sleep(1000)
global $warming = true
Link to comment
Share on other sites

  • Moderators

Hi,

For the second time in about a week - the following is on the first page of Zedna's thread (which you can find here):

Adding data to resources can be done simply by #AutoIt3Wrapper directive:

#AutoIt3Wrapper_Res_File_Add=Filename [,Section [,ResName]] <<<< Note that this line is in strike-out!!!!!

#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, rcdata, TEST_TXT_1, 0

Try using the correct syntax and it will work!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi,

For the second time in about a week - the following is on the first page of Zedna's thread (which you can find here):

Adding data to resources can be done simply by #AutoIt3Wrapper directive:

#AutoIt3Wrapper_Res_File_Add=Filename [,Section [,ResName]] <<<< Note that this line is in strike-out!!!!!

#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, rcdata, TEST_TXT_1, 0

Try using the correct syntax and it will work!

M23

i run the example script that is posted and it even doesn't work! thats not the problem
global $warming = true
Link to comment
Share on other sites

  • Moderators

LimeSeed,

Are you using the full version of SciTE, which includes the AutoItWrapper to action the directives?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@LimeSeed

your #AutoIt3Wrapper_Res_File_Add line is for the native AutoIt3Wrapper add resource function

it's currently limited to the RCData type for resources.

_ResourcePlaySound() requires a wav resource stored with resource type WAVE or SOUND only

you need Reshacker for other resource type support other than RCData

you must also use short path names for #AutoIt3Wrapper paths

you can use #AutoIt3Wrapper_Res_File_Add instead of Reshacker for your wave file by using the _ResourcePlaySoundEx() UDF in my example

instead of _ResourcePlaySound() which requires WAVE or SOUND data type supported by Reshacker

best compiled in SciTE so you can see AutoIt3Wrapper and UPX messages in the console.

**watch out for AutoIt3Wrapper changing '--compress-resources=0' to '--compress-resources|0' causing UPX to fail**

the AutoIt3Wrapper resource add functions enumerate added resources sequentially (1,2,3, etc.)

you cannot use your own numbers for resources.

Resources.au3 works with both resource string names and string formatted integers** ('#1','#2','#3', etc.)

(use Reshacker instead of AutoIt3Wrapper resources add functions if using names)

MSDN: FindResource Function - http://msdn.microsoft.com/en-us/library/ms648042.aspx

** Remarks

'If the first character of the string is a pound sign (#),

the remaining characters represent a decimal number that

specifies the integer identifier of the resource's name or type.

For example, the string "#258" represents the integer identifier 258.

To reduce the amount of memory required for a resource,

an application should refer to it by integer identifier instead of by name. '

Good luck

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_File_Add=C:\WINDOWS\Media\ding.wav, RCData, 1
;#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, C:\WINDOWS\Media\ding.wav, WAVE, TEST_WAV_1, 0
;#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, C:\WINDOWS\Media\tada.wav, SOUND, TEST_WAV_2, 0
#AutoIt3Wrapper_Run_After=C:\Progra~1\AutoIt3\Aut2Exe\upx.exe --best --compress-resources=0 "%out%"
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Resources.au3>

If Not @Compiled Then MsgBox(262144,"Compiled WAV resource test", _
"This script must be compiled to work and wav files must be in paths listed")

;_ResourcePlaySound("TEST_WAV_1")
;_ResourcePlaySound("TEST_WAV_2")
$pResInfo = _ResourceGet("#1");default RCDATA type
_ResourcePlaySoundEx($pResInfo)
Sleep(1000)

Func _ResourcePlaySoundEx($pRes, $Flag = 0)
; normally this API is used to play wav files with the first parameter as a string filename
; changing it to a pointer allows playing a wav resource with RCData type
; _ResourcePlaySound() function requires a WAVE or SOUND resource type only
; the current AutoIt3Wrapper resource functions only support RCData type
; MSDN: http://msdn.microsoft.com/en-us/library/ms713269.aspx
; default flag is $SND_SYNC = 0
; Author: rover, modified from Zedna/ProgAndy _ResourcePlaySound() in Resources.au3
    Local Const $SND_NODEFAULT = 0x2
    Local Const $SND_MEMORY = 0x4
    Local $ret = DllCall("winmm.dll", "int", "sndPlaySound", "ptr", $pRes, "int", BitOr($SND_MEMORY, $SND_NODEFAULT, $Flag))
    If @error Then Return SetError(1, 0, 0)
    Return $ret[0]
EndFunc

I see fascists...

Link to comment
Share on other sites

  • Moderators

rover,

I hate to contradict you , but Zedna is quite clear that you must use the #AutoIt3Wrapper_run_after=ResHacker.exe -add line and NOT #AutoIt3Wrapper_Res_File_Add. See Zedna's own examples here.

If I read the Resources UDF thread correctly, it was a problem in SciTE where Jos could not get the _Res_File_Add function to work correctly with all the resource types that Zedna wanted to use. The following is from one of Zedna's posts in the thread:

2008-04-24

- added support for JPG,GIF,PNG in _ResourceSetImageToCtrl() using GDI+ - thanks ProgAndy

- reverted all examples back from #AutoIt3Wrapper_Res_File_Add= to #AutoIt3Wrapper_run_after=ResHacker.exe -add

- updated both ZIP archives

However, I do agree that using Reshacker after compiling without upx is guaranteed to work.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

rover,

I hate to contradict you , but Zedna is quite clear that you must use the #AutoIt3Wrapper_run_after=ResHacker.exe -add line and NOT #AutoIt3Wrapper_Res_File_Add. See Zedna's own examples here.

If I read the Resources UDF thread correctly, it was a problem in SciTE where Jos could not get the _Res_File_Add function to work correctly with all the resource types that Zedna wanted to use. The following is from one of Zedna's posts in the thread:

2008-04-24

- added support for JPG,GIF,PNG in _ResourceSetImageToCtrl() using GDI+ - thanks ProgAndy

- reverted all examples back from #AutoIt3Wrapper_Res_File_Add= to #AutoIt3Wrapper_run_after=ResHacker.exe -add

- updated both ZIP archives

However, I do agree that using Reshacker after compiling without u

px is guaranteed to work.

M23

Melba23

did you try the example and read the explanations?

I pointed out that the current limitation of the AutoIt wrapper resource functions

limits the data type to RCData, the PlaySound API looks for WAVE or SOUND resources only.

the alternate UDF I posted in the example works with the AutoIt wrapper resource RCData type

if you uncomment the other two resource wrapper lines and the two _ResourcePlaySound() lines and compile, all three sounds will play.

If your resource requirements are met by the native resource wrapper (limited to RCData type) functions then you don't need Reshacker.

I have shown how to use the native resource functions as well as the Reshacker method.

Edit correction: _ResourceSetImageToCtrl() works with BMP, GIF, TIF, JPG and PNG using RCData type of AutoIt resource wrapper

If you need resource types other than RCData, such as bitmap, jpeg and png then yes use Reshacker, especially if you want to use names and not numbers for your resources.

for most uses only RCData type is needed. it's the users choice, resources.au3 is usable with either method.

Edit2: I should add the explanation that the first resource wrapper by Jos used names for resources, then was changed to integers added automatically

which broke previous examples.

given the trouble people are having installing Reshacker, they should start with the resource wrapper until they get used to using compiled resources.

I did not post an untested example...

Edited by rover

I see fascists...

Link to comment
Share on other sites

  • Moderators

rover,

Apologies if you took offence at my last post.

I was merely trying to highlight the syntax used by Zedna himself to allow his UDF to work as advertised with all compatible resources.

No reflection on you or your example.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

rover,

Apologies if you took offence at my last post.

I was merely trying to highlight the syntax used by Zedna himself to allow his UDF to work as advertised with all compatible resources.

No reflection on you or your example.

M23

no problem, no offense taken.

you know how people (myself included) sometimes don't read posts thoroughly or jump to conclusions,

and not everyone tries every example code they comment on, so things can be missed.

I was just quick to reiterate to clarify my reasoning.

Cheers

I see fascists...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...