Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/31/2021 in all areas

  1. Yeah yeah, believe what you want nerdy.
    2 points
  2. I have this file but doesn't think i can upload without permission from the author
    1 point
  3. an example of editable, single selection by LarsJ: VirtualKeyboard.au3 Around Dec. 2016 this file was include in the zip (i think): https://www.autoitscript.com/forum/topic/182469-using-controls-to-edit-cells-in-a-listview/
    1 point
  4. Excellent! Thanks @TheXman for the great suggestion. I will take some time out now to study your CyrptoNG UDF code to learn about how to work with the structs and DllCall. Seeing examples like this does help a lot. This is just what I needed.
    1 point
  5. I can see that you've been doing a lot of searching for and reading topics on how to do API calls and define structures in AutoIt. I'm sure that you've come across several good ones. In addition to those topics, there's a wealth of examples in the WinApi* UDF libs that come with AutoIt as well as many UDF libs submitted by users. If you would like a suggestion for a relatively well-formatted, well-written, and well-documented UDF lib with numerous DllCalls/Structs/Constants/Enums, may I suggest my CryptoNG UDF lib (CryptoNG.au3)? Of course I'm biased as to its quality but I also suggest it because I wrote it. So I know how it works and why any particular piece of code was written the way it was. Therefore, I can easily answer any questions that you may have about it. Not only will it give you many DllCall and DllStruct* examples, but it also has examples of how error checking can be done as well as other general formatting and coding techniques. Hopefully, it can help you quickly flatten your overall AutoIt leaning curve. If after looking through the UDF you have general AutoIt-related questions, then I would suggest you create a new topic for those questions. If you have CryptoNG-specific questions in which you think the answers may benefit other users of CryptoNG, then I suggest you post them in the CryptoNG topic. Of course if you have ZeroMQ-related questions, then continue posting them here. That way, you keep this or other topics on-point and uncluttered.
    1 point
  6. Yes, I used the definition in the zmq.h header file, from the latest version of the ZeroMQ DLL for Windows (libzmq-v142-x64-4_3_4.zip), on the page that you referred to in the 3rd post. That's probably the one that you should rely on since you are using the DLL built from that source -- at least I hope that's what you are using.
    1 point
  7. It is because you are zeroing the pointer not the struct. Exactly
    1 point
  8. Another issue from your last post: You define the following 2 constants. Where did you get the understanding that a zmq msg type could be 32 bytes? Your definitions: Const $tag_zmq_msg_t = "BYTE var1[32];" Const $tag_zmq_msg_t64 = "BYTE var1[64];" The header file defines zmq_msg_t as: /* Some architectures, like sparc64 and some variants of aarch64, enforce pointer * alignment and raise sigbus on violations. Make sure applications allocate * zmq_msg_t on addresses aligned on a pointer-size boundary to avoid this issue. */ typedef struct zmq_msg_t { #if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) __declspec(align (8)) unsigned char _[64]; #elif defined(_MSC_VER) \ && (defined(_M_IX86) || defined(_M_ARM_ARMV7VE) || defined(_M_ARM)) __declspec(align (4)) unsigned char _[64]; #elif defined(__GNUC__) || defined(__INTEL_COMPILER) \ || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590) \ || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590) unsigned char _[64] __attribute__ ((aligned (sizeof (void *)))); #else unsigned char _[64]; #endif } zmq_msg_t; That says that a zmq_msg_t is 64 bytes. Since the default byte boundary for a struct created with DllStructCreate is 8, you don't need to explicitly set the alignment but it wouldn't hurt for the sake of readability and explicit translation. You don't have to because anything on an 8 byte boundary is also on a 4 byte boundary. You could do something like: Global $tag_zmq_msg_t = (@AutoItX64 ? "align 8;" : "align 4;") & "byte var[64];" ;Explicit boundaries or Global $tag_zmq_msg_t = "byte var[64];" ; Implicit 8 byte boundary In your script, you used the 32 byte definition. If an API function is expecting 64 bytes, and it only is given 32 bytes, bad things can happen. At the least, you can have unexpected results. You used: Global $msg = DllStructCreate($tag_zmq_msg_t) One more word of advice, in the functions that call the API's, after each DllCall, you should check both the @error and the API's return code (if one exists) to make sure that the API call was successful. If the API call is not successful, you should signal to the caller that the function failed. Many scripts use SetError() for this purpose. That also means that it might be better not to call those functions within other functions, like you are currently doing. By calling the functions within other functions, you don't have the ability to make sure that the function was successful. For example you do this: ConsoleWrite(StringFormat("zmq_msg_init_data = %s", zmq_msg_init_data(DllStructGetPtr($msg),DllStructGetPtr($data),6,$hHandle,null)) & @CRLF) When it might be better to do something like this: $someVar = zmq_msg_init_data(DllStructGetPtr($msg),DllStructGetPtr($data),6,$hHandle,null) If @error Then Return MsgBox($MB_ICONERROR, "ERROR", "Some error occured. @error = " & @error) ConsoleWrite("zmq_msg_init_data = " & $someVar & @CRLF) Like I said, this assumes that zmq_msg_init_data() appropriately sets @error if an error was encountered. The other benefit to using similar logic is that you don't continue when an error has occurred. Obviously if you were not successful in initializing your msg data, you shouldn't continue.
    1 point
  9. Global $hHandle = DllCallbackRegister(zmq_free_fn, "none", "ptr;ptr") You can remove double quotes around any reference to functions. It will make it detectable for au3check if the function is wrong.
    1 point
  10. @dPilar Have a look at _WD_UpdateDriver in wd_helper.au3.
    1 point
  11. How do you want to add new values? At the top of the list, at the end, before/after a selected item?
    1 point
  12. Now you are just being delusional, there is no such thing Anything and everything is possible in Linux, unlike Windows where you are restricted to the capabilities it provides. Linux is more open and innovative, anyone can extended it to make it work however they like. You just need to know how things work in Linux, which is different from Windows obviously.
    1 point
  13. As your link points out, the declaration of the function is: void zmq_version (int *major, int *minor, int *patch); The test script below works for me: #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> zeromq_test() Func zeromq_test() Local $aResult $aResult = DllCall("libzmq-v142-mt-4_3_4.dll", "none", "zmq_version", _ "int*", Null, _ ;Major "int*", Null, _ ;Minor "int*", Null) ;Patch If @error Then Return MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "DllCall Error - @error = " & @error) ConsoleWrite(StringFormat("zeroMQ Version = %s.%s.%s", $aResult[1], $aResult[2], $aResult[3]) & @CRLF) EndFunc Console Output: zeroMQ Version = 4.3.4
    1 point
  14. Close, but I think it would look something like this: Const $tag_zmq_msg_t = "struct; BYTE var1[32]; endstruct;" Or just: Const $tag_zmq_msg_t = "BYTE var1[32];" since the struct/endstruct is implied in this case.
    1 point
  15. No way! I promise to finish it before your time runs out... so that you can finally enjoy the fruits of Linux without any restrictions Disclaimer: The above mentioned text should not be, in any way, be constructed into a contract, promise, guarantee or any other type of bond with liability
    1 point
  16. Suggest that you comment out this line and then rerun your tests, If you aren't using Scite, you can set logging to a file with _WD_Option / Console. Then post the log here if you need additional help with diagnosing the error. P.S. The error 10 is $_WD_ERROR_Exception
    1 point
  17. Mat

    GUICtrlOnChangeRegister

    It's on old trick using WM_COMMAND, but it's now nice and easy to use. Its syntax is very similar to GUICtrlSetOnEvent, however it does have an extra parameter for parameters for the function. example: #Include "GUIonchangeRegister.au3" GUICreate ("test") $EditID = GUICtrlCreateEdit ("", 2, 2, 300, 300) GUICtrlonchangeRegister (-1, "MyFunc", "42|53") GUISetState () While GUIGetMsg () <> -3 Sleep (10) WEnd Func MyFunc ($i, $n) Tooltip ("You sent data!! params: " & $i & ", " & $n) EndFunc ; ==> MyFunc #Include-once #Include<Array.au3> Global $INTERNAL_CHANGE_REGISTER[1][3] = [[0, 0, 0]] GUIRegisterMsg (0x0111, "__GUI_CHANGE_REGISTER_WM_COMMAND") ; #FUNCTION# ;==================================================================================================================== ; ; Name...........: GUICtrlonchangeRegister ; Description ...: Registers an edit or input control to trigger a function when edited. ; Syntax.........: GUICtrlonchangeRegister($hEdit, $sFunc [, $sParams] ) ; Parameters ....: $hEdit - The handle to the edit control (can be a control ID) ; $sFunc - The string function, as used in functions like HotKeySet + GUISetOnEvent. ; $sParams - a "|" seperated list of parameters for the function (Optional, default = "") ; Return values .: Success - 1 ; Failure - 0 And Sets @Error to 1 ; Author ........: Mat ; Modified.......: ; Remarks .......: When using the pipe, use "\|" to stop it from being a seperator. ; Related .......: GUICtrlonchangeUnRegister ; Link ..........: ; Example .......: Yes ; ; ;=============================================================================================================================== Func GUICtrlonchangeRegister ($hEdit, $sFunc, $sParams = "") If $hEdit = -1 Then $hEdit = GUICtrlGetHandle (-1) If Not IsHwnd ($hEdit) Then $hEdit = GUICtrlGetHandle ($hEdit) If $hEdit = 0 Then Return SetError (1, 0, 0) ; $hEdit does not exist If $sFunc = "" Then Return GUICtrlonchangeUnRegister ($hEdit) ReDim $INTERNAL_CHANGE_REGISTER[UBound ($INTERNAL_CHANGE_REGISTER) + 1][3] $INTERNAL_CHANGE_REGISTER[0][0] += 1 $INTERNAL_CHANGE_REGISTER[$INTERNAL_CHANGE_REGISTER[0][0]][0] = $hEdit $INTERNAL_CHANGE_REGISTER[$INTERNAL_CHANGE_REGISTER[0][0]][1] = $sFunc $INTERNAL_CHANGE_REGISTER[$INTERNAL_CHANGE_REGISTER[0][0]][2] = $sParams Return 1 Endfunc ; ==> GUICtrlonchangeRegister ; #FUNCTION# ;==================================================================================================================== ; ; Name...........: GUICtrlonchangeUnRegister ; Description ...: UnRegisters an edit or input control so it no longer triggers a function ; Syntax.........: GUICtrlonchangeUnRegister($hEdit) ; Parameters ....: $hEdit - The handle to the edit control (can be a control ID) ; Return values .: Success - 1 ; Failure - 0 And Sets @Error to 1 ; Author ........: Mat ; Modified.......: ; Remarks .......: ; Related .......: GUICtrlonchangeRegister ; Link ..........: ; Example .......: Yes ; ; ;=============================================================================================================================== Func GUICtrlonchangeUnRegister ($hEdit) If $hEdit = -1 Then $hEdit = GUICtrlGetHandle (-1) If Not IsHwnd ($hEdit) Then $hEdit = GUICtrlGetHandle ($hEdit) If $hEdit = 0 Then Return SetError (1, 0, 0) ; $hEdit does not exist Local $i = __GUI_CHANGE_REGISTER_GETINDEX ($hEdit) If $i < 0 Then Return SetError (1, 0, 0) _ArrayDelete ($INTERNAL_CHANGE_REGISTER, $i) $INTERNAL_CHANGE_REGISTER[0][0] -= 1 Return 1 Endfunc ; ==> GUICtrlonchangeUnRegister ; #INTERNAL# ;==================================================================================================================== ; ; Name...........: __GUI_CHANGE_REGISTER_WM_COMMAND ; Description ...: Handles the WM_COMMAND message and triggers events. ; Syntax.........: __GUI_CHANGE_REGISTER_WM_COMMAND ($hWnd, $msgID, $wParam, $lParam) ; Parameters ....: $hEdit - The handle to the edit control (can be a control ID) ; Return values .: "GUI_RUNDEFMSG" ; Author ........: Mat ; Modified.......: ; Remarks .......: ; Related .......: GUICtrlonchangeRegister ; Link ..........: ; Example .......: Yes ; ; ;=============================================================================================================================== Func __GUI_CHANGE_REGISTER_WM_COMMAND ($hWnd, $msgID, $wParam, $lParam) If (BitShift($wParam, 16) <> 768) Then Return "GUI_RUNDEFMSG" Local $i = __GUI_CHANGE_REGISTER_GETINDEX ($lParam) If $i < 0 Then Return "GUI_RUNDEFMSG" If $INTERNAL_CHANGE_REGISTER[$i][1] = "" Then Call ($INTERNAL_CHANGE_REGISTER[$i][1]) Else Local $avParams = StringRegExp ($INTERNAL_CHANGE_REGISTER[$i][2], "(.*?[^\\])?(?:\||$)", 3) For $x = Ubound ($avParams) - 2 to 0 Step -1 $avParams[$x + 1] = $avParams[$x] Next $avParams[0] = "CallArgArray" Call ($INTERNAL_CHANGE_REGISTER[$i][1], $avParams) EndIf Return "GUI_RUNDEFMSG" EndFunc ; ==> __GUI_CHANGE_REGISTER_WM_COMMAND ; #INTERNAL# ;==================================================================================================================== ; ; Name...........: __GUI_CHANGE_REGISTER_GETINDEX ; Description ...: Returns the array index for an Edit HWnd, or -1. ; Syntax.........: __GUI_CHANGE_REGISTER_GETINDEX($hWnd) ; Parameters ....: $hWnd - The handle to the edit control (can NOT be a control ID) ; Return values .: The index or -1 ; Author ........: Mat ; Modified.......: ; Remarks .......: ; Related .......: __GUI_CHANGE_REGISTER_WM_COMMAND ; Link ..........: ; Example .......: Yes ; ; ;=============================================================================================================================== Func __GUI_CHANGE_REGISTER_GETINDEX ($hWnd) For $i = 1 to $INTERNAL_CHANGE_REGISTER[0][0] If $hWnd = $INTERNAL_CHANGE_REGISTER[$i][0] Then Return $i Next Return SetError (1, 0, -1) Endfunc ; ==> __GUI_CHANGE_REGISTER_GETINDEX and for those who don't like copying + pasting: http://m-a-t.googlecode.com/files/GUIonchangeRegister.au3 Mat
    1 point
  18. Using SNMP - MIB protocol In the support forum someone was asking if there was a possibility to readout the printer toner status using SNMP. For those who don't know what SNMP is : In order to retrieve data from an SNMP device you need to read the MIB database structure. For those who want to know more about MIB's : So the key to the lock is : 1. have the SNMP protocol communication = UDP 161 2. Read the MIB for the info you want to retrieve The first thing is simple in AU3, create a UDF socket. The second thing takes more time to dig. Microsoft supplies by default some MIB file in your windows. Look in C:\Windows\System32\ for *.MIB files Reading them is easy. Just open them in Notepad and read. It contains a structure of hierarchy information which was defined occording to the RFC1213 and others. So now what ? You can query the some MIB object using WMI. $strTargetSnmpDevice = "10.0.0.x" ; Device IP Address $objWmiLocator = ObjCreate("WbemScripting.SWbemLocator") $objWmiServices = $objWmiLocator.ConnectServer("", "rootsnmplocalhost") $objWmiNamedValueSet = ObjCreate("WbemScripting.SWbemNamedValueSet") $objWmiNamedValueSet.Add ("AgentAddress", $strTargetSnmpDevice) $objWmiNamedValueSet.Add ("AgentReadCommunityName", "public") $colIfTable = $objWmiServices.InstancesOf("SNMP_RFC1213_MIB_ifTable",Default , $objWmiNamedValueSet) For $objInterface In $colIfTable ConsoleWrite ("ifIndex [Key]: " & $objInterface.ifIndex & @CRLF & _ " ifAdminStatus: " & $objInterface.ifAdminStatus & @CRLF & _ " ifDescr: " & $objInterface.ifDescr & @CRLF & _ " ifInDiscards: " & $objInterface.ifInDiscards & @CRLF & _ " ifInErrors: " & $objInterface.ifInErrors & @CRLF & _ " ifInNUcastPkts: " & $objInterface.ifInNUcastPkts & @CRLF & _ " ifInOctets: " & $objInterface.ifInOctets & @CRLF & _ " ifInUcastPkts: " & $objInterface.ifInUcastPkts & @CRLF & _ " ifInUnknownProtos: " & $objInterface.ifInUnknownProtos & @CRLF & _ " ifLastChange: " & $objInterface.ifLastChange & @CRLF & _ " ifMtu: " & $objInterface.ifMtu & @CRLF & _ " ifOperStatus: " & $objInterface.ifOperStatus & @CRLF & _ " ifOutDiscards: " & $objInterface.ifOutDiscards & @CRLF & _ " ifOutErrors: " & $objInterface.ifOutErrors & @CRLF & _ " ifOutNUcastPkts: " & $objInterface.ifOutNUcastPkts & @CRLF & _ " ifOutOctets: " & $objInterface.ifOutOctets & @CRLF & _ " ifOutQLen: " & $objInterface.ifOutQLen & @CRLF & _ " ifOutUcastPkts: " & $objInterface.ifOutUcastPkts & @CRLF & _ " ifPhysAddress: " & $objInterface.ifPhysAddress & @CRLF & _ " ifSpecific: " & $objInterface.ifSpecific & @CRLF & _ " ifSpeed: " & $objInterface.ifSpeed & @CRLF & _ " ifType: " & $objInterface.ifType & @CRLF) Next Enjoy !! regards ptrex
    1 point
  19. Inherent restrictions of Linux aside.
    0 points
×
×
  • Create New...