Jump to content

@FuncName ?


Recommended Posts

I use /RM (Rename Variables and Functions to a shorter name) in the AutoIt3Wrapper GUI to Compile, and have to use #Au3Stripper_Off / #Au3Stripper_On.

@NumParams exists, a @FuncName makes sense to me, and would allow me to workaround limitations in renaming functions.

If @FuncName is a possibility given the way AutoIt is coded, I would open a ticket to request it for a future build, otherwise I would be requesting nonsense out of my .... imagination :) 

Thanks @Jon

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

11 years ago was proposed, and... rejected.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • Developers

This seems to be related to au3stripper.
Please show me a snippet that shows what you are talking about so I can have a look at it.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/rm
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Func SayHiMsgBox($sMsg)
    MsgBox(0,@ScriptName, $sMsg, 20)
EndFunc

Func RunSayHiMsgBox($sFunc, $sMsg)
    Execute($sFunc & '("' & $sMsg & '")')
EndFunc

RunSayHiMsgBox("SayHiMsgBox", "Yellow there   =)")

it will not run compiled but we both know why and how to get around it.

Now about the ticket #1243:

Changed 11 years ago by Valik
Resolution set to Rejected
Status changed from new to closed
Version 3.3.0.0 deleted
No, the macro causes way too much performance degradation. Also, terrible example. You're requesting the feature to write bad code. Not exactly the best way to get it considered.

My request has a different approach/reason and would be available within the function just like @NumParams is.
I know that there is no performance impact implementing it, if it was possible. Now, is it practical / useful to implement such ? ( I believe it is )

Also know that a "function reference map" can be created by au3stripper and/or the coder. Or the coder can patch the *_stripped.au3 and compile that. So is not like "OMG what am I going to do" but I believe a @FuncName goes well with @NumParams.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • Developers

This does make sense it doesn't work as au3stripper has no way of knowing that SayHiMsgBox() is used via the Execute statement.
The simple way to "fix" this is to add this line:

#Au3Stripper_Ignore_Funcs=SayHiMsgBox

It is also very hard to test for this potential issue and create a warning/error, like I do with a Call() statement.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

But do you have an example that shows the real need of such macro?

I mean what is the usage in this case?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Since AutoIt functions are now first-class citizen, passing function names as strings is only calling for trouble.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

17 minutes ago, Jos said:

The simple way to "fix" this is...

..yes, I know. The request for the new macro is if, is not a big deal to implement. Otherwise, meh, no big deal. Is not existent at the moment but if it exited may have been used.

@MrCreatoR, there is no immediate need for it nor I have code that must use it, but I would argue that neither @NumParams is a must have, tho may come in handy.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

As I said above, the correct code would be:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/rm
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Func SayHiMsgBox($sMsg)
    MsgBox(0,@ScriptName, $sMsg, 20)
EndFunc

Func RunSayHiMsgBox($Func, $sMsg)
    Execute(FuncName($Func) & '("' & $sMsg & '")')
EndFunc

RunSayHiMsgBox(SayHiMsgBox, "Yellow there   =)")

Or did I miss something?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

4 minutes ago, jchd said:

Since AutoIt functions are now first-class citizen, passing function names as strings is only calling for trouble.

my understanding of language is limited, both code and human wise. I did not get the "first-class citizen" part. :baby:

As  far as code, say:

Spoiler
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/rm
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; https://www.autoitscript.com/forum/topic/143250-grab-runtime-errors-when-script-is-run-from-a-service/?tab=comments#comment-1009391
If @Compiled Then _AddHookApi("user32.dll", "MessageBoxW", "_Intercept_MessageBoxW", "int", "hwnd;wstr;wstr;uint")
Func _Intercept_MessageBoxW($hWnd, $sText, $sTitle, $iType)
    If $sTitle = "AutoIt Error" Then
;~      ; For example:
;~      ConsoleWriteError($sTitle & " " & $sText & @CRLF)
;~  Else
        Local $aCall = DllCall("user32.dll", "int", "MessageBoxW", _
                "hwnd", $hWnd, _
                "wstr", "My " & $sText, _
                "wstr", "My " & $sTitle, _
                "uint", $iType)
        If @error Or Not $aCall[0] Then Return 0
        Return $aCall[0]
    EndIf
EndFunc   ;==>_Intercept_MessageBoxW
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Let's try it (don't forget to compile)
; Usual message box
MsgBox(0, 'Test', 'Some text')
; Cause array error
Global $aArray[3] = [1, 2, 3]
$aArray[4] = 4 ; !!!!


