binhnx

Simple and Stupid Control Hover UDF

24 posts in this topic

#1 ·  Posted (edited)

Version 3:

Ops, you may ask, where's the version 2?
The answer is, you will never see it. I skipped it to jump to version 3 directly.

Why? Actually, I didn't learn M$ about that versioning :)
The reason is, I planed to write version 2, using the new window/control handle indexing technique to eliminate all the ugly and slow loop. But when nearly finish, I feel so tired, tired of using a lots of all workaround. And finally, I decided to rewrite entire the UDF, using the direct solution, the way all other languages used, and should use.

I late some day, because of some machine code (it's actually not so necessary, but if the control is doing an expensive task, like heavy drawing then passing all the Window Message to AutoIt is not a so good idea because its slow speed may result in some annoying-small-but-easy-to-figure-out problems, (like tearing as example). So I use machine code directly to pass over it.

Now you have not a Stupid but a Smart UDF :) And it's still simple.

API change:

  • Remove a parameter from _SSCtrlHover_Register. You nolonger can attach other controls to the registered control. Use another method to do it and when you delete the control be sure to delete all the attached controls yourself. This breaks your old script.
  • Add double click event (last 2 parameters of _SSCtrlHover_Register)
  • Remove the _SSCtrlHover_Delete. You must manually delete yourself. It's easy with GUICtrlDelete and I decide not to duplicate this function to my UDF (be sure to delete your attached control too)

This version eliminate all the odd limit of old version, include:

  • No:longer use timer/adlib to test the control is on mouse event. Now it directly use native WinAPI method to provide a truly event-driven way. Every click is detected, every mouse hover/left, is handled perfectly.
  • Fast and very fast. All the loop is eliminated. Machine code. Execute speed is much much improved. (read as: nano seconds instead of milliseconds :) )
  • I documented it quite well so if you want you can easily browse it and change it the way you want.
  • Now you can use in both GUIGetMsg() loop mode or event mode. No longer setting constants like before because it works perfectly in both mode. Cheer

Remark: I don't include <WinAPI.au3> and <WinAPIShellEx.au3> in my UDF, because those UDF is very large and it will consume much more memory when you run (not matter you run the 'compiled' exe, the au3 file, or the .a3x file). In the CtrlHover UDF, i included a small subset of those UDF with the same name, so if you have already included <WinAPI.au3> or <WinAPIShell.au3>, be sure to edit the UDF and comment out the corresponding region.


Edit 2:

Reorganize script.

Fix some issues when drag too fast.
Add ability to handle "click" (work RIGHT as normal button, will not fire if you only release the mouse button upon the control as some UDF use MouseUp event)

Add a helper method to check if MouseUp event is click event or not.

Add compability function to call as normal UDF (with first letter is underscore).

Edit 1:

Add some function descriptions as JS's advice. Thank you  :rambo:

I also changed script name (shorter) and modify the register function so it may be called with less parameter.

From now on, the function name and calling syntax will be fixed.


OK, I know there is the famous "GUICtrlOnHover" UDF already in this forum, and many people have used it and enjoyed it!

But the UDF didn't work as I expected  :mad2: . So I wrote an UDF myself, as much simple as possible, and it works out of the box  :dance:

