Jump to content

Advanced DllCall and DllStruct AutoIt Code Generator BETA v0.6


Recommended Posts

Result = Problem while creating the oIE object, check internet connection

But i have a proper connection. And IE is in my pc.

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to post
Share on other sites
5 hours ago, JohnOne said:

I admire your patience, I've threatened to do this in the past, but dont have of it.

I'll certainly provide some feedback of testion when I get the time.

Thanks for share.

Thank you, I look forward to see what you think :D

2 hours ago, kcvinu said:

Result = Problem while creating the oIE object, check internet connection

But i have a proper connection. And IE is in my pc.

Oh, i cannot update the script right now, because im not home but for fast fix, you can go into parser.au3 @ line 31 you will find this

; timeout
    _IELoadWait($oIE, 1, 10000)

 

Edited by tarretarretarre
TypOSSss
Link to post
Share on other sites

30+ downloads and no comments?

I have updated the script
 

Update 0.2

  • Fixed some minor issues
  • Added highlight for a more pleasent view (Check OT)
  • Fixed minor bugs
  • Made it run faster when working with the same URL (It dosent load the page entierly)
  • No struct search is now done when no POINTER is used in the call
  • Added more options for the user

 

/Tarre

Link to post
Share on other sites
4 minutes ago, JohnOne said:

I have a question.

I notice the pakaged autoitobject dll files were modified less than a week ago, who modified them?

Hmm less than a week ago, that might be GIT removing CRLF when i commit, I dont use the official AO release either, the one in here is from here:

 

Link to post
Share on other sites
9 minutes ago, JohnOne said:

"Problem while creating the oIE object, check internet connection"

Win 10 x64, this machine.

thats weird, its  only a Timeout for _ieNavigate

 

Try change line 29 @ parser.au3 to $oIE = _IECreate($sUrl, 0, $___DeveloperMode, 1)

And remove _IELoadWait($oIE, 1, 40000) @ parser.au3

I'm not close to a Win10 machine, so i cannot test this now im afraid.

 

/Tarre

Link to post
Share on other sites

"Unable to read <pre>*</pre> from $sHTML"

--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function _IELoadWait, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (code)
! COM Error ! Number: 0x0, ScriptLine: 102, Reason: Variable must be of type 'Object'.
! COM Error ! Number: 0x0, ScriptLine: 125, Reason: Variable must be of type 'Object'.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites
5 minutes ago, JohnOne said:

Okay i have the same IE version,

If you run this in a new script

#include <string.au3>
#include <array.au3>
#include <ie.au3>

Local $oIE = _IECreate("https://msdn.microsoft.com/en-us/library/windows/desktop/ms633515%28v=vs.85%29.aspx")
Local $sHTML = _IEBodyReadHTML($oIE)
Local $Try = _StringBetween($sHTML, "<pre>", "</pre>")

_ArrayDisplay($try)

_IEQuit($oIE)

Could you print the array?

And thank you for the input, it really helps!

Link to post
Share on other sites

Actually I get the array intermittently.

about 50/50

EDIT:

So I've tried the code again, when it gets past the last error, next is no c++ syntax found on page.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites
3 minutes ago, JohnOne said:

Actually I get the array intermittently.

about 50/50

Alright, it seems like autoit tries to read the data while the page is not fully loaded.


Could you try this script and see if you get a consistant array

 

#include <string.au3>
#include <array.au3>
#include <ie.au3>

Local $oIE = _IECreate("https://msdn.microsoft.com/en-us/library/windows/desktop/ms633515%28v=vs.85%29.aspx")
Local $sHTML = _IEBodyReadHTML($oIE)
Local $try

Local $timerinit = TimerInit()

Do
    ;Exit loop after 10 sec of failure
    if TimerDiff($timerinit) > 10000 Then ExitLoop
    $try = _StringBetween($sHTML, "<pre>", "</pre>")
    Sleep(100)
Until IsArray($try)

_ArrayDisplay($try)


_IEQuit($oIE)

 

Link to post
Share on other sites

why not use InetGet ?

#include <string.au3>
#include <array.au3>

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

;~ Local $oIE = _IECreate("https://msdn.microsoft.com/en-us/library/windows/desktop/ms633515%28v=vs.85%29.aspx")
;~ Local $sHTML = _IEBodyReadHTML($oIE)
Local $sHTML = Example( "https://msdn.microsoft.com/en-us/library/windows/desktop/ms633515%28v=vs.85%29.aspx" )
ConsoleWrite($sHTML&@CRLF)
Local $try
Local $timerinit = TimerInit()
Do
    ;Exit loop after 10 sec of failure
    if TimerDiff($timerinit) > 10000 Then ExitLoop
    $try = _StringBetween($sHTML, "<pre>", "</pre>")
    Sleep(100)