Func _AddHookApi($sModuleName, $vFunctionName, $vNewFunction, $sRet = "", $sParams = "")
    Local Static $pImportDirectory, $hInstance
    If Not $pImportDirectory Then
        $hInstance = _GetModuleHandle()
        If @error Then Return SetError(1, 0, 0)
        Local $aCall = DllCall("dbghelp.dll", "ptr", "ImageDirectoryEntryToData", _
                "handle", $hInstance, _
                "boolean", 1, _ ; as an image
                "word", 1, _ ; IMAGE_DIRECTORY_ENTRY_IMPORT
                "dword*", 0)
        If @error Or Not $aCall[0] Then Return SetError(2, 0, 0)
        $pImportDirectory = $aCall[0]
    EndIf
    Local $iIsInt = IsInt($vFunctionName)
    Local $iRestore = Not IsString($vNewFunction)
    Local $tIMAGE_IMPORT_MODULE_DIRECTORY
    Local $pDirectoryOffset = $pImportDirectory
    Local $tModuleName
    Local $iInitialOffset, $iInitialOffset2
    Local $iOffset2
    Local $tBufferOffset2, $iBufferOffset2
    Local $tBuffer, $tFunctionOffset, $pOld, $fMatch
    Local Const $PAGE_READWRITE = 0x04
    While 1
        $tIMAGE_IMPORT_MODULE_DIRECTORY = DllStructCreate("dword RVAOriginalFirstThunk;" & _
                "dword TimeDateStamp;" & _
                "dword ForwarderChain;" & _
                "dword RVAModuleName;" & _
                "dword RVAFirstThunk", _
                $pDirectoryOffset)
        If Not DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk") Then ExitLoop
        $tModuleName = DllStructCreate("char Name[64]", $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAModuleName"))
        If DllStructGetData($tModuleName, "Name") = $sModuleName Then ; function from this module
            $iInitialOffset = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk")
            $iInitialOffset2 = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAOriginalFirstThunk")
            If $iInitialOffset2 = $hInstance Then $iInitialOffset2 = $iInitialOffset
            $iOffset2 = 0
            While 1
                $tBufferOffset2 = DllStructCreate("dword_ptr", $iInitialOffset2 + $iOffset2)
                $iBufferOffset2 = DllStructGetData($tBufferOffset2, 1)
                If Not $iBufferOffset2 Then ExitLoop
                If $iIsInt Then
                    If BitAND($iBufferOffset2, 0xFFFFFF) = $vFunctionName Then $fMatch = True ; wanted function
                Else
                    $tBuffer = DllStructCreate("ushort Ordinal; char Name[64]", $hInstance + $iBufferOffset2)
                    If DllStructGetData($tBuffer, "Name") == $vFunctionName Then $fMatch = True ; wanted function
                EndIf
                If $fMatch Then
                    $tFunctionOffset = DllStructCreate("ptr", $iInitialOffset + $iOffset2)
                    _VirtualProtect(DllStructGetPtr($tFunctionOffset), DllStructGetSize($tFunctionOffset), $PAGE_READWRITE)
                    If @error Then Return SetError(3, 0, 0)
                    $pOld = DllStructGetData($tFunctionOffset, 1)
                    If $iRestore Then
                        DllStructSetData($tFunctionOffset, 1, $vNewFunction)
                    Else
                        DllStructSetData($tFunctionOffset, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction, $sRet, $sParams)))
                    EndIf
                    Return $pOld
                EndIf
                $iOffset2 += DllStructGetSize($tBufferOffset2)
            WEnd
            ExitLoop
        EndIf
        $pDirectoryOffset += 20 ; size of $tIMAGE_IMPORT_MODULE_DIRECTORY
    WEnd
    Return SetError(4, 0, 0)
EndFunc   ;==>_AddHookApi

Func _VirtualProtect($pAddress, $iSize, $iProtection)
    Local $aCall = DllCall("kernel32.dll", "bool", "VirtualProtect", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iProtection, "dword*", 0)
    If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
    Return 1
EndFunc   ;==>_VirtualProtect

Func _GetModuleHandle($vModule = 0)
    Local $sParamType = "ptr"
    If IsString($vModule) Then $sParamType = "wstr"
    Local $aCall = DllCall("kernel32.dll", "ptr", "GetModuleHandleW", $sParamType, $vModule)
    If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
    Return $aCall[0]
EndFunc   ;==>_GetModuleHandle

 

..something that has many other function in the function that is excluded, will exclude a bunch of them too in the /rm case.

Again, I or anyone, can edit AutoIt3Wrapper and do anything. The "passing function names as strings is only calling for trouble" part, I don't know, how should I do different in the case of this function ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