It has some advantages compare to the old GUICtrlOnHover.au3

  • It creates the normal button behavior. When you press primary mouse button in the control and begin to drag, it do not set other controls to "hover" state.
  • Faster. I try to add 2k controls. When mouse change from one control to another, it only take about 25ms to handle. In idle state (mouse cursor is not over any control), the cost is ignorable with < 0.1ms. Compare with GUICtrlOnHover UDF takes about 3ms when mouse cursor is over the control, but in idle state, it takes about 35ms. (I do not know why) (That is, because I tested script with overlapped controls. GUICtrlOnHover rely on WinAPI function WindowFromPoint(), which return the first created control (the control with is overlapped any others), but my script rely on GUIGetCursorInfo() which return the last created control - which is the most nested control in Windows). So my script need to check entire 2k control, but GUICtrlOnHover return the first element. I will wait for information about GUIGetCursorInfo() to decide that my UDF should use WinAPI function instead of the native function. In the normal usecase and controls is not overlapped, my UDF is far faster. Edit: Add a setting constant, make you ability to choose use WindowFromPoint() or GUIGetCursorInfo(). Default to the WinAPI function)
  • Faster time to create/ register control.
  • Native AutoIt. No Callback. The only DllCall I use is to get parent window of a control. Wonder why AutoIt do not have a similar function. Found a new bug #2899. If someone can ad more functinal to WinGetHandle("[LAST]"), it should be great  :guitar: Edit: Use some other WinAPI call to provide workaround for issue with GUIGetCursorInfo.
  • Smaller size, about 280 lines compare with about 400 lines of GUICtrlOnHover. More simple, more easy to use.
  • No more than 120 characters in one line. No annoying jumping when scroll the UDF
  • Support event mode to detect mouse down event. But it doesn't work with overlay control. So you cannot have a control (with event) over another control. (use $_BGUIGETCURSORINFOFIX const setting to get rid of this). It seems that it's a AutoIt bug, the GUIGetCursorInfo return a useless control id when controls overlapped. Its not the same with the control received with WindowFromPoint(), or the control which fire event (anyone can confirm it's a bug? Or it's a special feature?   :ranting: ) ( I open a new Trac Ticket here: #2900)

Current limit:

  • Mouse down Almost all mouse event is currently detected by timeout (this is why the script called Simple and Stupid, but every UDF I found in this forum also use this method). You can set a smaller timeout to catch the mouse, but sometimes its annoying. Edit: Default changed to 30ms timeout, it should be fast enough to detect any click! You can also change to use event mode to detect click better!

Otherwise, it works like a charm. Try it and happy with it  :muttley:


Example: Callback function

#include "SSCtrlHover.au3"

GUICreate(@AutoItVersion)
$idLbl1 = GUICtrlCreateLabel("Label 1", 5, 5)
SSCtrlHover_Register($idLbl1, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 0)
$idLbl2 =GUICtrlCreateLabel("Label 2", 5, 35)
SSCtrlHover_Register($idLbl2, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 5)
GUISetState()

While GUIGetMsg() <> -3
   Sleep(10)
WEnd

Func FnNormal($idCtrl, $hWnd, $vData)
   ConsoleWrite(@CRLF & "Normal/Leave " & $idCtrl)
EndFunc

Func FnHover($idCtrl, $hWnd, $vData)
   ConsoleWrite(@CRLF & "Hover " & $idCtrl)
EndFunc

Func FnActive($idCtrl, $hWnd, $vData)
   ConsoleWrite(@CRLF & "Active " & $idCtrl)
EndFunc

Func FnClick($idCtrl, $hWnd, $vData)
   ConsoleWrite(@CRLF & "CLICK! " & $idCtrl & " - " & $hWnd & " - " & $vData)
EndFunc

You can use it with GUICtrlSetImage to provide a "hover button" effect :)

Version 1: SSCtrlHover.au3

Version 3: SSCtrlHover.zip

Edited by binhnx
4 people like this

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Nice! You have some examples to provide us?

SSControlHover_Register($idCtrl, $aIdAttachedCtrl, _
                $fnNormalCb, $vNormalData, $fnHoverCb, $vHoverData, $fnActiveCb, $vActiveData)

Something like popular the sentences below

; #FUNCTION# ====================================================================================================================
; Name ..........: SSControlHover_Register
; Description ...:
; Syntax ........: SSControlHover_Register($idCtrl, $aIdAttachedCtrl, $fnNormalCb, $vNormalData, $fnHoverCb, $vHoverData,
;                  $fnActiveCb, $vActiveData)
; Parameters ....: $idCtrl              - An integer value.
;                  $aIdAttachedCtrl     - An array of unknowns.
;                  $fnNormalCb          - A boolean value.
;                  $vNormalData         - A variant value.
;                  $fnHoverCb           - A boolean value.
;                  $vHoverData          - A variant value.
;                  $fnActiveCb          - A boolean value.
;                  $vActiveData         - A variant value.
; Return values .: None
; Author ........: Your Name
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================

JS

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

Where's the code?

In the attached file :)


99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thank you very much! I used old UDF by Creator for making GUI "buttons" with Pic controls instead and I've noticed that the state fuctions returns too many results at a time. 'Cause of this I had not critical, but unpleasant blinks on my buttons when push and hold mouse button. Your UDF has solved all the problems. Can you clarify for me more detailed, what Data parameters (like $vClickData) do in your UDF?

P. S. There is a mistake in the _SSCtrlHover_Register function parameters' description. Last two names of parameters duplicating two others above.

Edited by pat4005

Share this post


Link to post
Share on other sites

@pat4005: I'm glad you are happy with my UDF :)

Sorry about the description, I wrote it at very late so I almost copy & paste & forget every thing :)

The $vClickData is a variable which then be pass to your $fnClickCb function callback, as like every other $v...Data in my UDF.

