Jump to content

Auto3Lib


PaulIA
 Share

Recommended Posts

Link to comment
Share on other sites

Can you be more specific about "not quite sure what to do once the event log is loaded into an array". Are you having trouble with file operations or you don't understand what is in the array returned by _EventLog_Read?

It's this bit of code from the example that I'm not quite sure what it does:

CODE
$sData = ""

$aData = $aEvent[14]

for $iJ = 1 to $aData[0]

$sData = $sData & Hex($aData[$iJ], 2) & " "

if Mod($iJ, 16) = 0 then $sData = $sData

next

if $sData <> "" then $sData = $sData

What part of the event log goes into $aEvent[14] ? Why the Hex conversion? When I run the script it gets the oldest entries from my event log, to see the newest do I add _EventLog_Count($hEventLog) + 1 to start again at the top?
Link to comment
Share on other sites

It's this bit of code from the example that I'm not quite sure what it does:

CODE
$sData = ""

$aData = $aEvent[14]

for $iJ = 1 to $aData[0]

$sData = $sData & Hex($aData[$iJ], 2) & " "

if Mod($iJ, 16) = 0 then $sData = $sData

next

if $sData <> "" then $sData = $sData

What part of the event log goes into $aEvent[14] ? Why the Hex conversion? When I run the script it gets the oldest entries from my event log, to see the newest do I add _EventLog_Count($hEventLog) + 1 to start again at the top?
If you look in the event log using the Windows Event Viewer, at the bottom of the dialog is a box that shows data in Byte or Word format. The data contained here is specific to the event and the application that created the event. This is what $aEvent[14] contains. The bit of code in the example simply splits it into nice rows of 16 bytes each so that it can be displayed.

As I mentioned before, the event log is a circular queue. If the event log is not full, the first record is the oldest record and _EventLog_Count() is the newest record. If the event log is full, the oldest record is at the position returned by _EventLog_Oldest() and the newest record is at the position returned by _EventLog_Oldest() + 1. If this value is greater than _EventLog_Count(), then you need to wrap the value back to 1. So, if the event log is full, the newest record is at _EventLog_Oldest() + 1 "mod" _EventLog_Count().

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

This release contains a module for the animation (AVI) control. Of more interest (and use) is the addtion of a module that encapsulates the Windows Networking (WNet) functions. It also includes a module for all of the Windows Time functions.

The server for the pipes demo has been rewritten so that it is a single instance server. The previous multi instance server had some bugs and it was difficult for even me to understand. The new demo is a lot simpler to follow. You'll notice that when executing remote commands that the data is now streamed back to the remote in real time. Thanks to arcker for helping to debug the pipes module and for the many helpful suggestions.

In the last release, I had whipped up a simple script that checked to see if there was a new release of Auto3Lib here on the forum. Unfortunately, I hard coded the attachment ID in the script which obviously changes every time I release a new version. :"> Thanks to Dizzy for catching this one.

There is a new function in the TreeView module that allows you to find a node in the tree by a "path". For example, if you're using the TreeView in Explorer and want to find the node for the AutoIt directory, you can do so by using:

_TreeView_FindNodeEx($hTree, "DeskTop|My Computer|Local Disk (C:)|Program Files|AutoIt3")

This is significantly faster than using FindNode when you know the path to the node that you are after. This is especially true on trees with a large number of nodes. Thanks to luckyb for contributing the code for this function. Speaking of which, luckyb also gets another nod for pointing out a potential problem in the TreeView Expand/Collapse functions. These functions have been changed so that they wait to make sure the expand/collapse operation has completed before returning.

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

If you look in the event log using the Windows Event Viewer, at the bottom of the dialog is a box that shows data in Byte or Word format. The data contained here is specific to the event and the application that created the event. This is what $aEvent[14] contains. The bit of code in the example simply splits it into nice rows of 16 bytes each so that it can be displayed.

As I mentioned before, the event log is a circular queue. If the event log is not full, the first record is the oldest record and _EventLog_Count() is the newest record. If the event log is full, the oldest record is at the position returned by _EventLog_Oldest() and the newest record is at the position returned by _EventLog_Oldest() + 1. If this value is greater than _EventLog_Count(), then you need to wrap the value back to 1. So, if the event log is full, the newest record is at _EventLog_Oldest() + 1 "mod" _EventLog_Count().

Here is a bit of the code I've modified to read the latest 20 entries of a an event log that is not full:

CODE
#include <A3LEventLog.au3>

Dim $hEventLog, $aData, $sData

Dim $iI, $iJ, $iCount, $aEvent, $logfile, $ioffset, $pad

$logfile = FileOpen("temp.txt", 2)

