Showing posts with label AutoIt. Show all posts
Showing posts with label AutoIt. Show all posts

2019 VBA reference - equivalents for Autoit, C++ and Java function and keywords

Author: Jeffrey Paesch

This page is started on March 10, 2019. The idea is to provide techniques, function to equivalents well know programming language functions and or statements.
You will enjoy this page, especially if you are the guy that translate code to another code Language,

==========================================================
Return x 
Description: exit function and return a value (java, autoit, and more)
Solution:  functionname = x: exit function (on the same line)
Example:
.    function (arg1,....)
.        if arg1 = "" then myfunction = -1: exit function
.        .......
.        ....
.    end function
==========================================================
void mysub( const int i );.
Description: passing const variable (as of C++) to VBA function. Link with detailed description
Solution: create a local (scope) variable within your function and capture the function byref variables
Example:
.    function (arg1,const_arg1 as integer, const_arg2 as boolean)
.        Dim arg1as integer, arg2 as boolean
.        arg1 = const_arg1,
.        arg2 = const_arg2
.        ' work from here with the local variables arg1 and arg2,
.        .......
.        ....
.    end function
==========================================================
more to come


AutoIt3 and FF.au3 - “error reading registry entry for FireFox” 2017 March


AutoIt3 and FF.au3 is striking again with the “error reading registry entry for FireFox”.
On one of my 32 bit computer the registry key CurrentVersion under  KEY_LOCAL_MACHINE\SOFTWARE\\Mozilla\Mozilla Firefox does not exists. 
Therefore I got the following error when I run the script on this particular computer:
__FFStartProcess ==> General Error: Error reading registry entry for FireFox.
HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\*CurrentVersion*\Main\PathToExe


How to fix?
By replacing the regread function with RegEnumKey function in the __FFStartProcess function. The fixes is highlighted below. 

Note: I made an improvement in how to declare $sHKLM variable.

 ======Before Update

Local $sHKLM = 'HKEY_LOCAL_MACHINE\SOFTWARE\'
If @OSArch <> 'X86' Then $sHKLM &= 'Wow6432Node\'
$sHKLM &= 'Mozilla\Mozilla Firefox'
Local $sFFExe = RegRead($sHKLM & "" & RegRead($sHKLM, "CurrentVersion") & "\Main", "PathToExe")
If @error Then
    SetError(__FFError($sFuncName, $_FF_ERROR_GeneralError, "Error reading registry entry for FireFox." & @CRLF & _
            $sHKLM & "\*CurrentVersion*\Main\PathToExe" & @CRLF & _
            "Error from RegRead: " & @error))
    Return 0
EndIf

====== After Update

Local $sHKLM = 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\'

If @OSArch = 'X86' Then $sHKLM = stringreplace($sHKLM, "Wow6432Node\", "")
$sHKLM &=  Regenumkey($sHKLM ,1) & "\Main"
If @error Then
    SetError(___firefox_Error($sFuncName, $__firefox__ERROR_GeneralError, "Error reading registry entry for FireFox." & @CRLF & _
    $sHKLM&"\*CurrentVersion*\Main\PathToExe" & @CRLF & _
    "Error from RegRead: " & @error))
    Return 0
EndIf