You also could do something like this:

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Before=%autoitdir%\AutoIt3.exe "%in%" /AddFuncName
#Au3Stripper_Parameters=/rm
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

If $CmdLine[0] And StringInStr($CmdLineRaw, '/AddFuncName') Then
    $sRead = FileRead(@ScriptFullPath)
    $sRead = StringRegExpReplace($sRead, '(?mi)^((?:Volatile\h+)?\h*Func\h+)(\w+)([^\r\n]+)(?:\r?\n\t+Local Const \$FuncName = "\w+")?', '\1\2\3' & @CRLF & @TAB & 'Local Const $FuncName = "\2"')
    
    $hFile = FileOpen(@ScriptFullPath, 2)
    FileWrite($hFile, $sRead)
    FileClose($hFile)
    
    Exit
EndIf

Func Func1($sVar)
    ;Func1 stuff
EndFunc

Func Func2($sVar1, $sVar2)
    ;Func2 stuff
EndFunc

 

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

O I see now. That's because DllCallbackRegister() and possibly friends require a function name as a string and not as a function.

That's a defect in these function! If not already done, opening a Trac ticket to this effect would be a good idea while Jon is working on AutoIt.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

 

5 minutes ago, jchd said:

while Jon is working on AutoIt

...I wanted to see if, given that he is looking at the code right now, the idea was sound and easy to just add the macro.

As far as the DllCallbackRegister() ticket, I would not be able to defend the point if I had to, so ..., if you could present it in the ticket system, it would have a better future than if I did.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Depends on what others think.  I for one have no use of AutoIt for my daily job ans it's been ages I've not used DllCallbackRegister and I never used Au3Stripper. So my point of view is rather moot.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

The Au3Stripper makes a smaller executable. The fact that you are in this forum now is that you are fond of AutoIt. You have a set of skills that may come in useful right now and if there is no great opposition, a compelling presentation can bring in a world of opportunities. Now if this is not possible due time or real life constrains, then that is that.
I for once, don't have the know how to request a change, as again, could not defend the point.

I guess there is a MVP forum, where ideas can be posted and a pool, would determine, yay or nay :) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Posted to the MVP forum.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

your example of the use of FuncName(), gave me a clue. Thanks to that I've found a way to eat my cake and have it too implement it :D

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/rm
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; https://www.autoitscript.com/forum/topic/143250-grab-runtime-errors-when-script-is-run-from-a-service/?tab=comments#comment-1009391

;Global $f__Intercept_MessageBoxW = FuncName(_Intercept_MessageBoxW) ; <--- pointer by jchd

If @Compiled Then _AddHookApi("user32.dll", "MessageBoxW", FuncName(_Intercept_MessageBoxW), "int", "hwnd;wstr;wstr;uint")
Func _Intercept_MessageBoxW($hWnd, $sText, $sTitle, $iType)
    If $sTitle = "AutoIt Error" Then
;~      ; For example:
;~      ConsoleWriteError($sTitle & " " & $sText & @CRLF)
;~  Else
        Local $aCall = DllCall("user32.dll", "int", "MessageBoxW", _
                "hwnd", $hWnd, _
                "wstr", "My " & $sText, _
                "wstr", "My " & $sTitle, _
                "uint", $iType)
        If @error Or Not $aCall[0] Then Return 0
        Return $aCall[0]
    EndIf
EndFunc   ;==>_Intercept_MessageBoxW
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Let's try it (don't forget to compile)
; Usual message box
MsgBox(0, 'Test', 'Some text')
; Cause array error
Global $aArray[3] = [1, 2, 3]
$aArray[4] = 4 ; !!!!