$hEventLog = _EventLog_Open("", "System")

$hEventLog = _EventLog_Open("", "System")

$iCount = _EventLog_Count($hEventLog)

_Lib_ConsoleWrite("Record count ......: " & $iCount )

_Lib_ConsoleWrite("Oldest record .....: " & _EventLog_Oldest($hEventLog))

_Lib_ConsoleWrite(@CR)

$ioffset = _EventLog_Oldest($hEventLog)

$pad = $iCount

$iCount = $ioffset + $pad

MsgBox(0, "$icount", $iCount)

for $iI = $iCount - 20 to $iCount

$aEvent = _EventLog_Read($hEventLog)

FileWriteLine($logfile, "Record number .....: " & $aEvent[ 1])

FileWriteLine($logfile, "Submitted .........: " & $aEvent[ 2] & " " & $aEvent[ 3])

FileWriteLine($logfile, "Generated .........: " & $aEvent[ 4] & " " & $aEvent[ 5])

FileWriteLine($logfile, "Event ID ..........: " & $aEvent[ 6])

FileWriteLine($logfile, "Type ..............: " & $aEvent[ 8])

FileWriteLine($logfile, "Category ..........: " & $aEvent[ 9])

FileWriteLine($logfile, "Source ............: " & $aEvent[10])

FileWriteLine($logfile, "Computer ..........: " & $aEvent[11])

FileWriteLine($logfile, "Username ..........: " & $aEvent[12])

FileWriteLine($logfile, "Description .......: " & $aEvent[13])

$sData = ""

$aData = $aEvent[14]

for $iJ = 1 to $aData[0]

$sData = $sData & Hex($aData[$iJ], 2) & " "

if Mod($iJ, 16) = 0 then $sData = $sData

next

if $sData <> "" then $sData = $sData

_Lib_ConsoleWrite("Data ..............: " & $sData)

_Lib_ConsoleWrite(@CR)

next

_EventLog_Close($hEventLog)

Pardon ignorance. I realize now that $icount doesn't control from where the Log reading will begin, it's all in _EventLog_Read($hEventLog), so where do I set this offset? As you can see I've tried to do so with $iCount and $ioffset, but all this does is control the number of events that will be read, not from where to start the reading. Once the offset is worked out, how do I tell _EventLog_Read($hEventLog) to sart from this offset?
Link to comment
Share on other sites

Is there a help file or something for AU3Lib because i have looked through the forums and looked at the example scripts for it and i am still confused.

I am trying to automate an installation that has a load of tick boxes in a ListBox, i want to untick one of them and then continue with the script but i cannot work this out. Any help would be appreciated, its not that i cant be bothered to look and work things out i am just really really stuck

Cheers in advance

Lee

Link to comment
Share on other sites

Pardon ignorance. I realize now that $icount doesn't control from where the Log reading will begin, it's all in _EventLog_Read($hEventLog), so where do I set this offset? As you can see I've tried to do so with $iCount and $ioffset, but all this does is control the number of events that will be read, not from where to start the reading. Once the offset is worked out, how do I tell _EventLog_Read($hEventLog) to sart from this offset?

In the next release, I will put in some more examples of how to find a specific record in the event log. Until then, if you just want to read the newest 20 entries in the event log, you can do it this way:

Func Read()
  Local $hEventLog, $iI, $aEvent

  $hEventLog = _EventLog_Open("", "Application")
  for $iI = 1 to 20
    $aEvent = _EventLog_Read($hEventLog, True, False)
    ...
    ... Print event detail
    ...
  next
  _EventLog_Close($hEventLog)
EndFunc

On a side note, Microsoft has acknowledged that there is a bug in the seek method of the ReadEventLog API when using event logs with a size greater than 2 MB. I'll have to do some thinking on how to work around this one.

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Is there a help file or something for AU3Lib because i have looked through the forums and looked at the example scripts for it and i am still confused.

There is currently no separate help file. A help file is on my "to do" list, but it is a project as big (or bigger) than Auto3Lib itself. Auto3Lib is targeted towards the advanced AutoIt programmer, so the documentation in the UDFs will have to do for now.

I am trying to automate an installation that has a load of tick boxes in a ListBox, i want to untick one of them and then continue with the script but i cannot work this out. Any help would be appreciated, its not that i cant be bothered to look and work things out i am just really really stuck

If you need some help, feel free to PM/email me a small example and I'll see if I can help you out.
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Hi I want to comment at least one more time on the beta-dependency of Auto3Lib.

I would wish Auto3Lib to go back to supporting the stable release again. Right now, for example, stable release is even newer in development than the last beta, according to this comment of a moderator.