I planed to change the UDF a little more (using a fantastic method to store window and control infos so we don't need to loop to find the hover/active... control anymore, and a addtional UDF using the new handy Map feature in new AutoIt version). So I delay changing the description until I finish all the works (I'm too lazy  :sweating: ) (Currently I have no time for it :sweating: , but I will begin as soon as possible, so just wait  :thumbsup: )


99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

binhnx, hi. Not so long ago I've had a problem with your UDF. When I point "-1" value as a first parameter in _SSCtrlHover_Register function then nothing works. I need to use a variable with control id instead. Also when I use _SSCtrlHover_Register function in multiple places in my program (in multiple windows) some of buttons work and some don't. Can you explain such behavior? Unpatiently wait for a new version of your UDF anyway!

Edited by pat4005

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

At line 67:

$_aControlHoverData[$iIndex][0] = $idCtrl

I forgot to check $idCtrl = -1 at that point. You can modify it by adding this line after line 57 (before WinAPI GetAncestor() call)

If ($idCtrl=-1) Then $idCtrl = DllCall("user32.dll", "INT", "GetDlgCtrlID", "HWND", $hWnd)[0]

Sorry about that odd bug. I'll fix it in new version.

About the second bug, I haven't pointed out what wrong yet. Currently, my script only working with controls inside top-level GUI. If you use with nested GUI (child GUI(s) created by specified $WS_CHILD in GUICreate), you may get unexpected behavior. I'm not sure if that is your problem or not.

When I wrote the first line of the UDF, I decided that it should be much AutoIt as possible. So I try to reduce any WinAPI call (by DllCall), callback or timer function. But as time go by, I realize that it's impossible to write a good UDF without using many WinAPI functions :) This will solve a lot of problems with current version.

Good news: Will start writing today. You may have the new version tomorrow :D

Edited by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

binhnx, your work is impressively REMARKABLE! Of course, I've already downloaded and tested new v3 UDF and it works perfectly great. To be more specific I've noticed speed improvement even by eye, my former problem was just miraculously solved and however blinking defect is still absent. Thank you very much!:thumbsup: But here is some "but". I found a little problem and I want to ask you some other questions:

1) Problem is that when I try to exit script containing your UDF functions using HotKeySet function for that, it crushes with an AutoIt big-don't-know-how-to-call-it error twice. Other times all works well.

 

2) Why don't you put your Assert function inside UDF?
3) Whether еру hover button effect must work when GUI is not active (just curious)?
4) Can you please post an example which will contain ready to use and clickable "button on hover" working scheme with images on controls (if I expressed my thoughts correctly)?
 
UPD: When compiled script crushes after any way to exit it  :ermm:.
Edited by pat4005

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

@pat4005:

1. About the crash problem: I'll fix it later. But it's a good practice to manually delete all the GUI  (using GUIDelete) before using the Exit function.

2. Assert function is used for all my UDF so I think it's better to separate it to a different file. If you find it annoying and you only use this UDF, copy that function to main UDF file.

3. The event is delivered by Windows directly, so the hover function is called exactly when a control is on hover, and the normal function is called exactly when the mouse leave the control. Don't worry, it works no matter your GUI is activated or not. It only not work when your GUI is minimized or hidden (why do you need it to work when you can not put your mouse over the control :) ) It works when you need it and doesn't work when you don't need to save your CPU :) )

4. Later, later, later. I'll add a addition SSButtonHover UDF. Now I'm messing with another project :D

Edit: Assert is intended to use in dev. It's only mission is check for something that may cause if you write something careless. So, if you're sure all things you wrote a right: check error, ensure the variable type you specified is match with the expected type... so you definitely safe to remove all the assert statement from my UDF.

PS: Thank you for your feedback, it helps me a lot to improve my UDF quality.

Edited by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Share this post


Link to post
Share on other sites
binhnx, I got it. There is more about your UDF. After using hovering image onto pic control I've saw image lags similar to those that was with using Creator's UDF. Is it a known bag?

Share this post


Link to post
Share on other sites

#14 ·  Posted

Great job :D

Share this post


Link to post
Share on other sites

#15 ·  Posted

How to make click and double click trigger different mouse event ?

Share this post


Link to post
Share on other sites

#16 ·  Posted

Hi

About the crash problem Is there a better way?-_-

Share this post


Link to post
Share on other sites

#17 ·  Posted

2 hours ago, ura said:

About the crash problem

Which crash problem?  You do realize you're posting in a 3 years old thread?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#18 ·  Posted

8 hours ago, Jos said:

哪个崩溃的问题?你确实意识到你在一个3年的线程发布?

乔斯

Hi, Jos.

1) Compile and run in the exit when there will be two prompt error (The reason seems to be that the registered subclasses have not been removed)

