Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/17/2023 in all areas

  1. Introduction JSON is a pure data exchange format. Basically you only have to deal with JSON in 2 places in a program: Once when reading JSON data and once when outputting data. In between it should not really matter that the data used to be JSON or should be converted to it. You should not need any special intermediate structures but only the elements that the respective programming language provides anyway. This is exactly the approach of this UDF: There is the function _JSON_Parse(), which converts an arbitrary JSON string into (nested) pure AutoIt data types (Arrays, Maps, Strings, Numbers, Null, True, False). And on the other side we have the function _JSON_Generate(), which generates a JSON string from arbitrary (nested) AutoIt data structures. Import and export JSON So how to use - let`s give an example: Handling nested data structures JSON is often very nested. The resulting AutoIt data is therefore naturally also nested, which makes it somewhat cumbersome to process with pure AutoIt on-board methods. For this reason, the UDF comes with a few helper functions that make life with this data easier. One of them is _JSON_Get(), which allows you to access deeply nested data with a simple query syntax. On the other hand there is the function _JSON_addChangeDelete() with which you can (the name already says it) change, add and delete data. You can even easily create deeply nested structures with a single call. Again, here is a small example of how to use it: Strictly speaking, these functions should not even have "JSON" in their names, since they are generally applied to data structures in AutoIt. However, since they are often used in the JSON environment, we allow ourselves this small inaccuracy. Why should i give it a try? Probably the most common method to deal with JSON in AutoIt is the variant via JSMN. My minor dissatisfactions with this approach led me to write this UDF in the first place a few years ago. So the incentives are quite JSMN related: Parsing and extraction of data is faster than in JSMN. (Only if the JSON string makes heavy use of JSON escapes should JSMN be a bit faster in parsing, since the escapes are resolved later.) Editing the data is easier, because you don't need special commands for the JSMN intermediate structure but deal directly with AutoIt structures. Generating JSON is also simple: build your structure in AutoIt as you like and then let it generate a JSON string for you with _JSON_Generate(). The UDF is smaller (28kb vs. 45kb) The UDF is in pure AutoIt. You can directly customize any behavior as you like. >>sourcecode and download on github<<
    3 points
  2. AutoXenon, Charming - please do try and keep it civil from now on Now go and look carefully at the example in the Help file for GUICtrlCreateInput and see where the $WS_EX_ACCEPTFILES extended style should be placed (Hint: not where you have it). M23
    3 points
  3. https://www.autoitscript.com/forum/profile/6718-lxp/ https://www.autoitscript.com/forum/topic/13374-_regclone/ https://github.com/Lx/autoit-ControlGetHandleByPos https://github.com/Lx/autoit-RegClone https://www.autoitscript.com/forum/profile/77744-centrally/ https://www.autoitscript.com/forum/topic/148005-imagesearch-usage-explanation https://github.com/ellysh?tab=repositories https://www.autoitscript.com/forum/profile/75336-scintilla4evr/ https://www.autoitscript.com/forum/topic/183506-motion-graphics-udf https://github.com/scidsgn?tab=repositories https://www.autoitscript.com/forum/profile/71248-danyfirex/ https://www.autoitscript.com/forum/topic/207324-uwpocr-windows-platform-optical-character-recognition-api-implementation/ https://github.com/orgs/DanysysTeam/repositories https://www.autoitscript.com/forum/profile/69387-isi360/ https://www.autoitscript.com/forum/topic/192960-isn-autoit-studio https://github.com/74ls00/ISN-AutoIt-Studio Okay that's the last batch for today :)
    2 points
  4. Oh wow, you're a real Sherlock 😅 . I will have a look later @noellarkin. Best regards Sven
    2 points
  5. Found him: Haven't used it myself, but it seems to be for controlling Android devices. https://github.com/htejera/AutoItMonkey
    2 points
  6. Danp2

    Get HTML Page

    To clarify, my suggestion was to use the loop following the ProcessWaitClose, not as a replacement for it. Do it this way will eliminate the chance that only a portion of the output is captured.
    1 point
  7. SUPPORTTI

    PORT RDP - (Moved)

    #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> $host = "172.16.16.100" ;<<<<<<< enter here the host name or ip address $port = "53899" ;Remote Desktop ActiveX Control Interfaces -> http://msdn.microsoft.com/en-us/library/aa383022(v=VS.85).aspx $hGUI = GUICreate("CONEXAO ROGERIO AUTO CENTER", 952, 675, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $oRDP = ObjCreate("MsTscAx.MsTscAx") ;http://msdn.microsoft.com/en-us/library/aa381344(v=VS.85).aspx $oRDP_Ctrl = GUICtrlCreateObj($oRDP, 64, 44, 800, 600) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE) $oRDP.DesktopWidth = 1366 $oRDP.DesktopHeight = 768 $oRDP.Fullscreen =768 $oRDP.ColorDepth = 32 $oRDP.AdvancedSettings2.RedirectDrives = True ; Sollen die Laufwerke mitgenommen werden $oRDP.AdvancedSettings2.RedirectPrinters = True ; Sollen die Drucker mitgenommen werden $oRDP.AdvancedSettings2.RedirectPorts = False ; Ports wie LPT1 etc $oRDP.AdvancedSettings2.RedirectSmartCards = False ; SmartCards für Authentifizierung $oRDP.AdvancedSettings2.EnableAutoReconnect = False $oRDP.AdvancedSettings2.allowBackgroundInput = False $oRDP.AdvancedSettings2.ConnectionBarShowRestoreButton = False $oRDP.AdvancedSettings3.SmartSizing = True $oRDP.AdvancedSettings5.AudioRedirectionMode = 0 $oRDP.AdvancedSettings2.ClearTextPassword = "Password" ; <<<<<<< enter here the user password $oRDP.AdvancedSettings8.EnableCredSspSupport = true $oRDP.AdvancedSettings2.RDPPort = $port $oRDP.Server = $host $oRDP.UserName = "Administrador" ;<<<<<<< enter here the user name $oRDP.Domain = "CLIENTE.LOCAL" ;<<<<<<< enter here the domain name $oRDP.ConnectingText = "Conectando a CLIENTE RDP " $oRDP.DisconnectedText = "Desconectado de CLIENTE RDP " $oRDP.StartConnected = True $oRDP.Connect() GUISetState(@SW_SHOW, $hGUI) ;~ ConsoleWrite($oRDP.GetErrorDescription() & @CRLF) While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             $oRDP.Disconnect()             Exit     EndSwitch WEnd Passing by to inform you that I found the solution thanks to the friends above thank you all very much.
    1 point
  8. Helpfile says.: will only work with Read example for GUICtrlCreateInput.
    1 point
  9. @SOLVE-SMART a few more: Each one has their AutoIt profile, a UDF they wrote and their Github link: https://www.autoitscript.com/forum/profile/104326-tragenalpha/ https://www.autoitscript.com/forum/topic/190864-software-aics-autoit-compiler-suite/ https://github.com/tragenalpha?tab=repositories https://www.autoitscript.com/forum/profile/97490-alzri/ https://www.autoitscript.com/forum/topic/180595-au4-library/ https://github.com/yaseralnajjar?tab=repositories https://www.autoitscript.com/forum/profile/54961-matwachich/ https://www.autoitscript.com/forum/topic/176515-udf-simple-flexible-multi-clients-tcp-server/ https://github.com/matwachich?tab=repositories https://www.autoitscript.com/forum/profile/102275-donchunior/ https://www.autoitscript.com/forum/topic/206400-background-intelligent-transfer-service-bits/ https://github.com/DonChunior?tab=repositories https://www.autoitscript.com/forum/profile/109280-mrkm/ https://www.autoitscript.com/forum/topic/206133-ocrspace-udf/ https://github.com/MurageKabui?tab=repositories https://www.autoitscript.com/forum/profile/81064-ergo/ https://www.autoitscript.com/forum/topic/194886-crontotimeau3-udf-cron-expression-parser/ https://github.com/seizu?tab=repositories https://www.autoitscript.com/forum/profile/92534-rynow/ https://www.autoitscript.com/forum/topic/187223-romasql/ https://github.com/4ern?tab=repositories https://www.autoitscript.com/forum/profile/77962-minxomat/ https://www.autoitscript.com/forum/files/file/366-autoit-oop-extender/ https://github.com/minxomat?tab=repositories (have been made private) https://www.autoitscript.com/forum/profile/21864-joeyb1275/ https://www.autoitscript.com/forum/topic/43950-id3-udf-id3v1-id3v2-mp3-tags/ https://github.com/joeyb1275?tab=repositories https://www.autoitscript.com/forum/profile/115186-vietanhdev/ https://www.autoitscript.com/forum/topic/206758-games-on-autoit3-lines98-minichess-and-tictactoe/ https://github.com/vietanhdev?tab=repositories https://www.autoitscript.com/forum/profile/113429-mateocedillo/ https://www.autoitscript.com/forum/topic/207413-can-you-make-a-voice-synthesizer-in-autoit-here-the-answer/ https://github.com/rmcpantoja?tab=repositories https://www.autoitscript.com/forum/profile/75137-jefrey/ https://www.autoitscript.com/forum/topic/205453-multi-threading/ https://github.com/jesobreira?tab=repositories
    1 point
  10. Hi @iSan, if you want to get the value of the title attribute you have to use "attribute" instead of "property". Get value of title would look like this: _WD_ElementAction($sSession, $sSelectElement, "attribute", "title") Get value of value would look like this: _WD_ElementAction($sSession, $sSelectElement, "attribute", "value") But your <input> with the ID suffix _inputCell_1.2 don't have a filled value attribute. So which information do you want? Best regards Sven
    1 point
  11. My example ConsoleWrite("_IncrementNumber($iNumber)"&@CRLF) is wrong as it misses the trailing $. ExpandVarStrings does exactly what it is supposed to do (tested using AutoIt 3.3.16.0): AutoItSetOption("ExpandVarStrings", 0) ConsoleWrite("_IncrementNumber($iNumber$)" & @CRLF) returns "_IncrementNumber($iNumber$)" and AutoItSetOption("ExpandVarStrings", 1) ConsoleWrite("_IncrementNumber($iNumber$)" & @CRLF) returns "_IncrementNumber(123)".
    1 point
  12. Hi @water. The use of ExpandVarStrings seems to be redundant Your example works event if "ExpandVarStrings" is omitted. example code to show why: AutoItSetOption("ExpandVarStrings", 1) global $iNumber = 123; ConsoleWrite("_IncrementNumber($iNumber)"&@CRLF) ConsoleWrite("_IncrementNumber($iNumber$)"&@CRLF) To be clear, your example works perfectly fine, just wanted to clarify that ExpandVarStrings had nothing to do with it
    1 point
  13. Here is an example of this new way of declaring a GUI class. Notice that it's much easier and intuitive to set the styles in the example() function. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> example() Func example() $mWin = guiClass_New( "My Window", 600, 500) $mWin.resizible = True $mWin.hasMinBox = False $mWin.popup = True method( $mWin, "mSetStyle") method( $mWin, "mShow") $aList = method( $mWin, "mList") _ArrayDisplay($aList, "My Gui class properties and methods list") while True switch GUIGetMsg() Case $GUI_EVENT_CLOSE exit EndSwitch sleep(1) Wend EndFunc Func method(ByRef $obj, $method, $para = "") $m = $obj[$method] if $m = "" or Not IsFunc($m) then Return SetError(1) If $para = "" Then Return call( $obj[$method], $obj ) ; No parameters return call( $obj[$method], $obj, $para ) ; with some parameters. EndFunc Func guiClass_move( ByRef $obj , $iSpeed = 0) ; First, set the left, top, or/and width, heigh properties, ; The call this method $hWnd = WinMove( $obj.gui, "", $obj.left, $obj.top, $obj.width, $obj.height, $iSpeed) Return SetError(@error, @extended, $hWnd) EndFunc Func guiClass_hide(ByRef $obj) WinSetState($obj.gui, "", @SW_HIDE) $obj.state = WinGetState($obj.gui) EndFunc Func guiClass_show(ByRef $obj) WinSetState($obj.gui, "", @SW_SHOW) $obj.state = WinGetState($obj.gui) EndFunc Func guiClass_close(ByRef $obj) WinClose($obj.gui) $obj = Null EndFunc Func guiClass_listClass(ByRef $obj) ; list all properties and methods as 2D array ; $a[0] is the name, $a[1] is the value, $a[2] is the var type $aKeys = MapKeys($obj) $iCount = UBound($aKeys) Local $aList[$iCount][3] For $i = 0 to $iCount -1 $aList[$i][0] = $aKeys[$i] $aList[$i][1] = $obj[ $aKeys[$i] ] $aList[$i][2] = VarGetType( $aList[$i][1] ) Next Return $aList EndFunc Func guiClass_updateStatus(ByRef $obj) if Not WinExists($obj.gui) Then Return SetError(1) ; Set current status $aPos = WinGetPos($obj.gui) if @error Then Return SetError(2) $obj.left = $aPos[0] $obj.top = $aPos[1] $obj.width = $aPos[2] $obj.height = $aPos[3] $obj.state = WinGetState($obj.gui) $obj.title = WinGetTitle($obj.gui) $aStyle = GUIGetStyle($obj.gui) $obj.style = $aStyle[0] $obj.exstyle = $aStyle[1] EndFunc Func guiClass_flash(ByRef $obj) WinFlash($obj.gui) EndFunc Func guiClass_setStyle(ByRef $obj) $iStyle = $obj.style $iStyle = BitOR( _ $obj.resizible ? $WS_SIZEBOX : 0, _ $obj.thinBorder ? $WS_BORDER : 0, _ $obj.popup ? $WS_POPUP : 0, _ $obj.hasTitle ? $WS_DLGFRAME : 0, _ $obj.hasMaxBox ? $WS_MAXIMIZEBOX : 0, _ $obj.hasMinBox ? $WS_MINIMIZEBOX : 0, _ $obj.hasSysMenu ? $WS_SYSMENU : 0 _ ) $obj.style = $iStyle GUISetStyle($iStyle) EndFunc Func guiClass_New($sTitle = "", $iWidth = 800, $iHeight = 450, $iLeft = -1, $iTop = -1, $iStyle = $GUI_SS_DEFAULT_GUI, $iExStyle = 0, $hParent = 0) Local $obj[] ; Initialize all default values. $obj.title = $sTitle $obj.width = $iWidth $obj.height = $iHeight $obj.left = $iLeft $obj.top = $iTop $obj.style = $iStyle $obj.exstyle = $iExStyle $obj.parentGui = $hParent ; Main Styles $obj.resizible = BitAND( $iStyle, $WS_SIZEBOX) = $WS_SIZEBOX $obj.thinBorder = BitAND($iStyle, $WS_BORDER) = $WS_BORDER $obj.popup = BitAND($iStyle, $WS_POPUP) = $WS_POPUP $obj.hasTitle = BitAND($iStyle, $WS_DLGFRAME) = $WS_DLGFRAME $obj.hasMaxBox = BitAND($iStyle, $WS_MAXIMIZEBOX) = $WS_MAXIMIZEBOX $obj.hasMinBox = BitAND($iStyle, $WS_MINIMIZEBOX) = $WS_MINIMIZEBOX $obj.hasSysMenu = BitAND($iStyle, $WS_SYSMENU) = $WS_SYSMENU ; Methods $obj.mMove = guiClass_move $obj.mHide = guiClass_hide $obj.mShow = guiClass_show $obj.mClose = guiClass_close $obj.mList = guiClass_listClass $obj.mFlash = guiClass_flash $obj.mSetStyle = guiClass_setStyle ; Create the gui local $hGui = GUICreate($obj.title, $obj.width, $obj.height, $obj.left, $obj.top, $obj.style, $obj.exstyle, $obj.parentGui) if @error then Return SetError(1) $obj.gui = $hGui $obj.pid = WinGetProcess($hGui) $obj.state = WinGetState($hGui) Return $obj EndFunc Func c($str) ConsoleWrite($str & @CRLF) EndFunc
    1 point
  14. The problem is I don't know which one is from Healthcare insurance or Citibank, who has legitimate business with me. Those guys usually use their own 1800 or 1888 numbers. Each time they use a different number. So it's impossible to put all of them into a contatc white list.
    1 point
  15. Also note that functions are first-class citizens in AutoIt. ConsoleWrite(VarGetType(ConsoleWrite) & @LF) ConsoleWrite(VarGetType(_MyFunc) & @LF) Local $v = _MyFunc ConsoleWrite($v() & @LF) Func _MyFunc() Return("Done") EndFunc This way keeps you away from calling a badly formed function name, like Call("MyFunc")
    1 point
  16. Malkey

    Stringleft and Array

    Here are two one-liners that will return StringLeft() and StringRight() of all items in a 1D or 2D array. #include <array.au3> ; 1D Aarray Local $aArray[] = ["02", 1234, 23456789, "3456733333333333333333333"] ; Or, 2D Array ;Local $aArray[][] = [["02", 1234, 23456789, "3456733333333333333333333"],["ab", "cdefg","hijklmnop"]] _ArrayDisplay($aArray) $aArray1 = _ArrayFromString(StringRegExpReplace(_ArrayToString($aArray, "!"), "([^!\v]{3}).[^!\v]*", "\1"), "!") ; _ArrayAllItemsStringLeft _ArrayDisplay($aArray1, "Left") $aArray2 = _ArrayFromString(StringRegExpReplace(_ArrayToString($aArray, "!"), "[^!\v]*([^!\v]{3})", "\1"), "!") ; _ArrayAllItemsStringRight _ArrayDisplay($aArray2, "Right")
    1 point
  17. Musashi

    Stringleft and Array

    I got that . The problem is the size of the third value. If you need to work with values that exceed the above limits, then it is worth taking a look at the bignum-udf
    1 point
  18. I don't have the client software to test with, but I would recommend seeing if you are able to use the _GUICtrlTreeView_* functions instead. Those functions are a much more elegant and reliable way to interact with treeview controls instead of send keystrokes. It would also be a meaningful exercise to improve your scripting skills. You can use the Au3Info*.exe tool included with AutoIt it see what kind of control the treeview is using. Drag the Finder Tool icon over the PRONTO treeview control, and if it is a SysTreeView32 class control you should be able to use the _GUICtrlTreeView_* UDF to automate it. It if is not a SysTreeView control, there may still be a way to automate the control directly requires the use of more complex functions (i.e. IUIAutomation). ...just a recommendation
    1 point
  19. GUIs of interest here are non-AutoIt GUIs not created with GUICreate(). They are created with Windows API functions eg. _WinAPI_CreateWindowEx(). (2020-04-26) Is it possible in such a non-AutoIt GUI to implement a Windows message loop? Which functionality and techniques do and do not work in such non-AutoIt GUIs? Which internal functions can be used? Can AutoIt and non-AutoIt GUIs exist side by side in the same script? Can existing UDFs be used? This example started last week with inspiration from this thread. After several tests during the week, I've decided to make a little more of the example. This is an update of first post. Over the coming weeks I'll be adding more code in new posts. If it all works well and stable, the ideas in the project may be seen in a wider perspective. Some information has been deleted during this update. The information will be added again later. Basic functionality What is a Windows message loop In Microsoft documentation, a message loop is usually coded like this: while GetMessage(&msg, 0, 0, 0) { // Retrieve a message from the message queue // Processes accelerator keystrokes if (!TranslateAccelerator( hwndMain, // handle to receiving window haccel, // handle to active accelerator table &msg)) // message data { TranslateMessage(&msg); // Translate a virtual-key message into a character message DispatchMessage(&msg); // Send a message to the window procedure } } And the window procedure is defined like this: LRESULT CALLBACK WinProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam) // second message parameter { switch (uMsg) { case WM_CREATE: // Initialize the window. return 0; case WM_PAINT: // Paint the window's client area. return 0; case WM_SIZE: // Set the size and position of the window. return 0; case WM_DESTROY: // Clean up window-specific data objects. return 0; // // Process other messages. // default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 0; } Message loop The purpose of a message loop is first and foremost to keep the program running and prevent it from ending immediately. It's exactly the same in AutoIt. But why so complicated code as shown above? It's necessary for advanced message handling eg. to use keyboard accelerators that are local to the individual program and not global as hot keys. Window procedure The window procedure handles the messages sent from the DispatchMessage() function in the message loop. Even in a simpler message loop, messages are sent to the window procedure. This is done through deault code in the Windows API functions and the operating system. If a message isn't handled by the window procedure, it's forwarded to the default window procedure DefWindowProc(). 0) _WinAPI_RegisterClassEx.au3 This is the example of _WinAPI_RegisterClassEx() in the help file. _WinAPI_CreateWindowEx() is used to create the GUI window. The example here is a slightly modified version: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include <WinAPIRes.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Global $bExit = False Example() Func Example() Local Const $sClass = "MyWindowClass" Local Const $sName = "_WinAPI_RegisterClassEx" ; Get module handle for the current process Local $hInstance = _WinAPI_GetModuleHandle( 0 ) ; Create a class cursor Local $hCursor = _WinAPI_LoadCursor( 0, 32512 ) ; IDC_ARROW ; Create a class icons (large and small) Local $tIcons = DllStructCreate( "ptr;ptr" ) _WinAPI_ExtractIconEx( @SystemDir & "\shell32.dll", 130, DllStructGetPtr( $tIcons, 1 ), DllStructGetPtr( $tIcons, 2 ), 1 ) Local $hIcon = DllStructGetData( $tIcons, 1 ) Local $hIconSm = DllStructGetData( $tIcons, 2 ) ; Create DLL callback function (window procedure) Local $pWinProc = DllCallbackGetPtr( DllCallbackRegister( "WinProc", "lresult", "hwnd;uint;wparam;lparam" ) ) ; Create and fill $tagWNDCLASSEX structure Local $tWCEX = DllStructCreate( $tagWNDCLASSEX & ";wchar szClassName[" & ( StringLen( $sClass ) + 1 ) & "]" ) DllStructSetData( $tWCEX, "Size", DllStructGetPtr( $tWCEX, "szClassName" ) - DllStructGetPtr( $tWCEX ) ) DllStructSetData( $tWCEX, "Style", 0 ) DllStructSetData( $tWCEX, "hWndProc", $pWinProc ) DllStructSetData( $tWCEX, "ClsExtra", 0 ) DllStructSetData( $tWCEX, "WndExtra", 0 ) DllStructSetData( $tWCEX, "hInstance", $hInstance ) DllStructSetData( $tWCEX, "hIcon", $hIcon ) DllStructSetData( $tWCEX, "hCursor", $hCursor ) DllStructSetData( $tWCEX, "hBackground", _WinAPI_CreateSolidBrush( _WinAPI_GetSysColor( $COLOR_3DFACE ) ) ) DllStructSetData( $tWCEX, "MenuName", 0 ) DllStructSetData( $tWCEX, "ClassName", DllStructGetPtr( $tWCEX, "szClassName" ) ) DllStructSetData( $tWCEX, "hIconSm", $hIconSm ) DllStructSetData( $tWCEX, "szClassName", $sClass ) ; Register a window class _WinAPI_RegisterClassEx( $tWCEX ) ; Create a window _WinAPI_CreateWindowEx( 0, $sClass, $sName, BitOR( $WS_CAPTION, $WS_POPUPWINDOW, $WS_VISIBLE ), ( @DesktopWidth - 826 ) / 2, ( @DesktopHeight - 584 ) / 2, 826, 584, 0 ) ; Main msg loop While Sleep(10) If $bExit Then ExitLoop WEnd ; Unregister window class and release resources _WinAPI_UnregisterClass( $sClass, $hInstance ) _WinAPI_DestroyCursor( $hCursor ) _WinAPI_DestroyIcon( $hIcon ) _WinAPI_DestroyIcon( $hIconSm ) EndFunc ; Window procedure Func WinProc( $hWnd, $iMsg, $wParam, $lParam ) Switch $iMsg Case $WM_CLOSE $bExit = True EndSwitch Return _WinAPI_DefWindowProcW( $hWnd, $iMsg, $wParam, $lParam ) EndFunc Note that the Esc key, which can normally be used to close an AutoIt window, doesn't work. But you can use Alt+F4 to close the window. Alt+F4 is a hot key. In the example, the main message loop is coded this way: ; Main msg loop While Sleep(10) If $bExit Then ExitLoop WEnd And the window procedure that handles messages: Func WinProc( $hWnd, $iMsg, $wParam, $lParam ) Switch $iMsg Case $WM_CLOSE $bExit = True EndSwitch Return _WinAPI_DefWindowProcW( $hWnd, $iMsg, $wParam, $lParam ) EndFunc Esc key In AutoIt, the Esc key to exit the program is implemented as an accelerator key. But this simple message loop is unable to handle keyboard accelerators. Keyboard accelerators The Microsoft documentation for keyboard accelerators can be found here. To use keyboard accelerators in a program, the following code steps must be implemented: Create a keyboard accelerator struct to store information Fill in the accelerator key structure with information Create an accelerator table with CreateAcceleratorTable() Include TranslateAccelerator() in the message loop Include a WM_COMMAND message handler in the window procedure Includes\WinMsgLoop.au3 (2020-04-26) WinMsgLoop.au3 implements the functions to use keyboard accelerators and to create a Windows message loop: #include-once ; Message structure Global Const $tagMSG = "hwnd hwnd;uint message;wparam wParam;lparam lParam;dword time;int X;int Y" ; Keyboard accelerator structure Global Const $tagACCEL = "byte fVirt;word key;word cmd;" ; Values of the fVirt field Global Const $FVIRTKEY = TRUE Global Const $FNOINVERT = 0x02 Global Const $FSHIFT = 0x04 Global Const $FCONTROL = 0x08 Global Const $FALT = 0x10 #cs ; One accelerator key Local $tAccel = DllStructCreate( $tagACCEL ) DllStructSetData( $tAccel, "fVirt", $FVIRTKEY ) DllStructSetData( $tAccel, "key", $VK_ESCAPE ) DllStructSetData( $tAccel, "cmd", $VK_ESCAPE ) ; cmd = key to keep it simple ; Two accelerator keys Local $tAccel = DllStructCreate( $tagACCEL & $tagACCEL ) DllStructSetData( $tAccel, 1, $FVIRTKEY ) DllStructSetData( $tAccel, 2, $VK_KEY1 ) DllStructSetData( $tAccel, 3, $VK_KEY1 ) DllStructSetData( $tAccel, 4, $FVIRTKEY ) DllStructSetData( $tAccel, 5, $VK_KEY2 ) DllStructSetData( $tAccel, 6, $VK_KEY2 ) #ce ; Error handling ; @error = 0: No errors ; 1: Parameter error ; Create a keyboard accelerator table Func WinMsgLoop_CreateAcceleratorTable( $tAccel ) Local $iSize = DllStructGetSize( $tAccel ) If Mod( $iSize, 6 ) Then Return SetError(1,0,0) ; SetError ( code [, extended = 0 [, return value]] ) Return DllCall( "User32.dll", "handle", "CreateAcceleratorTableW", "struct*", $tAccel, "int", $iSize/6 )[0] EndFunc ; Retrieve a message from the message queue Func WinMsgLoop_GetMessage( ByRef $tMsg ) Return DllCall( "User32.dll", "bool", "GetMessageW", "struct*", $tMsg, "hwnd", 0, "uint", 0, "uint", 0 )[0] EndFunc ; Processes accelerator keystrokes Func WinMsgLoop_TranslateAccelerator( $hWnd, $hAccel, ByRef $tMsg ) Return DllCall( "User32.dll", "int", "TranslateAcceleratorW", "hwnd", $hWnd, "handle", $hAccel, "struct*", $tMsg )[0] EndFunc ; Processes dialog box messages Func WinMsgLoop_IsDialogMessage( $hWnd, ByRef $tMsg ) Return DllCall( "User32.dll", "bool", "IsDialogMessageW", "hwnd", $hWnd, "struct*", $tMsg )[0] EndFunc ; Translate a virtual-key message into a character message Func WinMsgLoop_TranslateMessage( ByRef $tMsg ) DllCall( "User32.dll", "bool", "TranslateMessage", "struct*", $tMsg ) EndFunc ; Send a message to the window procedure Func WinMsgLoop_DispatchMessage( ByRef $tMsg ) DllCall( "User32.dll", "lresult", "DispatchMessageW", "struct*", $tMsg ) EndFunc ; Destroy a keyboard accelerator table Func WinMsgLoop_DestroyAcceleratorTable( $hAccel ) DllCall( "User32.dll", "bool", "DestroyAcceleratorTable", "handle", $hAccel ) EndFunc ; Posts a WM_QUIT message to the message queue ; WinMsgLoop_GetMessage() returns 0 on WM_QUIT and the message loop terminates Func WinMsgLoop_PostQuitMessage( $iExitCode = 0 ) Return DllCall( "User32.dll", "none", "PostQuitMessage", "int", $iExitCode )[0] EndFunc 1) Windows message loop.au3 In this example, the Esc and End keys can be used to exit the program. It contains a complete Windows message loop. The script contains a number of ConsoleWrites so you can see what's going on in SciTE console. Keyboard accelerators: #cs ; Esc accelerator key to Exit ; Create keyboard accelerator structure Local $tAccel = DllStructCreate( $tagACCEL ) DllStructSetData( $tAccel, "fVirt", $FVIRTKEY ) DllStructSetData( $tAccel, "key", $VK_ESCAPE ) DllStructSetData( $tAccel, "cmd", $VK_ESCAPE ) ; cmd = key to keep it simple #ce ; Esc/End accelerator keys to Exit ; Create keyboard accelerator structure Local $tAccel = DllStructCreate( $tagACCEL & $tagACCEL ) DllStructSetData( $tAccel, 1, $FVIRTKEY ) DllStructSetData( $tAccel, 2, $VK_ESCAPE ) DllStructSetData( $tAccel, 3, $VK_ESCAPE ) ; cmd = key to keep it simple DllStructSetData( $tAccel, 4, $FVIRTKEY ) DllStructSetData( $tAccel, 5, $VK_END ) DllStructSetData( $tAccel, 6, $VK_END ) ; Create a keyboard accelerator table Local $hAccel = WinMsgLoop_CreateAcceleratorTable( $tAccel ) ConsoleWrite( "$hAccel = " & $hAccel & @CRLF & @CRLF ) Using dialog box keys (2020-04-26) To use dialog box keys, the message loop must contain the IsDialogMessage() function. The function identifies and processes the keys. Windows message loop: (2020-04-26) ; Windows message loop Local $tMsg = DllStructCreate( $tagMSG ) While WinMsgLoop_GetMessage( $tMsg ) ; Retrieve a message from the message queue ConsoleWrite( "0x" & Hex( DllStructGetData( $tMsg, "message" ), 4 ) & @CRLF ) If Not WinMsgLoop_TranslateAccelerator( $hWnd, $hAccel, $tMsg ) And _ ; Processes accelerator keystrokes Not WinMsgLoop_IsDialogMessage( $hWnd, $tMsg ) Then ; Processes dialog box messages WinMsgLoop_TranslateMessage( $tMsg ) ; Translate a virtual-key message into a character message WinMsgLoop_DispatchMessage( $tMsg ) ; Send a message to the window procedure EndIf If $bExit Then ExitLoop WEnd WM_COMMAND message handler: (2020-04-26) Case $WM_COMMAND ConsoleWrite( @CRLF & "$WM_COMMAND" & @CRLF ) Switch BitShift( $wParam, 16 ) ; HiWord Case 1 ; Accelerator key ConsoleWrite( "Accelerator key" & @CRLF ) Switch BitAND( $wParam, 0xFFFF ) ; LoWord Case $VK_ESCAPE ConsoleWrite( "$VK_ESCAPE" & @CRLF ) _WinAPI_DestroyWindow( $hWnd ) Return 0 ; Don't call DefWindowProc() Case $VK_END ConsoleWrite( "$VK_END" & @CRLF ) _WinAPI_DestroyWindow( $hWnd ) Return 0 EndSwitch EndSwitch Program termination code: (2020-04-26) Case $WM_CLOSE ConsoleWrite( @CRLF & "$WM_CLOSE" & @CRLF ) If MsgBox( $MB_OKCANCEL, "Really close?", "My application", 0, $hWnd ) = $IDOK Then _WinAPI_DestroyWindow( $hWnd ) Else ConsoleWrite( @CRLF ) EndIf Return 0 ; Don't call DefWindowProc() Case $WM_DESTROY ConsoleWrite( @CRLF & "$WM_DESTROY" & @CRLF ) $bExit = True Return 0 2) Windows message loop 2.au3 (2020-04-26) Optimized version of the message loop because DllCall() is used directly instead of more time-consuming functions in WinMsgLoop.au3 UDF: ; Windows message loop Local $tMsg = DllStructCreate( $tagMSG ) While DllCall( "User32.dll", "bool", "GetMessageW", "struct*", $tMsg, "hwnd", 0, "uint", 0, "uint", 0 )[0] ; Retrieve a message from the message queue ConsoleWrite( "0x" & Hex( DllStructGetData( $tMsg, "message" ), 4 ) & @CRLF ) If Not DllCall( "User32.dll", "int", "TranslateAcceleratorW", "hwnd", $hWnd, "handle", $hAccel, "struct*", $tMsg )[0] And _ ; Processes accelerator keystrokes Not DllCall( "User32.dll", "bool", "IsDialogMessageW", "hwnd", $hWnd, "struct*", $tMsg )[0] Then ; Processes dialog box messages DllCall( "User32.dll", "bool", "TranslateMessage", "struct*", $tMsg ) ; Translate a virtual-key message into a character message DllCall( "User32.dll", "lresult", "DispatchMessageW", "struct*", $tMsg ) ; Send a message to the window procedure EndIf If $bExit Then ExitLoop WEnd 3) Navigating with Tab key.au3 (2020-04-26) When IsDialogMessage() is added to the code in the message loop, dialog box keys work immediately. Eg. Tab and Shift+Tab. Demonstrated in the example with three buttons. 4) Adding virtual ListView.au3 A virtual listview with cell background colors is created in the window. As it's a virtual list view, a WM_NOTIFY message handler is needed to handle LVN_GETDISPINFO notifications. Background colors are drawn through NM_CUSTOMDRAW notifications. A virtual and custom drawn listview is very message intensive and therefore interesting to test. ; Create ListView $hListView = _GUICtrlListView_Create( $hWnd, "", 10, 10, 800, 538, $LVS_DEFAULT+$LVS_OWNERDATA-$LVS_SINGLESEL, $WS_EX_CLIENTEDGE ) _GUICtrlListView_SetExtendedListViewStyle( $hListView, $LVS_EX_DOUBLEBUFFER+$LVS_EX_FULLROWSELECT ) ; Add columns For $i = 0 To $iCols - 1 _GUICtrlListView_AddColumn( $hListView, "Col " & $i, 96, 2 ) ; 2 = Centered text Next ; ListView items For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $aItems[$i][$j] = $i & "/" & $j Next Next ; ListView colors Local $aLVColors = [ 0xCCCCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFFCC, 0xFFCCCC, 0xFFCCFF ] ; BGR For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $aColors[$i][$j] = $aLVColors[Random( 0,5,1 )] Next Next ; Set number of rows in virtual ListView DllCall( "user32.dll", "lresult", "SendMessageW", "hwnd", $hListView, "uint", $LVM_SETITEMCOUNT, "wparam", $iRows, "lparam", 0 ) Case $WM_NOTIFY Switch DllStructGetData( DllStructCreate( $tagNMHDR, $lParam ), "Code" ) Case $LVN_GETDISPINFOW ; Fill virtual listview Local Static $tText = DllStructCreate( "wchar[100]" ), $pText = DllStructGetPtr( $tText ) Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If Not BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Return Local $sItem = $aItems[DllStructGetData($tNMLVDISPINFO,"Item")][DllStructGetData($tNMLVDISPINFO,"SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) Return 0 ; Don't call DefWindowProc() Case $NM_CUSTOMDRAW ; Draw back colors Local $tNMLVCUSTOMDRAW = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCUSTOMDRAW, "dwDrawStage" ), $iItem Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any item-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations Case $CDDS_ITEMPREPAINT + $CDDS_SUBITEM ; Before painting a subitem $iItem = DllStructGetData( $tNMLVCUSTOMDRAW, "dwItemSpec" ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[$iItem][DllStructGetData($tNMLVCUSTOMDRAW,"iSubItem")] ) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch Usage of the code I don't think there's such a great need for code like this. At least the code shows that translating Windows API functions into AutoIt works pretty well. Implementing the code in the WinMsgLoop.au3 UDF was straightforward. There is a question about using keyboard accelerators in non-AutoIt GUIs in this post. If you use AutoIt for prototyping, you might get some ideas here. Because the examples do not contain internal AutoIt functions but only Windows API functions, they are easy to translate into C/C++ and other languages. When translating back and forth between AutoIt and other languages, the internal functions are always the problem. How to translate these functions? Recent performance issue Recently, a problem was raised in this post regarding a multiple 100% performance degradation on Windows 10 versions later than 1803 as soon as a GUI element became visible in a script. The problem persisted throughout the rest of the code, even though the GUI element was deleted. I've tested the issue under Windows 10 1809 with all the examples here. All of the examples suffer from the problem. How much of the code needs to be translated into C/C++ before the problem disappears? Only the line which contains the _WinAPI_CreateWindowEx() function that creates and displays the window? Or does the problem still exist when all code is translated? That could be interesting. I've already done examples of translating AutoIt code into C/C++ eg. in this example and this example so it's not that hard. 7z-file The 7z-file contains source code for the UDFs and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. WinMsgLoop.7z
    1 point
  20. Because Koda's main web page (http://koda.darkhost.ru/page.php?id=download) isn't working, here is latest Koda 1.7.3 for download: koda_1.7.3.0.zip
    1 point
  21. According to the documentation for WS_TABSTOP, the IsDialogMessage() function must be included in the message loop to identify a keystroke as a dialog box key. Example here.
    1 point
  22. If you want to download directly, here is another example: Global $path = @DesktopDir & "\test.exe" $Surl = "http://download.thinkbroadband.com/5MB.zip" FileDownload($Surl, $path) Func FileDownload($url, $SavePath) Local $xml, $Stream $xml = ObjCreate("Microsoft.XMLHTTP"); Corrected from winhttp.winhttprequest.5.1 for faster dl $Stream = ObjCreate("Adodb.Stream") $xml.Open("GET", $url, 0) $xml.Send $Stream.Type = 1 $Stream.Open $Stream.write($xml.ResponseBody) $Stream.SaveToFile($SavePath) $Stream.Close EndFunc ;==>FileDownload
    1 point
  23. SUPPORTTI

    PORT RDP - (Moved)

    I have this script working OK I have been looking for a week how to add the terminal server port Default port 3389 Change to by 53899 where to add the port in this script with default port works normal Exemplo: 172.16.16.1:53899 #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> $host = "172.16.16.1" ;<<<<<<< insira aqui o nome do host ou endereço IP ;Remote Desktop ActiveX Control Interfaces -> http://msdn.microsoft.com/en-us/ library/aa383022(v=VS.85).aspx $hGUI = GUICreate("CONEXAO CLIENTE REMOTO", 952, 675, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $oRDP = ObjCreate("MsTscAx .MsTscAx") ;http://msdn.microsoft.com/en-us/library/aa381344(v=VS.85).aspx $oRDP_Ctrl = GUICtrlCreateObj($oRDP, 64, 44, 800, 600) GUICtrlSetResizing(- 1, $GUI_DOCKALL) GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE) $oRDP.DesktopWidth = 1366 $oRDP.DesktopHeight = 768 $oRDP.Fullscreen =768 $oRDP.ColorDepth = 32 $oRDP.AdvancedSettings2.RedirectDrives = Verdadeiro; Apenas as impressoras de baixa qualidade foram $ oRDP.AdvancedSettings2.RedirectPrinters = True ; Apenas o Drucker mitgenommen foi usado $oRDP.AdvancedSettings2.RedirectPorts = False ; Portas como LPT1 etc $oRDP.AdvancedSettings2.RedirectSmartCards = False ; SmartCards para Autenticação $oRDP.AdvancedSettings2.EnableAutoReconnect = False $oRDP.AdvancedSettings2.allowBackgroundInput = False $oRDP.AdvancedSettings2.ConnectionBarShowRestoreButton = False $oRDP.AdvancedSettings3.SmartSizing = True $oRDP.AdvancedSettings5.AudioRedirectionPasswordMode = 0 $oRDPCleartingTextword2. "Senha " ; <<<<<<< digite aqui a senha do usuário $oRDP.AdvancedSettings8.EnableCredSspSupport = true $oRDP.Server = $host $oRDP.UserName = "Administrador" ;<<<<<<< insira aqui o nome de usuário $oRDP.Domain = "CLIENTE.LOCAL" ;<<< <<<< insira aqui o nome do domínio $oRDP.ConnectingText = "Conectando a CLIENTE REMOTO " $oRDP.DisconnectedText = "Desconectado de CLIENTE REMOTO" $oRDP.StartConnected = True $oRDP.Connect() GUISetState(@SW_SHOW, $hGUI) ;~ ConsoleWrite($oRDP.GetErrorDescription() & @CRLF) Enquanto 1     $nMsg = GUIGetMsg()     Alternar $nMsg         Caso $GUI_EVENT_CLOSE             $oRDP.Disconnect()             Sair     EndSwitch WEnd
    0 points
  24. I have been playing with maps and realize that, if you need some simple object manipulation or something similar to class, maps can be of great help. Here is an example script to realize a simple class: myClass. The testObj below is a map declared by myClassNew(), and it comes with "mSet" and "mShow" 2 methods, and "status" as the only property. It's pretty easy to call the methods on this testObj, just use the "method" function. The properties are directly accessible like a real object. So this way is quite a simple and lightweight way to write your own class, which is actually a map. example() Func example() $testObj = myClass_New() c("Original status:" & $testObj.status) $testObj.status = "Set directly" c( "You can get or set the properties directly:" & @CRLF & "status:" & $testObj.status) c( "Or you can set the value by a method:" ) ; Run the methods for this class. method($testObj, "mSet", "the status set by mSet") c( "Status after mSet:" & $testObj.status) c( "And you can use a method to show the value:") $testObj.status = "status from method" method($testObj, "mShow") EndFunc Func method(ByRef $obj, $method, $para = "") $m = $obj[$method] if $m = "" or Not IsFunc($m) then Return SetError(1) If $para = "" Then Return call( $obj[$method], $obj ) ; No parameters return call( $obj[$method], $obj, $para ) ; with some parameters. EndFunc Func myClass_SetStatus(ByRef $obj , $text = "") $obj.status = $text Return EndFunc Func myClass_showStatus(ByRef $obj) c("Show value in a method:" & $obj.status ) Return EndFunc Func myClass_New() Local $obj[] $obj.mSet = myClass_SetStatus $obj.mShow = myClass_showStatus $obj.status = "start" Return $obj EndFunc Func c($str) ConsoleWrite($str & @CRLF) EndFunc
    0 points
×
×
  • Create New...