Do you others in this forum prefer Auto3Lib to support the beta or the stable release?

thanks, autocart

Edited by autocart
Link to comment
Share on other sites

Hi I want to comment at least one more time on the beta-dependency of Auto3Lib.

I would wish Auto3Lib to go back to supporting the stable release again. Right now, for example, stable release is even newer in development than the last beta, according to this comment of a moderator.

Do you others in this forum prefer Auto3Lib to support the beta or the stable release?

thanks, autocart

Auto3Lib always supports the latest release of AutoIt, whether it be "stable" or beta. As of now, Auto3Lib supports the latest stable release of AutoIt because there is no newer beta release. As for the post, I don't think you read it correctly. Valik is stating that all of the betas have been superceded by the latest stable release of code, which is correct. I'm not sure I understand the problem you're having between the AutoIt betas and Auto3Lib. Can you elaborate a bit?

<rant>

On another note, I think people are giving the beta releases a bad rap. Jon and the other devs do an excellent good job of releasing quality code during the betas and I have little problems using them with Auto3Lib. In fact, the only real problem that I have every had was when Auto3Lib code was used in the standard UDFs and it caused naming conflicts. Since I've switched to prefixing all of the Auto3Lib functions, this isn't a issue anymore.

</rant>

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Hi I want to comment at least one more time on the beta-dependency of Auto3Lib.

I would wish Auto3Lib to go back to supporting the stable release again. Right now, for example, stable release is even newer in development than the last beta, according to this comment of a moderator.

Do you others in this forum prefer Auto3Lib to support the beta or the stable release?

thanks, autocart

I think Auto3Lib should use whatever is most recent, since that is what most everyone on the forums uses. In other words, I agree with how Paul has been operating to date.

Sometimes it is helpful to remember that the common factor in all our problems is usually ourselves. If you're having compatibility problems, you may need to upgrade - I did.

Link to comment
Share on other sites

Never mind. If that is so than I am totally satisfied.

I was confused by the statement in the readme.txt: "YOU NEED THE LATEST BETA RELEASE OF AUTOIT3 FOR AUTO3LIB TO WORK." You yourself just agreed to the statement "that all of the betas have been superceded by the latest stable release". That would mean to me that "THE LATEST BETA RELEASE OF AUTOIT3 FOR AUTO3LIB TO WORK" is also "superceded by the latest stable release", which I would have found not so good. But actually the sentence in the readme.txt is not totally correct. The truth is now:

Auto3Lib always supports the latest release of AutoIt, whether it be "stable" or beta.

That's the best solution. Thank you for the information update.

:) autocart

Link to comment
Share on other sites

Thanks PaulIA for a great library that lets me get the most from AutoIt with the least headache.

Two thumbs up! :)

I did run into an error recently with a script I use at work to reconfigure the visual settings on

Windows XP machines. The text of the error was:

_API_WriteProcessMemory: Only part of a ReadProcessMemory or WriteProcessMemory request was completed.

It appeared to be caused by the last few lines of the following code:

CODE

#region FOLDER OPTIONS ==============

; Start the "Folder Options" dialog

Run("rundll32 shell32.dll,Options_RunDLL",@WindowsDir)

WinWaitActive("Folder Options","Show common tasks")

; Click the Restore Defaults button

ControlClick("Folder Options","Show common tasks",30107)

; Tab over once to get to "View" tab

ControlCommand("Folder Options","Show common tasks",12320,"TabRight","")

WinWaitActive("Folder Options","You can apply the view")

; Click the Restore Defaults button

ControlClick("Folder Options","You can apply the view",30121)

; get a handle to the TreeView in the View tab

$hTempTreeView = ControlGetHandle("Folder Options","You can apply the view",30120)

; get a handle to "Automatically search for..."

$hNodeA = _TreeView_FindNode($hTempTreeView,"Automatically search for network folders and printers")

; UnCheck "Automatically search for..."

_TreeView_SetChecked($hTempTreeView,$hNodeA,False)

The funny thing is if I moved this code into it's own au3 file, it wouldn't generate the error. Then I noticed that I had a whole lot of other calls to _TreeView_FindNode and _TreeView_SetChecked before the problem code. I moved the problem code above the other calls, and the error went away. Strange, eh?

If it helps any, this is the "other" code/calls:

CODE

#region TASKBAR AND START MENU ================================================

; Open the Taskbar and Start Menu dialog

Run("rundll32 shell32.dll,Options_RunDLL 1",@WindowsDir)

WinWaitActive("Taskbar and Start Menu Properties","You can keep")

; UnCheck "Hide inactive icons"