2) I need this udf, and in improving this UDF, help me:unsure:

 

Share this post


Link to post
Share on other sites

#19 ·  Posted

It's true that the crash during script end when the script is run as 64-bit code is caused by the subclasses have not been removed.

You can remove the subclasses in the example in the first post in this way:

#AutoIt3Wrapper_UseX64=y

#include "SSCtrlHover_v3.au3"

GUICreate(@AutoItVersion)
$idLbl1 = GUICtrlCreateLabel("Label 1", 5, 5)
SSCtrlHover_Register($idLbl1, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 0)
$idLbl2 =GUICtrlCreateLabel("Label 2", 5, 35)
SSCtrlHover_Register($idLbl2, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 5)
GUISetState()

While GUIGetMsg() <> -3
  Sleep(10)
WEnd

_WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($idLbl1), $__SSCTRLHOVER_PSUBCLASSEXE, GUICtrlGetHandle($idLbl1))
_WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($idLbl2), $__SSCTRLHOVER_PSUBCLASSEXE, GUICtrlGetHandle($idLbl2))

Func FnNormal($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "Normal/Leave " & $idCtrl)
EndFunc

Func FnHover($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "Hover " & $idCtrl)
EndFunc

Func FnActive($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "Active " & $idCtrl)
EndFunc

Func FnClick($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "CLICK! " & $idCtrl & " - " & $hWnd & " - " & $vData)
EndFunc

 

1 person likes this

Share this post


Link to post
Share on other sites

#20 ·  Posted

On 2017-4-19 at 0:03 AM, LarsJ said:

确实,当脚本运行时,脚本中的崩溃是64位代码由子类引起的还没有被删除。

您可以通过以下方式删除第一篇文章中示例中的子类:

#AutoIt3Wrapper_UseX64 = Y

#include “SSCtrlHover_v3.au3

GUICreate@AutoItVersion$ idLbl1  =  GUICtrlCreateLabel(“标记1” , 55 ) 
SSCtrlHover _寄存器($ idLbl1 , “FnNormal” , 0 , “FnHover” , 0 , “FnActive” , 0 , “FnClick” , 0$ idLbl2  = GUICtrlCreateLabel(“Label 2” , 535 ) 
SSCtrlHover _ Register($ idLbl2 , “FnNormal” , 0 , “FnHover” , 0 , “FnActive” , 0 , “FnClick” , 5GUISetState()

而 GUIGetMsg() <>  - 3 
  睡眠(10WEnd

_WinAPI_RemoveWindowSubclassGUICtrlGetHandle$ idLbl1 ), $ __ SSCTRLHOVER_PSUBCLASSEXE , GUICtrlGetHandle$ idLbl1 ))
_WinAPI_RemoveWindowSubclassGUICtrlGetHandle$ idLbl2 ), $ __ SSCTRLHOVER_PSUBCLASSEXE , GUICtrlGetHandle$ idLbl2 ))

Func FnNormal($ idCtrl , $ hWnd$ vData )
  ConsoleWrite@CRLF & “Normal / Leave”  & $ idCtrl )
EndFunc

Func FnHover($ idCtrl , $ hWnd$ vData )
  ConsoleWrite@CRLF & “Hover”  & $ idCtrl )
EndFunc

Func FnActive($ idCtrl , $ hWnd$ vData )
  ConsoleWrite@CRLF & “Active”  & $ idCtrl )
EndFunc

Func FnClick($ idCtrl , $ hWnd$ vData )
  ConsoleWrite@CRLF & “CLICK!”  & $ idCtrl  & “ - ”  & $ hWnd  & “ - ”  & $ vData )
EndFunc

 

How to integrate into the UDF?