Until IsArray($try)
_ArrayDisplay($try)

Func Example($sIn)
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = _WinAPI_GetTempFileName(@TempDir)
    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet($sIn, $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($sFilePath)
    ; Close the handle returned by InetGet.
    InetClose($hDownload)
    Local $sTxt = FileRead($sFilePath)
;~     ; Display details about the total number of bytes read and the filesize.
;~     MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _
;~             "The total filesize: " & $iFileSize)
    ; Delete the file.
    FileDelete($sFilePath)
    Return $sTxt
EndFunc   ;==>Example

 

Edited by argumentum
show some code
Link to post
Share on other sites
1 minute ago, argumentum said:

why not use InetGet ?

Yeah I could, but _Ie Library should work on Win10, but if its not consistant at all, i will re-write all the _Ie elements with InetGet, but so far ive only tested on IE 9 and IE 11 on Win 7 64 bit

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By FrancescoDiMuro
      Good morning Forums 
      In these days, I am working on a project that involved me to use some Windows APIs to obtain some information about Terminal Servers.
      I'm doing this using wtsapi32.dll in a VBA Project, but, the lack of knowledge about few things threated in the articles make this quite difficult to
      implement and understand at the same time.
      The most difficult thing I'm facing is "translating" C/C++ functions or struct in VBA when pointers are used, or pointers of pointers, and so on.
      Since VBA seems to not have a pointer type, to make those functions work I need to implement other functions taken from other DLLs, and this confuses me a lot.
      For example, starting from this code, I splitted all the functions and all the definitions to understand why they are there, and why I need to use them.
      At the end, I've found out that the code I was going to implement starting from the functions provided in the Microsoft Docs won't be ever be able to work without some supplementary functions which are not mentioned anywhere.
      So, I was wondering if someone would please point me out to a good and practical exaplanation about pointers (in general) or specifically for VBA, because I need to use them quite often in these days, and I'd like to understand what I am doing.
      Thanks in advance.

      Best Regards and Stay at home 🏡
       
    • By IndianSage
      Hi,
      My AutoIt script is as folllows:
      ;use for calling function add2NosA in dll ;Local $vNo1 = 33 ;Local $vNo2 = 11 ;use for calling function sortNos in dll Local $vNo1 = [11,7,9] Local $vNo2 = [1,3,2] ; _ArrayDisplay($vNo1, "vNo1 display") ; _ArrayDisplay($vNo2, "vNo2 display") ;Local $hWnd = DllOpen("E:\CV-Dell-1\autoit3\myComObj1.dll") Local $hWnd = ObjCreate("myComObj1.clsMath") if (@error) Then MsgBox (0, "Error", "Error1 = " & @error) Exit EndIf ;function call method - DllCall with function name ;Local $aRes = DllCall($hWnd, "int", "addNosA", "int", $vNo1, "int", $vNo2) ;Local $aRes = DllCall($hWnd, "Ptr", "sortNos", "Array", $vNo1, "Array", $vNo2) ;function call method - $hWnd.<function name> ;Local $aRes = $hWnd.add2NosA($vNo1, $vNo2) ; this works fine with ObjCreate Local $aRes = $hWnd.sortNos($vNo1, $vNo2) if (@error) Then MsgBox (0, "Error", "Error2 = " & @error) DllClose($hWnd) Exit EndIf ;use appropriate msgbox ;MsgBox(0,"Result", "Result = " & $vNo1[0]) MsgBox(0,"Result", "Result = " & $aRes) _ArrayDisplay($vNo1, "vNo1 display") _ArrayDisplay($aRes , "aRes display") DllClose($hWnd) My VB.Net - ClassLibrary - Dll - COM obj is as follows - has 2 functions - add2NosA and sortNos:
      <ComClass(clsMath.ClassId, clsMath.InterfaceId, clsMath.EventsId)> Public Class clsMath Public Const ClassId As String = "3A42F85E-24C8-4BAA-91B5-AE56C4683C13" Public Const InterfaceId As String = "D99D7C79-2BA7-4A33-B7BC-9B7F19FDF828" Public Const EventsId As String = "CA128AC4-580C-4112-9EAD-8D1599E3F37A" Public Sub New() MyBase.New() End Sub Public Function add2NosA(ByVal no1 As Integer, ByVal no2 As Integer) As Integer Return (no1 + no2) End Function Public Sub sortNos(ByRef no1 As Array, ByRef no2 As Array) Array.Sort(no1) no2 = no1 End Sub End Class  Over all I tried various 8 options mentioned in the attached Excel file - with only 1 combination working.
      Overall could not make Array returned capture in AutoIt script. 
      Can someone help please?
      Thanks in  advance.
      Options-Tried-Matrix-Results.xlsx
    • By IndianSage
      I have create a function in FreeBasic like below:
      Extern "Windows-MS" Type tA f1 As Integer f2 As Integer End Type Public Function _switchOrder(ByVal no1 As Integer, ByVal no2 As Integer) As tA Export Dim result As Integer Dim taa As tA taa.f1 = no2 taa.f2 = no1 Return taa End Function End Extern Caller AutoIt code is:
      #include <MsgBoxConstants.au3> Global Const $sTag_ftdi_version_info="struct; int no1a; int no2a; endstruct" Local $aRet=DllCall("Math1.dll","Ptr","_switchOrder", "Int", 10, "Int", 30) ;MsgBox (0,"",@error & "-" & $aRet[0] & "-" & $aRet[1]& "-" & $aRet[2]) Local $t_ftdi_version_info=DllStructCreate($sTag_ftdi_version_info,$aRet[0]) MsgBox (0,"msg1=",@error & "---" & $aRet[0] & "-" & $aRet[1]& "-" & $aRet[2]) ;Local $retData1 = DllStructGetData($t_ftdi_version_info,"",1) Local $retData1 = DllStructGetData($t_ftdi_version_info,"no1a") MsgBox (0,"msg2=",@error & "--" & $retData1) ;Local $retData1 = DllStructGetData($t_ftdi_version_info,"",2) Local $retData1 = DllStructGetData($t_ftdi_version_info,"no2a") MsgBox (0,"msg2=",@error & "--" & $retData1) ;ConsoleWrite(DllStructGetData($t_ftdi_version_info,"",2) & "--" & @error) ;ConsoleWrite(DllStructGetData($t_ftdi_version_info,"no2a") & @CRLF) ;ConsoleWrite(DllStructGetData($tversion_str,1) & @CRLF) Getting error 2 for DllStructGetData or it give Close Application AutoIt popup message. 
      Certainly DllCall is not returning pointer to the Structure in $aRet[0] hence issue.
      Can someone help me fix this please?
      Thanks in advance.
       
       
    • By xYuri
      This simple dllcall gives me error 5, access denied,
      Func _WinAPI_VkKeyScan($__key) _WinAPI_SetLastError(0) $res = DllCall('User32.dll', 'SHORT', 'VkKeyScan', 'CHAR', $__key) _xConsole('res: '&$res) $_LastErr = _WinAPI_GetLastError() If $_LastErr <> 0 Then _xConsole('Err: {' & $_LastErr & '}> ' & _WinAPI_GetLastErrorMessage()) Return $res EndFunc Am i doing something wrong?
      Also tried VkKeyScanA and W
      Edit:
      I want to send `:` via PostMessage() WM_KEYDOWN
    • By Skysnake
      This is relevant
      From here https://stackoverflow.com/questions/3454315/is-it-possible-to-pin-a-dll-in-memory-to-prevent-unloading
      I use several UDFs on the Forum to do various things.  Those UDFs work very well.
      Effectively the UDFs are DLL wrappers, that make it possible to access DLL functions easily without the long hard slog of DLLCall() every time.
      However, I have now run into the issue that multiple UDF DLLCalls are slow. Not mind numbingly slow, but slow enough to become noticeable with a large of repeated function calls.
      So I was wondering, is it possible to "load a DLL into memory" and leave it there for the duration of my script's lifetime, avoid repeated DLL on-disk reads with a persistent in memory DLL?
      From Microsoft
      https://docs.microsoft.com/en-us/windows/desktop/dlls/about-dynamic-link-libraries
      Looks like what I want to do is: load-time dynamic linking,
      So next question, (a) how do I do this with AutoIt (b) How would this impact on standard AutoIt type DLL calls?
       
      The point is speed.  Is there a different approach?
      Or am I barking up the wrong tree?
      Skysnake
×
×
  • Create New...