Func _AddHookApi($sModuleName, $vFunctionName, $vNewFunction, $sRet = "", $sParams = "")
    ; $vNewFunction = String($vNewFunction) <-- not needed
    Local Static $pImportDirectory, $hInstance
    If Not $pImportDirectory Then
        $hInstance = _GetModuleHandle()
        If @error Then Return SetError(1, 0, 0)
        Local $aCall = DllCall("dbghelp.dll", "ptr", "ImageDirectoryEntryToData", _
                "handle", $hInstance, _
                "boolean", 1, _ ; as an image
                "word", 1, _ ; IMAGE_DIRECTORY_ENTRY_IMPORT
                "dword*", 0)
        If @error Or Not $aCall[0] Then Return SetError(2, 0, 0)
        $pImportDirectory = $aCall[0]
    EndIf
    Local $iIsInt = IsInt($vFunctionName)
    Local $iRestore = Not IsString($vNewFunction)
    Local $tIMAGE_IMPORT_MODULE_DIRECTORY
    Local $pDirectoryOffset = $pImportDirectory
    Local $tModuleName
    Local $iInitialOffset, $iInitialOffset2
    Local $iOffset2
    Local $tBufferOffset2, $iBufferOffset2
    Local $tBuffer, $tFunctionOffset, $pOld, $fMatch
    Local Const $PAGE_READWRITE = 0x04
    While 1
        $tIMAGE_IMPORT_MODULE_DIRECTORY = DllStructCreate("dword RVAOriginalFirstThunk;" & _
                "dword TimeDateStamp;" & _
                "dword ForwarderChain;" & _
                "dword RVAModuleName;" & _
                "dword RVAFirstThunk", _
                $pDirectoryOffset)
        If Not DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk") Then ExitLoop
        $tModuleName = DllStructCreate("char Name[64]", $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAModuleName"))
        If DllStructGetData($tModuleName, "Name") = $sModuleName Then ; function from this module
            $iInitialOffset = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk")
            $iInitialOffset2 = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAOriginalFirstThunk")
            If $iInitialOffset2 = $hInstance Then $iInitialOffset2 = $iInitialOffset
            $iOffset2 = 0
            While 1
                $tBufferOffset2 = DllStructCreate("dword_ptr", $iInitialOffset2 + $iOffset2)
                $iBufferOffset2 = DllStructGetData($tBufferOffset2, 1)
                If Not $iBufferOffset2 Then ExitLoop
                If $iIsInt Then
                    If BitAND($iBufferOffset2, 0xFFFFFF) = $vFunctionName Then $fMatch = True ; wanted function
                Else
                    $tBuffer = DllStructCreate("ushort Ordinal; char Name[64]", $hInstance + $iBufferOffset2)
                    If DllStructGetData($tBuffer, "Name") == $vFunctionName Then $fMatch = True ; wanted function
                EndIf
                If $fMatch Then
                    $tFunctionOffset = DllStructCreate("ptr", $iInitialOffset + $iOffset2)
                    _VirtualProtect(DllStructGetPtr($tFunctionOffset), DllStructGetSize($tFunctionOffset), $PAGE_READWRITE)
                    If @error Then Return SetError(3, 0, 0)
                    $pOld = DllStructGetData($tFunctionOffset, 1)
                    If $iRestore Then
                        DllStructSetData($tFunctionOffset, 1, $vNewFunction)
                    Else
                        DllStructSetData($tFunctionOffset, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction, $sRet, $sParams)))
                    EndIf
                    Return $pOld
                EndIf
                $iOffset2 += DllStructGetSize($tBufferOffset2)
            WEnd
            ExitLoop
        EndIf
        $pDirectoryOffset += 20 ; size of $tIMAGE_IMPORT_MODULE_DIRECTORY
    WEnd
    Return SetError(4, 0, 0)
EndFunc   ;==>_AddHookApi

Func _VirtualProtect($pAddress, $iSize, $iProtection)
    Local $aCall = DllCall("kernel32.dll", "bool", "VirtualProtect", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iProtection, "dword*", 0)
    If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
    Return 1
EndFunc   ;==>_VirtualProtect

Func _GetModuleHandle($vModule = 0)
    Local $sParamType = "ptr"
    If IsString($vModule) Then $sParamType = "wstr"
    Local $aCall = DllCall("kernel32.dll", "ptr", "GetModuleHandleW", $sParamType, $vModule)
    If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
    Return $aCall[0]
EndFunc   ;==>_GetModuleHandle

..and now compiles just fine. 

Edited by argumentum
better code

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Recent change in Au3Stripper /rsln   .... releated to @ScriptLineNumber is enought replacement for @FuncName.
@FuncName will be uselles when you use Au3Stripper with /RM but @ScriptLineNumber will still fit the needs.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

"thinking does not hurt, ........ .......... but it takes time", lol, I like that.
Sharing may hurt but it brings about knowledge and solutions. It never occur to me to use FuncName() the way I did without sharing ( for my benefit ) and that knowing would not let me ask for the requested macro, but it also brought about DllCallbackRegister() incongruencies in reference to the language's(AutoIt) growth ( for the benefit of all ), so, ...sharing is good, annoying at times, but good overall.
I never meant to use the @FuncName for debugging as @ScriptLineNumber is all that is needed along with the error type ( in my view ), but I guess it could be used for that too, but then again, what line in the function. So, no, not for debugging.

So to wrap it up: 
Static was not in previous versions but it came to exist and is handy to have.
@FuncName would be complementary/related to @NumParams, if it existed. That's all. :gathering:

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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...