ControlCommand("Taskbar and Start Menu Properties","You can keep",1000,"UnCheck","")

; move to the Start Menu tab

ControlCommand("Taskbar and Start Menu Properties","You can keep",12320,"TabRight")

WinWaitActive("Taskbar and Start Menu Properties","Select this menu style")

; Select the "Classic Start Menu" radio button (controlID 1133)

ControlCommand("Taskbar and Start Menu Properties","Select this menu style",1133,"Check","")

#region Customize Classic Start Menu Dialog

; Click on "Customize" button next to "Classic.."

ControlClick("Taskbar and Start Menu Properties","Select this menu style",1130)

WinWaitActive("Customize Classic Start Menu","To remove records of recently")

; "Advanced Start Menu Options" is a TreeView - we have to get a handle to it

$hTreeView = ControlGetHandle("Customize Classic Start Menu","To remove records of recently",1123)

; now get handles to the individual nodes in the treeview

$hNodeDisplay_Admin_Tools = _TreeView_FindNode($hTreeView, "Display Administrative Tools")

$hNodeDisplay_Favorites = _TreeView_FindNode($hTreeView, "Display Favorites")

$hNodeDisplay_Log_Off = _TreeView_FindNode($hTreeView, "Display Log Off")

$hNodeDisplay_Run = _TreeView_FindNode($hTreeView, "Display Run")

$hNodeEnable_dragging = _TreeView_FindNode($hTreeView, "Enable dragging and dropping")

$hNodeExpand_Control_Panel = _TreeView_FindNode($hTreeView, "Expand Control Panel")

$hNodeExpand_My_Docs = _TreeView_FindNode($hTreeView, "Expand My Documents")

$hNodeExpand_My_Pics = _TreeView_FindNode($hTreeView, "Expand My Pictures")

$hNodeExpand_Net_Conns = _TreeView_FindNode($hTreeView, "Expand Network Connections")

$hNodeExpand_Printers = _TreeView_FindNode($hTreeView, "Expand Printers")

$hNodeScroll_Programs = _TreeView_FindNode($hTreeView, "Scroll Programs")

$hNodeShow_Small_Icons = _TreeView_FindNode($hTreeView, "Show Small Icons in Start Menu")

$hNodeUse_Personalized_Menus = _TreeView_FindNode($hTreeView, "Use Personalized Menus")

; Now set the respective values

_TreeView_SetChecked($hTreeView,$hNodeDisplay_Admin_Tools,False)

_TreeView_SetChecked($hTreeView,$hNodeDisplay_Favorites,False)

_TreeView_SetChecked($hTreeView,$hNodeDisplay_Log_Off,True)

_TreeView_SetChecked($hTreeView,$hNodeDisplay_Run,True)

_TreeView_SetChecked($hTreeView,$hNodeEnable_dragging,True)

_TreeView_SetChecked($hTreeView,$hNodeExpand_Control_Panel,False)

_TreeView_SetChecked($hTreeView,$hNodeExpand_My_Docs,False)

_TreeView_SetChecked($hTreeView,$hNodeExpand_My_Pics,False)

_TreeView_SetChecked($hTreeView,$hNodeExpand_Net_Conns,False)

_TreeView_SetChecked($hTreeView,$hNodeExpand_Printers,False)

_TreeView_SetChecked($hTreeView,$hNodeScroll_Programs,False)

_TreeView_SetChecked($hTreeView,$hNodeShow_Small_Icons,False)

_TreeView_SetChecked($hTreeView,$hNodeUse_Personalized_Menus,False)

; Click OK to the "Customize ..." dialog (controlID 1)

ControlClick("Customize Classic Start Menu","",1)

#endregion Customize Classic Start Menu Dialog

; Click OK to the main "Taskbar..." dialog (controlID 1)

ControlClick("Taskbar and Start Menu Properties","",1)

#endregion TASKBAR AND START MENU

BTW, I am using the latest version of Scite4AutoIt, AutoIT 3.2.2.0 Prod, and the latest version of Auto3Lib (2007-01-24).

Feel free to email me if you want the whole source code/environment/etc to reproduce the problem.

Link to comment
Share on other sites

I did run into an error recently with a script I use at work to reconfigure the visual settings on

Windows XP machines. The text of the error was:

_API_WriteProcessMemory: Only part of a ReadProcessMemory or WriteProcessMemory request was completed.

This is usually the result of passing an invalid window handle to one of the functions. In AutoIt, you have to be careful to check all of your return results before using them. For example, in this piece of code:

