Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/26/2022 in all areas

  1. MattyD

    Midi UDF

    Hi all, Attached below are two segments of this project. The first "Midi API" is a wrap of the windows functions below. https://docs.microsoft.com/en-us/windows/win32/multimedia/midi-functions The second "Midi UDF" library is built on the first, and aims to provide a user friendly code base for people working with midi. This UDF so far covers: Channel Voice and Mode Messaging Registered Parameters (Channel Tuning, Mod Wheel/Pitch Bend ranges) Some prolific Non-Registered Parameters. Drum editing Envelope control Vibrato control Filter control General SysEx messaging Roland Data Transfer (DT1/RQ1) Yamaha XG Data Transfer & SysEx Parameter Control Global parameter control (GM2 Reverb & Chorus control) Device Control (Master Volume/Balance/Tuning) Octive/Scale Tuning Controller Destination settings (aftertouch/cc modulation editing) Active Sensing for Output Devices 3D Sound Controllers Midi Show Control - General Commands Importing and exporting midi files (experimental) Recording midi event sequences. (experimental) Midi Machine Control is currently not supported. Thank yous A quick shoutout shoutout to Water and Mr_Creator for the Simple Library Docs Generator - which was the originaly the basis of the helpfiles. Also a double to Water for the advanced help example (f1 key integration with scite). A couple of notes on synths. I've based the UDF on a couple of different RPs published many years apart, so implementation can be quite instrument specific. Don't expect too much of the builtin MS Wavetable Synth! I've had some more joy with the coolsoft midisynth with the choriumRevA soundfont if anyone is looking for a free alternative to test with. The two software synths mentioned above are also very slow responding to midi messages. If you forward messages to a physical instrument you should be able to play in real time. Previous versions: If anyone is after a previous release, they are all available on the sourceforge page. midi.zip
    1 point
  2. Wrong, it is prod in 3.3.16.0 and it is stable. But if array is what you understand more, i guess you should go ahead with it, but you are missing a good opportunity to learn a new approach.
    1 point
  3. Yes. You can create a MouseClickEx function that would do that for each action. You would only need to pass the name of the MouseClick, and it would do all (search map, get the 3 param and click the mouse accordingly).
    1 point
  4. As stated: I won't be making this (rather easy) change myself in the SciTE4AutoIt3 version unless it is made in the official version published by Neil Hodgson, which I use to apply my changes specifically for AutoIt3. I doubt many people will be running scripts from SciTE that take longer than a day as to me SciTE is used to develop scripts and not to run them for a long period.
    1 point
  5. Musashi: Of course I could add this elapsed timer to my code as a wrapper, but it is the console where the aberration is happening. I like to have the problem solved once and for all rather than implement workarounds globally. Do you unwind the workarounds once the problem gets fixed? Yikes - imagine all the releases, version control activity, and associated support issues for each bit of code. I have absolute trust in Jos to make the tweaks as time permits. Knowing most programmers, they absolutely hate to do a new release with known (minor) issues!
    1 point
  6. jchd

    Math based script

    @testerson Streamlined (I guess more correct) calculation: Local $sCalculate = Round($iInput * 0.945 * 1.2, 2) Substracting 5.5% is equivalent to multiplying by: (100 - 5.5) / 100 which is 0.945 Adding 20% is equivalent to multiplying by: (100 + 20) / 100 which is 1.2 You divide by 0.945, so you end up adding around 5.82% which I guess isn't what you want: 100 / 0.945 = 105.820105820106 With input 100 the (I guess correct) result is: 113.40
    1 point
  7. Subz

    Math based script

    Maybe something like: #include <GUIConstantsEx.au3> Global $g_iInput, $g_idInput, $g_idOutput _Example() Func _Example() GUICreate("Calculate", 110, 90) $g_idInput = GUICtrlCreateInput("", 5, 5, 100, 20) $g_idOutput = GUICtrlCreateInput("", 5, 30, 100, 20) GUICtrlSetState($g_idOutput, $GUI_DISABLE) Local $idOutput = GUICtrlCreateButton("Copy to Clipboard", 5, 55, 100, 30) GUISetState() AdlibRegister("_Calculate") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idOutput ClipPut(GUICtrlRead($g_idOutput)) EndSwitch WEnd EndFunc Func _Calculate() Local $iInput = Int(GUICtrlRead($g_idInput)) If $iInput = $g_iInput Then Return Local $sCalculate = Round(($iInput/(1-5.5/100))*(1+20/100), 2) GUICtrlSetData($g_idOutput, $sCalculate) $g_iInput = $iInput EndFunc
    1 point
  8. Any mayo or ketchup with that? 1&2: This comes from SciTE and is part of the standard SciTE package. >Exit code: 0    Time: 31.67 The other suggestion is part of AutoIt3Wrapper and simple to change.
    1 point
  9. Yes. The same is true for Chrome according to the details posted by @Decibel.
    1 point
  10. This project implements data display functions based on _ArrayDisplay and _ArrayDisplayEx (virtual listview). Four functions are planned and maybe there’ll also come a fifth function. First post contains documentation common to all functions. In order to avoid first post being too long, posts 2 - 5 are reserved for documentation that's specific to the four planned functions. The first two functions _ArrayDisplayEx and CSVfileDisplay are presented below. The other functions will be presented in the coming weeks. Data display functions: _ArrayDisplayEx - Displays a 1D or 2D array in a virtual ListView CSVfileDisplay - Displays a CSV file in a virtual ListView _SQLite_Display - Displays data from a table, view or SELECT statement in a virtual ListView SafeArrayDisplay - Displays a 1D/2D safearray of variants (equivalent to an AutoIt array) in a virtual ListView The functions are mainly intended for large amounts of data with a large number of rows. The GUI and listview are implemented for this purpose. Thus, the left column in the listview is a row-number column. This is convenient when there are many rows. Through an input control at bottom of the GUI, you can focus on a specific row. When there are many rows it's difficult to scroll to a specific row with the mouse. The primary purpose of the functions is testing and debugging. Secondary to display data for end users. Therefore, features that are directly available in the function definition through parameters and flags are reduced to a minimum, while additional features that are especially interesting for end users must be specified in a single parameter which is the last parameter in the function definition. The definition of _ArrayDisplayEx looks like this: ; Displays a 1D or 2D array in a virtual ListView Func _ArrayDisplayEx( _ $aArray, _ ; 1D/2D array eg. StringSplit("Mo,Tu,We,Th,Fr,Sa,Su", ",") $sTitle = "", _ ; GUI title bar text, default title is set to "ArrayDisplayEx" $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0000, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs All functions uses a virtual listview to display data. A normal listview has two main features: Data storage and data display. A virtual listview has only one main feature: Data display. Data is stored in a data source outside the listview. Because data does not have to be inserted into the rows of a virtual listview, the listview shows up instantly. The number of rows is limited only to the data source. Data display in the virtual listview is implemented through subclassing. This means that the code will not interfere with WM_NOTIFY message handlers in your own code. And because there are a lot of messages involved in updating the cell texts in a virtual listview, the subclassing technique is also performance optimizing. The first parameter in the function definition is the data source. The data source is the main difference between the display functions. Depending on the function more than one parameter can be used to support the data source. After one or more data source parameters follows title, header and flag parameters. The last parameter is an array of additional features. It's discussed in a section below. These four parameters are common to all display functions. Flag values ; $iFlags values ; Add required values together ; 0x0000 => Left aligned text ; 0x0002 => Right aligned text ; 0x0004 => Centered text ; 0x0008 => Verbose mode ; 0x0010 => Half-height ListView ; 0x0020 => No grid lines in ListView ; 0x0040 => No bottom controls Not all flags can be used in all functions. See documentation for the actual function just below the function definition. Embedded controls (2018-04-14) Instead of creating the listview in a stand-alone main GUI, it's possible to create the listview in a child window of a user GUI, thereby creating an embedded control. A separate function is used to create the embedded control. This is the definition for _ArrayDisplayCtrl (the embedded control corresponding to _ArrayDisplayEx): ; Displays a 1D or 2D array in a virtual ListView as an embedded GUI control Func _ArrayDisplayCtrl( $hUserGui, $x, $y, $w, $h, _ $aArray, _ ; 1D/2D array eg. StringSplit("Mo,Tu,We,Th,Fr,Sa,Su", ",") $sTitle = "", _ ; GUI title bar text, default title is set to "ArrayDisplayEx" ; <<<< Not used >>>> $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0000, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs The embedded control is created with the code in Common\4)CreateAutoItGUICtrl.au3. Handle messages Messages from the embedded control must be identified in the user GUI. For this purpose, _ArrayDisplayCtrl (the embedded control corresponding to _ArrayDisplayEx) returns an array of information. The information and usage of the information is shown here through a part of the code in Examples\ArrayDisplayCtrl\1) Simple.au3: ; Create GUI Local $hGui = GUICreate( "Simple", 820, 660 ) ; Create ArrayDisplay control Local $aDisplay = _ArrayDisplayCtrl( $hGui, 10, 10, 800, 600, $aArray ) ; Get info about ArrayDisplay control Local $hDisplay = $aDisplay[0] ; Elem 0: Child window handle to show and resize window Local $idDisplay_FirstCtrl = $aDisplay[1] ; Elem 1: First controlID in child window (ListView control) Local $idDisplay_LastCtrl = $aDisplay[2] ; Elem 2: Last controlID in child window (last bottom ctrl) Local $hDisplay_MsgHandler = $aDisplay[3] ; Elem 3: Message handler for AutoIt events in child window Local $iDisplay_MsgHandlerIdx = $aDisplay[4] ; Elem 4: Message handler index GUISetState() GUISetState( @SW_SHOWNOACTIVATE, $hDisplay ) ; Show ArrayDisplay control Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg ; Handle messages for AutoIt events in ArrayDisplay control Case $idDisplay_FirstCtrl To $idDisplay_LastCtrl $hDisplay_MsgHandler( $iMsg, $iDisplay_MsgHandlerIdx ) You can use a shorter notation this way: ; Create GUI Local $hGui = GUICreate( "Simple", 820, 660 ) ; Create ArrayDisplay control Local $aDisplay = _ArrayDisplayCtrl( $hGui, 10, 10, 800, 600, $aArray ) GUISetState() GUISetState( @SW_SHOWNOACTIVATE, $aDisplay[0] ) ; Show ArrayDisplay control Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg ; Handle messages for AutoIt events in ArrayDisplay control Case $aDisplay[1] To $aDisplay[2] $aDisplay[3]( $iMsg, $aDisplay[4] ) As can be seen from the two Case statements, it's only tested if a message corresponds to a control in the range from the first controlId to the last controlId. A prerequisite for this to work is that the controlIds is an uninterrupted continuous sequence of integers. This is tested at the bottom of Common\4)CreateAutoItGUICtrl.au3. If the requirement is not met, @error is set to 5. The issue is demonstrated in an example: "a) Demonstration of @error = 5.au3". The message handler function $hDisplay_MsgHandler or $aDisplay[3] is implemented in Functions\ArrayDisplayEx\Internal\9)MessageLoopCtrl.au3 (for _ArrayDisplayCtrl). What happens if you forget to implement message handler code for the embedded control in your user GUI? Nothing. The embedded control will work anyway. However, you do not get any response to events that generate messages in the embedded control. Cleanup and release memory If the script with the embedded display function exits when the GUI closes, you do not have to worry about cleanup. It's done automatically by AutoIt. However, if you want to run more code after the GUI is closed, it may be useful to clean up and release memory used by the display function. Especially if it's a large data source. To release memory, take into account 3 types of variables: Variables created in your own script Variables passed to display function and stored as globals Variables passed to display function and stored as statics In order to release memory used by the last two types of variables, a new element has been added to the array returned from the display function (illustrated for _ArrayDisplayCtrl): $aDisplay[4] = $iIdx: Index in global array $aDataDisplay_Info (existing element) $aDisplay[5] = ArrayDisplay_Cleanup(): Performs cleanup, takes $iIdx and $hNotifyFunc as input parameters ArrayDisplay_Cleanup() that performs cleanup and releases memory is coded this way: ; Cleanup and release memory Func ArrayDisplay_Cleanup( $iIdx ) ; Remove $WM_COMMAND and $WM_SYSCOMMAND event handler If $aDataDisplay_Info[$iIdx][15] = 3 Then _ ; Remove WM_COMMAND, WM_SYSCOMMAND message handler (DataDisplayMult_MsgHandler) used to handle events from multiple concurrent and responsive GUIs DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aDataDisplay_Info[$iIdx][21], "ptr", $aDataDisplay_Info[$iIdx][40], "uint_ptr", $iIdx ) ; WM_COMMAND, WM_SYSCOMMAND ; Remove $WM_COMMAND event handler If $aDataDisplay_Info[$iIdx][15] = 2 Then _ ; Remove WM_COMMAND message handler (DataDisplayCtrl_WM_COMMAND) used to handle events from embedded GUI controls DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aDataDisplay_Info[$iIdx][21], "ptr", $aDataDisplay_Info[$iIdx][18], "uint_ptr", $iIdx ) ; WM_COMMAND ; Remove WM_NOTIFY message handler used to fill the virtual listview DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aDataDisplay_Info[$iIdx][21], "ptr", $aDataDisplay_Info[$iIdx][2], "uint_ptr", $iIdx ) ; WM_NOTIFY ; Delete ListView header background color resources If IsArray( $aDataDisplay_Info[$iIdx][16] ) Then Local $aTmp = $aDataDisplay_Info[$iIdx][16] ; [ $hListView, $pHeaderColor, $oHdr_Colors_Dict ] ; Remove WM_NOTIFY message handler (DataDisplay_HeaderColor) used to draw colors in listview header items DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aTmp[0], "ptr", $aTmp[1], "uint_ptr", 9999 ) For $hBrush In $aTmp[2].Items() DllCall( "gdi32.dll", "bool", "DeleteObject", "handle", $hBrush ) ; _WinAPI_DeleteObject Next $aDataDisplay_Info[$iIdx][16] = 0 EndIf ; Delete AutoIt GUI If $aDataDisplay_Info[$iIdx][15] <> 2 Then _ GUIDelete( $aDataDisplay_Info[$iIdx][21] ) ; Release memory $aDataDisplay_Info[$iIdx][0] = 0 $aDataDisplay_Info[$iIdx][3] = 0 $aDataDisplay_Info[$iIdx][4] = 0 $aDataDisplay_Info[$iIdx][5] = 0 $aDataDisplay_Info[$iIdx][6] = 0 ; Release local static memory $aDataDisplay_Info[$iIdx][1]( 0, 0x004E, 0, 0, $iIdx, 0 ) ; 0x004E = $WM_NOTIFY If $aDataDisplay_Info[$iIdx][15] = 2 Then DataDisplayCtrl_MsgHandler( 99999, $iIdx ) $aDataDisplay_Info[$iIdx][10] = 0 EndIf ; Release row in $aDataDisplay_Info $aDataDisplay_Info[$iIdx][20] = 0 ; $iIdx EndFunc And it's called this way: ; Cleanup and release memory $aDisplay[5]( $aDisplay[4] ) A new example, "b) Cleanup and release memory.au3", demonstrates the technique. Embedded control functions: _ArrayDisplayCtrl - Displays a 1D or 2D array in a virtual ListView as an embedded GUI control CSVfileDisplayCtrl - Displays a CSV file in a virtual ListView as an embedded GUI control _SQLite_DisplayCtrl - Displays data from a table, view or SELECT statement in a virtual ListView as an embedded GUI control SafeArrayDisplayCtrl - Displays a 1D/2D safearray of variants (equivalent to an AutoIt array) in a virtual ListView as an embedded GUI control Four new folders are created under Examples\ with similar examples. Multiple GUIs (2018-05-21) Both in the official _ArrayDisplay and in the data display functions here, it's possible to open multiple GUIs at the same time via user supplied functions and "Run User Func" buttons. An unfortunate consequence of this technique is that the message loop in the last created GUI blocks the message loop in a previously created GUI. This means that only the last created GUI is responsive to AutoIt messages eg. mouse clicks (all listviews are, however, fully functional because they are not depending on any AutoIt messages). As demonstrated in Unblocking a Blocked Message Handler and in Way to close AU3 Script with a button? it's possible to detect Windows messages (not AutoIt messages) in such blocked message loops by using window subclassing or GUIRegisterMsg functions. In case of _ArrayDisplay and the data display functions, it's enough to detect $WM_COMMAND messages for button click events and $WM_SYSCOMMAND messages for window close events. In the data display functions $WM_COMMAND messages are also used to detect input control events and keyboard accelerator events. By using these methods, four new data display functions are implemented with a new message handler, so that multiple simultaneous open GUIs are all responsive: _ArrayDisplayMult - Displays a 1D or 2D array in a virtual ListView, support for multiple GUIs CSVfileDisplayMult - Displays a CSV file in a virtual ListView, support for multiple GUIs _SQLite_DisplayMult - Displays data from a table, view or SELECT statement in a virtual ListView, support for multiple GUIs SafeArrayDisplayMult - Displays a 1D/2D safearray of variants (equivalent to an AutoIt array) in a virtual ListView, support for multiple GUIs Four new folders are created under Examples\ with similar examples. Note that at the top of Common\0)GlobalArray.au3, the number of simultaneous open data display GUIs is limited to 10: $aDataDisplay_Info[0][21] = 10 ; Max number of data display GUIs You can change the number to the value you want. Additional features Only basic functionality used for testing and debugging is implemented directly in the display functions. It's possible to use a wide range of additional features that are especially interesting when the display functions are used to display data for end users. Usually only a few features are used at a time. To avoid adding a lot of parameters to each display function of which only a few are used, additional features must be specified through a single $aFeatures parameter, which is the last parameter in the function definition. Also in order to avoid adding a lot of extra code to the functions that are rarely used, most of the features are implemented in separate include files. These files must be included in order to use the features. $aFeatures parameter is checked for errors under function initializing. In most cases, an error just means that the feature is skipped. Only in case of serious mistakes eg. a missing include file the function will return with an error code in @error. If verbose mode is turned on ($iFlags = 8), the error will be displayed in a MsgBox. The following additional features can be used: Features implemented through Common\ files (always usable) End user features: "ColAlign" - Column alignment "ColWidthMin" - Min. column width "ColWidthMax" - Max. column width "BackColor" - Listview background color "HdrColors" - Listview header background colors "UserFunc" - User supplied function Features implemented through include files End user features: Include file: "ColFormats" - Column text formats <Display function>_ColumnFormats.au3 "ColColors" - Column background colors <Display function>_ColumnColors.au3 "SortRows" - Sort rows in data source by index <Display function>_SortFuncs.au3 "SortCols" - Sort columns in data source by index <Display function>_SortFuncs.au3 "SortByCols" - Sort rows by multiple columns <Display function>_SortFuncs.au3 Debugging features: "DataTypes" - Data types info <Display function>_DataTypesInfo.au3 Not all features can be used in all functions. See documentation for the actual function just below the function definition. See HelpFiles\DisplayFeatures.txt in zip-file for documentation of each feature. See Examples\ for examples. Missing features Compared to the official _ArrayDisplay and the old version of _ArrayDisplayEx some features are omitted in the new functions. It's not possible to specify a data range to only display a small section of data. But rows and columns can be sorted by row and column indices which can replace the range feature. This is demonstrated in examples. Data copying that could be performed through two GUI buttons is omitted. Because the listviews are virtual listviews, potentially millions of cells can be selected and copied. Copying such large amounts of data can take a long time. Since data may in any case be copied directly from the data source, the copying functionality is omitted to avoid long-term copying. It's also not possible to change rows and columns. No transpose functionality. Function examples The zip-file is organized this way: DataDisplay\ - Top folder Common\ - Code common to all functions Examples\ - Examples for each function Functions\ - Implements the functions HelpFiles\ - Docu of additional features Resources\ - Resources used in examples Common\ and Functions\ contains all the code used to implement the display functions. Common\ is used to implement functionality and features. Functions\ is further divided into subfolders for each display function. The subfolders contains WM_NOTIFY message handlers that handles LVN_GETDISPINFOW, LVN_ODCACHEHINT, and NM_CUSTOMDRAW notifications, and displays data in the virtual list view. These functions are critical in terms of performance. Examples\ is also divided into subfolders for each display function. For each function the features are demonstrated one by one. If more parameters are used in relation to the data source, the utilization of the parameters is demonstrated in "Examples\<Display function>\0) Data source\". For most examples the data source is created on the fly. For this purpose, a few small UDFs are used. These UDFs are stored in Resources\. Using functions To use a display function in your own project copy the entire DataDisplay\ to the project folder. You can rename DataDisplay to Display or similar if you want a shorter name. You can delete Examples\, HelpFiles\ and Resources\. You can also delete display functions in Functions\ that you're not using. Then include the function you need in your code. Usage of the display functions is demonstrated in "Examples\<Display function>\3) Using function\". Here the code in "Examples\ArrayDisplayEx\3) Using function\My Project\Script1.au3": #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "Display\Functions\ArrayDisplayEx\ArrayDisplayEx.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $iRows = 10000, $iCols = 10 Local $aArray[$iRows][$iCols] For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $aArray[$i][$j] = $i & "/" & $j Next Next _ArrayDisplayEx( $aArray ) EndFunc And in "Examples\ArrayDisplayEx\3) Using function\My Project\Script2.au3": #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "Display\Display.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() Local $iRows = 10000, $iCols = 10 Local $aArray[$iRows][$iCols] For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $aArray[$i][$j] = $i & "/" & $j Next Next _ArrayDisplayEx( $aArray, "", "", 0, GetDisplayFeatures() ) EndFunc Display\Display.au3: #include-once #include "Functions\ArrayDisplayEx\ArrayDisplayEx.au3" #include "Functions\ArrayDisplayEx\ArrayDisplayEx_ColumnColors.au3" Func GetDisplayFeatures() ; ArrayDisplayEx features Local $aAlignment = [ [ -1, "R" ], [ 0, "C" ], [ 1, "L" ] ] Local $aColColors = [ [ 1, 0xCCFFCC ], [ 3, 0xFFFFCC ] ] Local $aFeatures = [ [ "ColAlign", $aAlignment ], _ [ "ColColors", $aColColors ] ] Return $aFeatures EndFunc v3.3.10.2 If you're using this UDF in AutoIt v3.3.10.2 you should be aware of an Au3Check issue as described in this post. Zip-file The organization of the zip-file is described in the section above. You need AutoIt 3.3.10 or later. Tested on Windows 10, Windows 7 and Windows XP. Comments are welcome. Let me know if there are any issues. DataDisplay.7z
    1 point
×
×
  • Create New...