Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/03/2017 in all areas

  1. Obsolete. Use Data display functions based on virtual listviews. I'm working on some code related to virtual ListViews. In this regard, I need to be able to show the contents of large arrays with the same ease as _ArrayDisplay can show the contents of smaller arrays. The arrays have to be shown as fast as possible. _ArrayDisplayEx is the answer. The most fundamental difference between _ArrayDisplayEx based on a virtual ListView and the official version of _ArrayDisplay is, that a virtual ListView is depending on WM_NOTIFY messages and needs a function to handle these messages. Advantages and disadvantages of _ArrayDisplayEx: Advantages No limitation on the number of rows as the ListView can display. The array itself is the limitation. The ListView shows up immediately. Because a virtual ListView is fed with data directly from the array, no time is spent on inserting rows in the ListView. Disadvantages _ArrayDisplayEx is depending on WM_NOTIFY message handlers registered with GUIRegisterMsg. Because you can't use two different WM_NOTIFY message handlers registered with GUIRegisterMsg at the same time, this makes it difficult to use a WM_NOTIFY message handler in your own code. This also makes it impossible to display two _ArrayDisplayEx windows side by side at the same time. Significantly more work is carried out by _ArrayDisplayEx than _ArrayDisplay. _ArrayDisplayEx must constantly feed the ListView with data for example when you scroll up or down. This is done in the WM_NOTIFY message handlers. Column widths are calculated based on the rows at the first page in the list view. This will not necessarily lead to correct column widths for all rows. Don't use _ArrayDisplayEx if the array contains less than 10,000 rows. The GUI Most of the GUI code is copied directly from the official version of _ArrayDisplay. Credit goes to ; #FUNCTION# =================================================================== ; Author ........: randallc, Ultima ; Modified.......: Gary Frost (gafrost), Ultima, Zedna, jpm, Melba23, AZJIO, UEZ ; ============================================================================== and especially Melba23, who has done most of the coding in the recent versions of the function. Changes compared to _ArrayDisplay (3.3.14) Changes in functionality and changes for parameters in function definition. A new "Goto row" control is added to the left of "Copy" buttons. If there are many rows in the array, it can be difficult to navigate to a specific row with the scroll bar. It's much easier to enter the row number. The dimensions label below the ListView that shows array dimensions is always shown. If a user function is specified the "Run User Func" button is always shown whether "Goto row" control or "Copy" buttons are shown or not. "Run User Func" button appears to the right of the dimensions label. $iFlags parameter (new/modified in bold): 0 = Left aligned text (default) 1 = Transposes the array 2 = Right aligned text 4 = Centered text 8 = Verbose: MsgBox on error, splash screen on lengthy commands 16 = No "Copy" buttons displayed (page 2 in Examples.au3) 32 = No "Exit Script" button displayed (page 2 in Examples.au3) 64 = No "Goto row" control displayed (page 2 in Examples.au3) 128 = No "Row" column displayed in ListView (header / page 5) 256 = Pass array and selection to user function (page 2) 512 = Show types of special data (page 3) 1024 = Half-height ListView (page 5) Flag values to hide controls and "Row" column. The meaning of the values 16, 32 and 64 is changed compared to the official version. 128 is a new value. When I specify a user function, it's rare that I need the array and selection. The default in _ArrayDisplayEx is not to pass array and selection to user function. If the array contains 100,000 rows the calculation of selected rows takes time. Set $iFlags = 256 to pass array and selection to user function. When array and selection is passed to user function ($iFlags = 256), "Run User Func" button works in the same way as "Copy" buttons according to the selection. If no rows are selected, all rows are passed to the user function. Else selected rows are passed to the function. If only rows 5 - 17 are visible in the ListView ($sArrayRange = "5:17"), you might only want to execute the user function for rows 5 - 17. For this purpose _ArrayDisplayEx settings can be passed to user function. Call _ArrayDisplayEx_LocalStorage (see below) to get the settings. Set $iFlags = 512 to show types of special data. Special data includes arrays, functions, objects and structures (DllStructCreate). When the flag is set, the corresponding cells in the ListView are shown with the following text strings: {Array}, {Function}, {Object} and {Struct}. Without this flag data is shown as empty cells. The flag is not set as default. For large arrays the control of special data types is time consuming. Because a lot of work is carried out in WM_NOTIFY functions to feed the ListView with data, you can set $iFlags = 1024 to use a half-height ListView. Then the ListView only have to be fed with half as many data. When you drag the scrollbar with the mouse, it's easier for the scrollbar to follow the mouse. A new parameter $hWM_NOTIFY_Function = 0 is added as the last parameter. Because _ArrayDisplayEx is based on a virtual ListView it's depending on WM_NOTIFY messages and functions. If you are using a WM_NOTIFY function in your own script, you can use the $hWM_NOTIFY_Function parameter to restore your function when the code returns from _ArrayDisplayEx. See page 4 in Examples.au3. Optimized for speed In this version the code is optimized for speed and nothing else. This means that as many control statements as possible are calculated before the repetitive and fast call of WM_NOTIFY functions in response to LVN_GETDISPINFO notifications to feed the ListView with data. The disadvantage is, that there is a fairly large number of WM_NOTIFY functions. The reason for the size of the script. Avoiding global variables To avoid globals a function _ArrayDisplayEx_LocalStorage and static locals are used to transfer information from _ArrayDisplayEx to WM_NOTIFY functions. _ArrayDisplayEx_LocalStorage can be called e.g. in a user function to get the same information. See page 2 in Examples.au3. Because of this usage of _ArrayDisplayEx_LocalStorage the keywords Const and ByRef can't be used in definition of _ArrayDisplayEx. Since _ArrayDisplayEx does not change the array this is not a problem. On the other hand it means that you can call the function in this way: _ArrayDisplayEx( StringSplit( "string", "delimiters" ) ) Examples Examples.au3 contains a bunch of small examples: Page 1 demonstrates the usage of the $sArrayRange parameter Page 2 shows the changes in relation to controls and user function Page 3 demonstrates how to show types of special data Page 4 shows how to restore a WM_NOTIFY function Page 5 is a summary of parameters and flags For the examples at page 1 (only page 1) you can click the "Run User Func" button to compare with the official version. To avoid influence of the WM_NOTIFY function (which would decrease performance significantly) _ArrayDisplay is executed in it's own process. The array is transferred to the new process through an object registered with AutoItObject (you can find a step-by-step demonstration of the technique here, and you can find a description in the AutoItObject thread). Run this code to test _ArrayDisplayEx with a large array: #include "ArrayDisplayEx.au3" ; One million rows, ten columns Global $iRows = 1000000, $iCols = 10 Global $aArray[$iRows][$iCols] ; This takes some seconds ; It'll use some memory For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $aArray[$i][$j] = $i & "/" & $j Next Next ConsoleWrite( "Array done ..." & @CRLF ) _ArrayDisplayEx( $aArray, "", "", 16, "", "", Default, 0xCCFFFF ) ; 16 => remove "Copy" buttons ; 0xCCFFFF => alternating row color Notice the "Array done ..." message in the console. The delay from the message shows up till you see the rows in the ListView, is the time it takes to create the GUI. Zip The zip contains four files: ArrayDisplayEx.au3 - contains the _ArrayDisplayEx UDF Examples.au3 - a bunch of small examples spread over five pages Examples\AutoItObject.au3 by the AutoItObject team - used in examples at page 1 Examples\Original.au3 - used in examples at page 1 You need AutoIt 3.3.10 or later. Tested on Windows 7 64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. Updated zip at bottom of post #4.
    1 point
  2. This works as well ... #include <IE.au3> Local $oIE = _IECreate ("https://it.shpock.com/my/signup/") Local $oForm = _IEFormGetCollection($oIE, 0) Local $username = _IEFormElementGetCollection ($oForm, 1) Local $password = _IEFormElementGetCollection ($oForm, 2) _IEFormElementSetValue ($username, "myname") _IEFormElementSetValue ($password, "myPassword") _IEFormSubmit($oForm)
    1 point
  3. At the moment there is no way to access .NET libraries natively... 2 Options left : 1. If this is a custom developed .NET libr. make it COM Visible as JohnOne indicated. 2. If you are looking for accessing .NET Class Libraries, you can use the PowerShell COM library as middleware... See my signature. I am looking into how we could still achieve this to access it natively. But some highly skilled forum members has already let me know that this will not be an easy task.... It could be achieved by using the ObjCreateInterface and reading a lot on MSDN ... It is NOW POSSIBLE TO ACCESS .NET Classes / THIRD PARTY ASSEMBLIES / POWERSHELL Cmdlets and MODULES See here on 'how to' Examples : All members are welcome to contribute and help in any way they can ... Rgds ptrex
    1 point
  4. I don't believe c# libraries have classic entry points like unmanaged dlls, so dllcall will not work. I think I recall you have to make your dll com visible and use as an object, you should search it, there is something on the forum about it. EDIT: .NET CLR is nowadays possible.
    1 point
  5. declare $larger = true before the loop
    1 point
  6. Set $larger = True outside of the loop.
    1 point
  7. orbs

    Retrieve Value from MT4

    @Frankie, welcome to AutoIt and to the forum. be aware that AutoIt users do not necessarily know what MT4 is, or any of the other terms you mention. you are pretty much leaving us guessing what program you are trying to interact with, which is a key question here. so: 1) what is the program you are trying to interact with? 2) does this program have a custom action you can define when a dataset matches some condition? 3) is the dataset present in any form other than a chart (e.g. in a file)? 4) is this real-time, or are you analyzing the dataset in retrospect? help us help you, give us something to work with.
    1 point
  8. jchd

    romaSQL

    I beg to strongly differ. While this may seem simple to use for SQL newbies, I doubt you can create "serious" SQL queries this way, I mean in real-world applications. Simple queries don't need any of these glue functions and routine non-trivial queries become an horrible mess almost impossible to understand. Further, it tends to teach newcomers an extremely limited grammar/dialect, instead of exposing the full power of SQL. In my book I call this totally counter-productive and utterly deceptive in the long run. For instance, imagining you have all Laravel wrapped as AutoIt functions, how would the following (still simple and pretty readable) query translate? create table T(date integer,test char); insert into T values (1,'clim'),(3,'clim'),(7,'amb'),(10,'amb'),(12,'xxx'), (13,'clim'),(15,'clim'),(20,'clim'),(22,'amb'),(25,'amb'); select min(date) as fromdate, max(date) as enddate, test from (--get closest preceeding different key select t.*, max(t2.date) as key2 from t left join t t2 on t2.date < t.date and t2.test != t.test group by t.date ) group by key2 Nom think of 4 or 8 complex subqueries on 7-table joins... Laziness never pays long term!
    1 point
  9. What game? CoD, BF, CS?
    1 point
  10. System image lists _WinAPI_ShellGetImageList (based on Shell_GetImageLists) in WinAPIShPath.au3 creates system image lists for small (16x16) and large (32x32) icons. SHGetImageList creates system image lists for small, syssmall (usually 16x16), large, extra large (48x48) and jumbo (256x256) icons. Jumbo icons are supported on Vista+. (On a Windows system, no more than these four system image lists exists (disregarding the syssmall list). That's why every decent icon editor by default should be able to create icons of the corresponding sizes.) On XP you can scale up extra large icons to 64x64, 96x96, 128x128, 160x160, 192x192, 224x224 and 256x256 pixel icons to create image lists (not system image lists) with these sizes. On Vista+ you can scale down jumbo icons to create image lists with the same sizes. GetSystemImageList in SystemImageLists.au3 is an implementation of SHGetImageList. SHGetFileInfo can be used to insert icons for files and folders into the system image lists. To get the proper icons, it's important to call SHGetFileInfo with the full paths for the files and folders represented as PIDLs. _WinAPI_ShellGetFileInfo in WinAPIShellEx.au3 is an implementation of SHGetFileInfo. But this function does not support PIDLs. GetSystemImageListIcon is based on code for SHGetFileInfo that supports PIDLs. GetSystemImageListIcon inserts an icon into the system image lists, and returns the index of the icon. If the icon already exists, it just returns the index. If more system image lists are created (with different sizes), a single call of GetSystemImageListIcon (SHGetFileInfo) will insert the icon into all lists. If you have created copies of the system image lists with other sizes, you have to manually create icons with the proper sizes, and insert into these image lists. State information SHGetFileInfo and GetSystemImageListIcon can extract state information for files and folders. GetSystemImageListIcon can extract ghosted, open folder and compressed states, and information for an overlay icon. File and folder states are demonstrated in the second example below. If state information includes ghosted or compressed flags, GetSystemImageListIcon returns an array with icon index in first row and state flags (ghosted or compressed) in second row. Note that state information not directly have anything to do with system image lists. But icon images in the lists are used to visually show file and folder states e.g. in a listview. SystemImageLists UDF SystemImageLists.au3 is a small (120 lines) UDF, which contains the two functions GetSystemImageList and GetSystemImageListIcon. The UDF creates five global constant variables $SHIL_LARGE, $SHIL_SMALL, $SHIL_EXTRALARGE, $SHIL_SYSSMALL and $SHIL_JUMBO with values 0 - 4. Examples First example Two examples are included in the zip. The first example is pretty much the same as the example for _WinAPI_ShellGetImageList in the help file. This example fills a system image list with (hundreds of) icons, and draw the icons into a single big picture control. In the example here, a picture control is created for each icon, and the GUI window is supplied with a vertical scroll bar. The number of icons is limited to 100. There are five versions of the example. One version for each of the five system image lists. The version with jumbo icons can be run on Vista+. Second example The second example shows how to use system image lists in a listview. The starting point are empty system image lists, which gradually are filled with icons of files and folders, as you drop on the listview. Icons which represents a file or folder, are supplied with the name of the file or folder. Icons which represents an image in a list, are supplied with a name that shows the index. The example shows how to display different states of the files and folders, and it shows how to copy and resize the image lists. This is a picture of the second example with a few extra large icons. You see a ghosted folder, a folder with an overlay icon, four compressed and one uncompressed item. The toolbar is hot-track enabled. To prevent flicker in the listview, resizing is done with this code by KaFu and Siao. The menu items of the Icons button fills the listview with icons of the Desktop, Computer, Control Panel, Documents and the System image list. For the first four menu items, icons are added to existing icons. For the last menu item (System image list) existing icons are deleted, before images are filled into the listview. The state items of the States button can be applied to icons which represents files or folders (icons with a name). Not icons which represents images in the system image lists (icons with a number). In absence of any of the former icons, the state items have no effect. The latter icons are deleted, when a state is set or unset. The menu items of the View button sets the size of the icons. Note that overlay icons are not drawn for sizes, which does not represent a system image list. The Delete button deletes the icons in the listview. The example shows how to copy and resize icons to 64x64, 96x96, 128x128, 160x160, 192x192, 224x224 and 256x256 pixels, and create image lists with these sizes. When icons are scaled to other sizes, it's very important to use proper functions to do the scaling. If not you can easily get icons of poor quality. On XP the extra large (48x48) icons are scaled up to larger sizes. On Vista+ the jumbo (256x256) icons are scaled down to smaller sizes. Here the scaling is done with internal functionality of the image lists. Zip file The size of the zip is caused by 4 icon files which includes 256x256 pixel images. System Image Lists.7z Testet on XP 32 bit and Win 7 32/64 bit.
    1 point
  11. Internal functions: __FuncName() AutoIt UDF functions: _FuncName() Your functions: FuncName() This is how it should be, so as to easily distinguish which are your functions and AutoIt's.
    1 point
  12. The way that has worked for me is totally using Enum and Arrays. The only "problem" with my method is that you have to declare the enum values globally (which for some reason a few don't want to do). I've even begun to use them to help me describe built-in functions. Example: Enum $fontFace, $fontWeight, $fontSize, _ $fontMax Global $font[$fontMax] Example() Func Example() $font[$fontFace] = "Tahoma" $font[$fontWeight] = "Bold" $font[$fontSize] = 8.5 MsgBox(0, "", GetFontWeight()) EndFunc Func GetFontWeight() Return $font[$fontWeight] EndFunc Example with built-in function: Enum $posLeft, $posTop, $posWidth, $posHeight MsgBox(0,"",GetPosition("Untitled - Notepad")[$posLeft]) Func GetPosition($title) Return WinGetPos($title) EndFunc
    1 point
  13. Declaring Global variables in a Function is never a good idea: #include <MsgBoxConstants.au3> ; Calling Example() first will initialise the Global variable $vVariableThatIsGlobal and therefore calling SomeFunc() won't return an error. ; Now look at Example 2. Example() Func Example() ; Declaring a variable in a function can cause serious problems, hence why all Global variables should be declared at the top of a script. Global $vVariableThatIsGlobal = 'This is a variable that has ''File Scope'' aka Global.' SomeFunc() EndFunc ;==>Example Func SomeFunc() MsgBox($MB_SYSTEMMODAL, '', $vVariableThatIsGlobal) ; As the variable was initialised this will not return an error. EndFunc ;==>SomeFuncExample 2: #include <MsgBoxConstants.au3> ; Calling SomeFunc() first will bypass the Global variable $vVariableThatIsGlobal being initialised and therefore AutoIt has no idea of what data the variable ; $vVariableThatIsGlobal contains. SomeFunc() Func Example() ; Declaring a variable in a function can cause serious problems, hence why all Global variables should be declared at the top of a script. Global $vVariableThatIsGlobal = 'This is a variable that has ''File Scope'' aka Global.' SomeFunc() EndFunc ;==>Example Func SomeFunc() MsgBox($MB_SYSTEMMODAL, '', $vVariableThatIsGlobal) ; As the variable wasn't initialised this will return an error of "variable used without being declared." EndFunc ;==>SomeFunc Question: What if I want to retain variable data once returned from a Function and only use that variable in that particular Function, can't it be declared as Global then? Answer: Static variables. #include <MsgBoxConstants.au3> Example() Func Example() SomeFunc() ; This will display a message box of 1, 1. SomeFunc() ; This will display a message box of 1, 2. SomeFunc() ; This will display a message box of 1, 3. EndFunc ;==>Example Func SomeFunc() ; This initialises a Static variable in Local scope. When a variable is declared just in Local scope (within a Function,) ; it's destroyed when the Function ends/returns. This isn't the case for a Static variable. The variable can't be ; accessed from anywhere else in the script apart from the Function it was declared in. Local Static $vVariableThatIsStatic = 0 Local $vVariableThatIsLocal = 0 $vVariableThatIsLocal += 1 ; This will always be 1 as it was destroyed once returned from SomeFunc. $vVariableThatIsStatic += 1 ; This will increase by 1. MsgBox($MB_SYSTEMMODAL, $vVariableThatIsLocal, $vVariableThatIsStatic) EndFunc ;==>SomeFunc
    1 point
×
×
  • Create New...