; get a handle to the TreeView in the View tab
$hTempTreeView = ControlGetHandle("Folder Options","You can apply the view",30120)
; get a handle to "Automatically search for..."
$hNodeA = _TreeView_FindNode($hTempTreeView,"Automatically search for network folders and printers")
; UnCheck "Automatically search for..."
_TreeView_SetChecked($hTempTreeView,$hNodeA,False)
oÝ÷ Ù.j·§¢×!yÉ"h±ç¢Mú7¦¥:ÞyXÂôߨM¡×j·¯jXmçè­ë¬x-é¢Ë±ê®z{jYlN¬Æ¦ËZëajÖ¥¢Úëh"Úk¢
Úg«±º-]jwg{¥G¦jGØ­q©åy§m¡©h¶é®åzk¢ÇûaȬ¶©®åzkajܨ¹ªÞ«â¨ºh ÛkÉÈZ§*.­ÊzÚ,¢g­)à)jëh×6
; get a handle to the TreeView in the View tab
$hTempTreeView = ControlGetHandle("Folder Options","You can apply the view",30120)
if $hTempTreeView = 0 then _Lib_ShowError("Unable to obtain TreeView handle")
; get a handle to "Automatically search for..."
$hNodeA = _TreeView_FindNode($hTempTreeView,"Automatically search for network folders and printers")
if $hNodeA = 0 then _Lib_ShowError("Call to _TreeView_FindNode failed")
; UnCheck "Automatically search for..."
_TreeView_SetChecked($hTempTreeView,$hNodeA,False)

Lastly, you're searching for control handles using a control ID. While this works most of the time, there are situations where the control ID will change in an application that builds screens dynamically. This may not be a problem here, but it is something to think about when developing applications using AutoIt. I always try to obtain the control handle using the control text as that usually remains constant.

If you change your code to check the return values and are still getting this error, please PM/email an example script that reproduces the problem and I will take a look at it.

P.S. Thanks for the feedback! :)

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

If what you say (about numeric ControlIDs vs text "ClassNameNN" ControlIDs) is true, then the help for AutoIt needs to be revised!!

Don't get me wrong, I'm siding with you at this point, but the helpfile (Function Reference/Window Management/Controls page) led me in the wrong direction about this, and the helpfile page for ControlGetHandle (Function Reference/Window Management/ControlGetHandle) doesn't mention validity checking either...

Perhaps that's why so many programmers have this problem...

Who do I direct this info to, to get the helpfile fixed/update/revised?

Thanks Paul :)

Link to comment
Share on other sites

If what you say (about numeric ControlIDs vs text "ClassNameNN" ControlIDs) is true, then the help for AutoIt needs to be revised!!

Don't get me wrong, I'm siding with you at this point, but the helpfile (Function Reference/Window Management/Controls page) led me in the wrong direction about this, and the helpfile page for ControlGetHandle (Function Reference/Window Management/ControlGetHandle) doesn't mention validity checking either...

Perhaps that's why so many programmers have this problem...

Who do I direct this info to, to get the helpfile fixed/update/revised?

Thanks Paul :)

I'm not sure that the AutoIt help file is what I would call misleading. It says that using the ControlID is "generally" the best method of identifying controls. That's true in most cases. The point that I was trying to make was that you can't rely on this as an absolute fact. In my personal experience, I have been bitten once or twice by dynamic control IDs, but have not had a problem (yet) when I use the controls text. I know that some people prefer one method over the other and I think a lot of it has to do with personal choice. However, the one thing that IS an absolute is that we should all check the return values/error codes coming from a UDF before we proceed to use them in subsequent functions. I think that was the point I was trying to make. :D

After reading the help file, I doubt the devs will want to change anything as this is more of a user learning issue that we all go through sooner or later. Anyway, that's just my 2 cents worth.

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

I was trying to use the screen capture utility and I keep getting the following:

_API_GetCursorInfo: Invalid access to memory location

Any idea what is wrong?

I had one other person report this but I couldn't get them to give me enough information to solve the problem. I'd really like to nail this one down as it only seems to be happening for certain people. Here is what I need to know:

Can you give me a small snippet of code that demonstrates the problem?

Does the demo script work when you run it?

If you run a script that just calls _API_GetCursorInfo, does it fail too?

Edited by PaulIA
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

No response from spyro, so I guess I'll appeal to the masses. If anyone is having a problem with the ScreenCap module, PLEASE post enough information so that I can debug the problem. To date I have had two reports of errors in _API_GetCursorInfo that I can not replicate on any of the machines that I have. It appears that this is only happening for a few select users. Here is what I need to know:

* Does the problem appear when you run the demo script?

* If you write a script that just calls _API_GetCursorInfo, does it fail?

* What version of OS and language are you using?

Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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