Share this post


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

  • Similar Content

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I'm working on a little project, and, I encountered a little strange error when I try to add some data to an array...
      The code I wrote is this:
      Func _WMI_Get_Win32_TemperatureProbe($blnCanUseWMI, $blnCustomArrayDisplay = False, $blnReturnEU = False) If $blnCanUseWMI Then Local $objWMI_QueryResult = $objWMI.ExecQuery("SELECT * FROM Win32_TemperatureProbe", "WQL", 32) If @error Then __ConsoleWrite("Error executing the query on Win32_TemperatureProbe class.", @error, 9999) Else Local $arrWin32_TemperatureProbe[1][3] _ArrayDelete($arrWin32_TemperatureProbe, 0) If @error Then __ConsoleWrite("Error deleting the 0st element $arrWin32_TemperatureProbe array.", @error, 9999) Else Local $objWMI_Variable = Null, $strWMI_QueryResult = "", $i = 0 For $objWMI_Variable In $objWMI_QueryResult $strWMI_QueryResult &= "QUERY RESULT" & "|# " & $i & "|/" & @CRLF & _ "Accuracy" & "|" & $objWMI_Variable.Accuracy & "|" & "[sint32]" & @CRLF & _ "Availability" & "|" & $objWMI_Variable.Availability & "|" & "[uint16]" & @CRLF & _ "Caption" & "|" & $objWMI_Variable.Caption & "|" & "[string]" & @CRLF & _ "ConfigManagerErrorCode" & "|" & $objWMI_Variable.ConfigManagerErrorCode & "|" & "[uint32]" & @CRLF & _ "ConfigManagerUserConfig" & "|" & $objWMI_Variable.ConfigManagerUserConfig & "|" & "[boolean]" & @CRLF & _ "CreationClassName" & "|" & $objWMI_Variable.CreationClassName & "|" & "[string]" & @CRLF & _ "CurrentReading" & "|" & $objWMI_Variable.CurrentReading & "|" & "[sint32]" & @CRLF & _ "Description" & "|" & $objWMI_Variable.Description & "|" & "[string]" & @CRLF & _ "DeviceID" & "|" & $objWMI_Variable.DeviceID & "|" & "[string]" & @CRLF & _ "ErrorCleared" & "|" & $objWMI_Variable.ErrorCleared & "|" & "[boolean]" & @CRLF & _ "ErrorDescription" & "|" & $objWMI_Variable.ErrorDescription & "|" & "[string]" & @CRLF & _ "InstallDate" & "|" & $objWMI_Variable.InstallDate & "|" & "[datetime]" & @CRLF & _ "IsLinear" & "|" & $objWMI_Variable.IsLinear & "|" & "[boolean]" & @CRLF & _ "LastErrorCode" & "|" & $objWMI_Variable.LastErrorCode & "|" & "[uint32]" & @CRLF & _ "LowerThresholdCritical" & "|" & $objWMI_Variable.LowerThresholdCritical & "|" & "[sint32]" & @CRLF & _ "LowerThresholdFatal" & "|" & $objWMI_Variable.LowerThresholdFatal & "|" & "[sint32]" & @CRLF & _ "LowerThresholdNonCritical" & "|" & $objWMI_Variable.LowerThresholdNonCritical & "|" & "[sint32]" & @CRLF & _ "MaxReadable" & "|" & $objWMI_Variable.MaxReadable & "|" & "[sint32]" & @CRLF & _ "MinReadable" & "|" & $objWMI_Variable.MinReadable & "|" & "[sint32]" & @CRLF & _ "Name" & "|" & $objWMI_Variable.Name & "|" & "[string]" & @CRLF & _ "NominalReading" & "|" & $objWMI_Variable.NominalReading & "|" & "[sint32]" & @CRLF & _ "NormalMax" & "|" & $objWMI_Variable.NormalMax & "|" & "[sint32]" & @CRLF & _ "NormalMin" & "|" & $objWMI_Variable.NormalMin & "|" & "[sint32]" & @CRLF & _ "PNPDeviceID" & "|" & $objWMI_Variable.PNPDeviceID & "|" & "[string]" & @CRLF & _ "PowerManagementCapabilities" & "|" & $objWMI_Variable.PowerManagementCapabilities & "|" & "[uint16]" & @CRLF & _ "PowerManagementSupported" & "|" & $objWMI_Variable.PowerManagementSupported & "|" & "[boolean]" & @CRLF & _ "Resolution" & "|" & $objWMI_Variable.Resolution & "|" & "[uint32]" & @CRLF & _ "Status" & "|" & $objWMI_Variable.Status & "|" & "[string]" & @CRLF & _ "StatusInfo" & "|" & $objWMI_Variable.StatusInfo & "|" & "[uint16]" & @CRLF & _ "SystemCreationClassName" & "|" & $objWMI_Variable.SystemCreationClassName & "|" & "[string]" & @CRLF & _ "SystemName" & "|" & $objWMI_Variable.SystemName & "|" & "[string]" & @CRLF & _ "Tolerance" & "|" & $objWMI_Variable.Tolerance & "|" & "[sint32]" & @CRLF & _ "UpperThresholdCritical" & "|" & $objWMI_Variable.UpperThresholdCritical & "|" & "[sint32]" & @CRLF & _ "UpperThresholdFatal" & "|" & $objWMI_Variable.UpperThresholdFatal & "|" & "[sint32]" & @CRLF & _ "UpperThresholdNonCritical" & "|" & $objWMI_Variable.UpperThresholdNonCritical & "|" & "[sint32]" $i+=1 Next ConsoleWrite($strWMI_QueryResult & @CRLF) _ArrayAdd($arrWin32_TemperatureProbe, $strWMI_QueryResult) ; I'll wait for an answer... See you later :) If @error Then __ConsoleWrite("Error inserting item #" & $i & " in the $arrWin32_TemperatureProbe array.", @error, 9999) Else If $blnCustomArrayDisplay Then _ArrayDisplay($arrWin32_TemperatureProbe, "Win32_TemperatureProbe:", "", 64 + 32 + 4, "|", "VARIABLE NAME|ACTUAL VALUE|ENGINEERING UNIT", 350, 0xD3D3D3) If @error Then __ConsoleWrite("Error displaying the $arrWin32_TemperatureProbe array.", @error, 9999) EndIf EndIf If $blnReturnEU = False Then _ArrayColDelete($arrWin32_TemperatureProbe, 2) If @error Then __ConsoleWrite("Error deleting the column #2 of $arrWin32_TemperatureProbe array.") EndIf EndIf If IsArray($arrWin32_TemperatureProbe) Then Return $arrWin32_TemperatureProbe Else Return False EndIf EndIf EndIf EndIf EndIf EndFunc And I get this error ( undocumented in the Help File on _ArrayAdd() function ):
      [15/09/2017 10:24:46] : Error inserting item #4 in the $arrWin32_TemperatureProbe array. > Error: 0 Adding a ConsoleWrite() before the _ArrayAdd() function, I can see the content of $strWMI_QueryResult, and, here it is:
      QUERY RESULT|# 0|/
      Accuracy|32768|[sint32]
      Availability||[uint16]
      Caption|Sensore numerico|[string]
      ConfigManagerErrorCode||[uint32]
      ConfigManagerUserConfig||[boolean]
      CreationClassName|Win32_TemperatureProbe|[string]
      CurrentReading||[sint32]
      Description|CPU Thermal Probe|[string]
      DeviceID|root\cimv2 0|[string]
      ErrorCleared||[boolean]
      ErrorDescription||[string]
      InstallDate||[datetime]
      IsLinear||[boolean]
      LastErrorCode||[uint32]
      LowerThresholdCritical||[sint32]
      LowerThresholdFatal||[sint32]
      LowerThresholdNonCritical||[sint32]
      MaxReadable|1270|[sint32]
      MinReadable|64266|[sint32]
      Name|Sensore numerico|[string]
      NominalReading||[sint32]
      NormalMax||[sint32]
      NormalMin||[sint32]
      PNPDeviceID||[string]
      PowerManagementCapabilities||[uint16]
      PowerManagementSupported||[boolean]
      Resolution|1000|[uint32]
      Status|Unknown|[string]
      StatusInfo||[uint16]
      SystemCreationClassName|Win32_ComputerSystem|[string]
      SystemName|DESKTOP-25LFPVU|[string]
      Tolerance|32768|[sint32]
      UpperThresholdCritical||[sint32]
      UpperThresholdFatal||[sint32]
      UpperThresholdNonCritical||[sint32]QUERY RESULT|# 1|/
      Accuracy|32768|[sint32]
      Availability||[uint16]
      Caption|Sensore numerico|[string]
      ConfigManagerErrorCode||[uint32]
      ConfigManagerUserConfig||[boolean]
      CreationClassName|Win32_TemperatureProbe|[string]
      CurrentReading||[sint32]
      Description|True Ambient Thermal Probe|[string]
      DeviceID|root\cimv2 1|[string]
      ErrorCleared||[boolean]
      ErrorDescription||[string]
      InstallDate||[datetime]
      IsLinear||[boolean]
      LastErrorCode||[uint32]
      LowerThresholdCritical||[sint32]
      LowerThresholdFatal||[sint32]
      LowerThresholdNonCritical||[sint32]
      MaxReadable|1270|[sint32]
      MinReadable|64266|[sint32]
      Name|Sensore numerico|[string]
      NominalReading||[sint32]
      NormalMax||[sint32]
      NormalMin||[sint32]
      PNPDeviceID||[string]
      PowerManagementCapabilities||[uint16]
      PowerManagementSupported||[boolean]
      Resolution|1000|[uint32]
      Status|Unknown|[string]
      StatusInfo||[uint16]
      SystemCreationClassName|Win32_ComputerSystem|[string]
      SystemName|DESKTOP-25LFPVU|[string]
      Tolerance|32768|[sint32]
      UpperThresholdCritical||[sint32]
      UpperThresholdFatal||[sint32]
      UpperThresholdNonCritical||[sint32]QUERY RESULT|# 2|/
      Accuracy|32768|[sint32]
      Availability||[uint16]
      Caption|Sensore numerico|[string]
      ConfigManagerErrorCode||[uint32]
      ConfigManagerUserConfig||[boolean]
      CreationClassName|Win32_TemperatureProbe|[string]
      CurrentReading||[sint32]
      Description|Memory Module Thermal Probe|[string]
      DeviceID|root\cimv2 2|[string]
      ErrorCleared||[boolean]
      ErrorDescription||[string]
      InstallDate||[datetime]
      IsLinear||[boolean]
      LastErrorCode||[uint32]
      LowerThresholdCritical||[sint32]
      LowerThresholdFatal||[sint32]
      LowerThresholdNonCritical||[sint32]
      MaxReadable|1270|[sint32]
      MinReadable|64266|[sint32]
      Name|Sensore numerico|[string]
      NominalReading||[sint32]
      NormalMax||[sint32]
      NormalMin||[sint32]
      PNPDeviceID||[string]
      PowerManagementCapabilities||[uint16]
      PowerManagementSupported||[boolean]
      Resolution|1000|[uint32]
      Status|Unknown|[string]
      StatusInfo||[uint16]
      SystemCreationClassName|Win32_ComputerSystem|[string]
      SystemName|DESKTOP-25LFPVU|[string]
      Tolerance|32768|[sint32]
      UpperThresholdCritical||[sint32]
      UpperThresholdFatal||[sint32]
      UpperThresholdNonCritical||[sint32]QUERY RESULT|# 3|/
      Accuracy|32768|[sint32]
      Availability||[uint16]
      Caption|Sensore numerico|[string]
      ConfigManagerErrorCode||[uint32]
      ConfigManagerUserConfig||[boolean]
      CreationClassName|Win32_TemperatureProbe|[string]
      CurrentReading||[sint32]
      Description|Video Card Thermal Probe|[string]
      DeviceID|root\cimv2 3|[string]
      ErrorCleared||[boolean]
      ErrorDescription||[string]
      InstallDate||[datetime]
      IsLinear||[boolean]
      LastErrorCode||[uint32]
      LowerThresholdCritical||[sint32]
      LowerThresholdFatal||[sint32]
      LowerThresholdNonCritical||[sint32]
      MaxReadable|1270|[sint32]
      MinReadable|64266|[sint32]
      Name|Sensore numerico|[string]
      NominalReading||[sint32]
      NormalMax||[sint32]
      NormalMin||[sint32]
      PNPDeviceID||[string]
      PowerManagementCapabilities||[uint16]
      PowerManagementSupported||[boolean]
      Resolution|1000|[uint32]
      Status|Unknown|[string]
      StatusInfo||[uint16]
      SystemCreationClassName|Win32_ComputerSystem|[string]
      SystemName|DESKTOP-25LFPVU|[string]
      Tolerance|32768|[sint32]
      UpperThresholdCritical||[sint32]
      UpperThresholdFatal||[sint32]
      UpperThresholdNonCritical||[sint32]
       
      Could please anyone help me out? 
      Thanks in advance
      Francesco
    • TheDcoder
      By TheDcoder
      Hello, I recently opened a bug report without reading the Helpfile... My bad . After @Melba23's gentle reminder, I was curious about why it was like that.
      It is about SetError's behaviour. This is the example from the bug report:
      Example() If @error Then ConsoleWrite("Error" & @CRLF) Else ConsoleWrite("No Error" & @CRLF) EndIf Func Example() SetError(1) Sleep(1000) EndFunc What I tried to do is set Example's (my user defined function's) @error value to 1... but the value set by SetError is cleared after calling a function, I wonder why? Why should calling to an external function effect my function's @error which is set when my function returns.
      Setting the error of a UDF in advance by using SetError makes sense... but I cannot find a reason why calling a function should clear it? Please note that I am not talking about @error, I am talking about the @error set by my function when it ends/returns!
      I hope someone can enlighten me, thanks for the answers in advance!
      P.S I tried to explain my best but my English is not very good and I didn't feel like I did a good job explaining today, so please pardon any mistakes that I have made
    • pboom
      By pboom
      I am looking for a way to retrieve filtered messages from the ‘system debug channel.' also known as  ‘kernel-mode debug output.'

      AutoIt must do the capture in real time. The following AutoIt UDF almost does what is required but it only captures application level, or Win32 debug output.

      https://www.autoitscript.com/forum/topic/82889-capture-debug-information-udf/#comment-593268

      The utility DebugView by Sysinternals captures the information as required by turning on Capture Kernal and in my case using the Filter include:

      *Incoming connection*

      The use of DebugView to do this is covered in the following tech note;

      https://www.tacticalsoftware.com/support/tech-notes/logging-com-port-activity.htm

      https://technet.microsoft.com/en-us/sysinternals/debugview.aspx

      However to make to make the information from DebugView available to my AutoIt script required DebugView capture to a text file and then my AutoIt script monitor that file for changes. The use of DebugView to capture the system debug channel could be made to work, but it was less than reliable and difficult to get started. The startup wasn’t something that could be easily automated not even with AutoIt.

      If you understood what I am talking about and made it this far, I think an explanation of the application is in order. Lots of details here sorry trying to answer questions in advance.

      I support a large installation of General Electric MUSE application. MUSE is a Windows-based medical application that processes and archives ECGs (electrocardiograms) taken on dedicated hardware (ECG Carts). Several methods exist on the cart to get the ECG from the Carts to the MUSE system; they range from floppies (on old obsolete hardware), memory cards, RS232 serial ports, and hardwired network connections.

      In our installation, we choose not to use the vendor-supplied network solution due to a variety of reasons I won’t get into here.  Instead, we have designed our own connection solution.

      We use a wireless serial server mounted on the ECG carts connecting to a server running a Serial/IP COM Port Redirector. The ECG cart and MUSE application think they are talking to each other via an RS232 port and as far as they are concerned, they are. However, this RS232 cable happens to run through our province (think State) wide Health Care WAN.  The hardware and software used can be seen on these two sites;

      http://www.bb-elec.com/Products/Wireless-Cellular/AirborneM2M-802-11-a-b-g-n-Dual-Band-Wireless/AirborneM2M-Industrial-Dual-Band-Wi-Fi-Router-Brid.aspx

      https://www.tacticalsoftware.com/virtual-serial-port-redirector/serial-ip.htm

      This setup works well we have over 130 ECG carts connecting using this setup. However, the end users are not technical, and there is a lot that can go wrong with wireless connections. So we do get complaints, often after the fact, that the ECG cart would not connect. A log of what ECG carts connected and when would be very helpful.

      The Serial redirector software can be configured to log all activity to the Kernal-mode Debug output. The serial redirector software itself being kernel level software. For configuration of the Wireless modules, we have custom written software (written in AutoIt) that amongst other things can display relevant configuration information for a Wireless module given it’s IP address.

      By extracting messages like the ones below from the Kernal-Mode Debug channel;

      COM56 : ½ Incoming connection from 10.158.188.172:51562

      COM18 : ½ Incoming connection from 10.158.188.200:50896

      COM19 : ½ Incoming connection from 10.158.188.180:59074

      COM68 : ½ Incoming connection from 142.239.15.82:34322

      We can have the module configuration program retrieve the configuration. The retrieved configuration contains more information such as the module ID number and wireless signal strength. This information is then logged to a file which is later loaded into a database. We can then query the database for connections made by a particular module within a specified time frame. The results of these Queries help us determine if the module was connected or is having problems connecting. Problems are usually indicated by poor signal strength and frequent re-connecting.

      So what I am looking for is a way for our module configuration program (written in AutoIt) to retrieve filtered Kernal-Level debug messages directly without using the DebugView application.

      The Forum post listed at the first of this message includes the source code for the DLL. So if you are versed in these matters and Visual Studio this may be an easy task. I looked at what needed to be done but, I was way over my head. If you look up the price of the serial IP redirector software, you can see that there is some money in our project for such things however, I do have a spending limit for purchases such as this.

       
    • jollypk
      By jollypk
      hI,
      Is there any UDF for Zeromq ?
      I need to communicate with a remote and local socket. Any suggestion or guidance will be very appreciated.
       
      Thanks
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I am working on a little script, which takes some data from a SQLite DB and should create a sort of report, inserting rows in a Word Document... I arrived at the point of:
      _Word_DocTableWrite() and, I don't know how to set the range parameter? What does that specify? 
      Thanks a lot for the help
      EDIT:
      Managed to write a table in the Word document, but now I get an error when I save the document with _Word_DocSaveAs(), with error 2.
      Which are possible causes? Thanks a lot, again
      EDIT 2:
      ... And, how can I set a border to the table? Maybe, with a sort of auto-formatting for text ( larger is the text, larger is the height/width of the table's cell ).
      Thanks  
      EDIT 3 ( bug ):
      Including the parameter $WdSaveChanges in the function _Word_DocSaveAs(), a save dialog box appears, and it should not do it, as it's written in the MSDN documentation:
      wdSaveChanges -1 Save pending changes automatically without prompting the user. Thanks again for everyone will answer to me