Leaderboard
Popular Content
Showing content with the highest reputation on 03/28/2015 in Posts
-
Virtual listviews are lightning fast and can handle millions of rows. Virtual listviews are of interest when you have to insert more than 10,000 rows. When there are less than 10,000 rows, the standard listviews are sufficiently rapid. See the section "Using standard listviews" below. In a virtual listview data are not stored directly in the listview. Data are stored in an array, a structure (DllStructCreate), a flat fixed-length record file, a database or similar. The listview only contains the rows which are visible depending on the height of the listview. See About List-View Controls in the MicroSoft documentation for more information. An array or a structure can be used for listviews with 10,000 - 100,000 rows. If there are more than 100,000 rows a fixed-length record file or a database seems to be the best solution, because they have low impact on memory usage. But you get nothing for free. The costs is that a part of the built-in features does not work, and you will have to implement these features yourself. Because data isn't stored in the listview the Set- and Get-functions to manipulate data doesn't work. You have to manipulate the data source directly. And sorting is not supported at all by virtual listviews. If you need sorting, a database seems to be the best solution in all cases, because sorting can be handled by the database. Below you'll find the following sections: Data stored in arrays Data stored in databases Data stored in fixed-length record files Sorting rows in a virtual listview $LVN_ODFINDITEM notifications Using standard listviews Updates Zip file Examples The next two sections shows how to use virtual listviews, when data are stored in arrays or databases. In first section data are stored in 3 arrays with 10,000/50,000/100,000 rows and 10 columns. In second section data are stored in 3 databases with 100,000/1,000,000/10,000,000 rows and 10 columns. Data stored in arrays For a virtual listview rows are displayed with $LVN_GETDISPINFO notifications and the $tagNMLVDISPINFO structure. Code for $LVN_GETDISPINFO messages in the WM_NOTIFY function can be implemented in this manner: Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $sItem = $aItems[DllStructGetData($tNMLVDISPINFO,"Item")][DllStructGetData($tNMLVDISPINFO,"SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) EndIf Run LvVirtArray.au3. It takes some time to create the arrays. But when the arrays are created, switching from one array to another (which means updating the listview) is instantaneous. Data stored in databases When data are stored in a database, $LVN_ODCACHEHINT notifications and the $tagNMLVCACHEHINT structure is used to insert the rows in an array cache before they are displayed with $LVN_GETDISPINFO messages. The $tagNMLVCACHEHINT structure is defined in this way: Global Const $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo" Note that $tagNMLVCACHEHINT is not included in GuiListView.au3 or StructureConstants.au3. Code for $LVN_ODCACHEHINT messages in the WM_NOTIFY function can be implemented in this manner: Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ), $iColumns $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) Local $sSQL = "SELECT * FROM lvdata WHERE item_id >= " & $iFrom & _ " AND item_id <= " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) & ";" _SQLite_GetTable2d( -1, $sSQL, $aResult, $iRows, $iColumns ) $aResult is the array cache. The purpose of the cache is to limit the number of SELECT statements. When the listview is displayed for the first time, all visible rows (in this example about 20) have to be updated. In this case $aResult will contain 20 rows and 10 columns. 20 rows is also the maximum number of rows in $aResult. A virtual listview will never update more than the visible number of rows at one time. Code for $LVN_GETDISPINFO messages can be implemented in this way: Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $iIndex = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom + 1 If $iIndex > 0 And $iIndex < $iRows + 1 Then Local $sItem = $aResult[$iIndex][DllStructGetData($tNMLVDISPINFO,"SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) EndIf EndIf The zip below contains a small GUI, CreateDB.au3, to create 3 SQLite databases with 100,000/1,000,000/10,000,000 rows. The databases will use about 10/100/1000 MB of diskspace, and the creation will take about ½/5/40 minutes (on an old XP). You must select a database and click a button to start the creation. If you get tired of waiting, you can cancel (checked for every 10,000 rows) the process and continue another time. The process will continue where it stopped. You can run the examples even though the databases might only contain 30,000/200,000/1,500,000 rows. You do not have to create all three databases. Run LvVirtDB.au3. Data stored in fixed-length record files (update 2015-04-01) Extracting data directly from a fixed-length record file by setting the file pointer to the current record and reading the required number of bytes is another example, where $LVN_ODCACHEHINT messages should be used to insert records in an array cache before they are displayed. Code for $LVN_ODCACHEHINT and $LVN_GETDISPINFO messages can be implemented as shown: Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ) $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) $iRows = DllStructGetData( $tNMLVCACHEHINT, "iTo" ) - $iFrom + 1 FileSetPos( $hFile, $iFrom * 12, 0 ) ; Each line is 10 chars + CR + LF $aCache = StringSplit( FileRead( $hFile, $iRows * 12 - 2 ), @CRLF, 3 ) The purpose of the cache is to limit the number of FileRead statements. Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $iIndex = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom If -1 < $iIndex And $iIndex < $iRows Then DllStructSetData( $tText, 1, $aCache[$iIndex] ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", 10 ) ; Each line is 10 chars EndIf EndIf Run LvVirtFile.au3. A fixed-length record file with 10,000 records (LvVirtFile.txt) is included in the zip. I have tested this example on a 1,1 GB file and 100,000,000 rows. The listview responds immediately. The solution with a flat fixed-length record file is extremely fast. Much faster than a database. But also with very much limited functionality compared to a database. Sorting rows in a virtual listview (update 2015-04-01) Sorting is not supported at all by virtual listviews. If you want rows to be sorted, you have to feed the listview with the rows in sorted order. If the rows are stored in an array, you have to sort the array before you feed the listview. If you want to sort the rows by two or more columns, you have to store the rows in two or more arrays which are sorted for the current column. Or you have to create two or more indexes to handle the sorting. Sorting arrays and creating indexes is time consuming. If you need sorting, a database seems to be the best solution, because sorting can be handled by the database. Nevertheless, here's an example that stores 10,000/20,000/30,000 rows and 3 columns in arrays, and creates indexes to handle the sorting. The columns are strings, integers and floating point numbers, and indexes are calculated for all 3 columns. To be able to create the indexes as fast as possible, structures (DllStructCreate) are used to create the indexes. This is the function to create indexes for integers and floating point numbers. The function for strings is equivalent. $tIndex = DllStructCreate( "uint[" & $iRows & "]" ) Func SortNumbers( ByRef $aItems, $iRows, $iCol, $pIndex, $tIndex ) Local $k, $n, $lo, $hi, $mi, $gt HourglassCursor( True ) WinSetTitle( $hGui, "", "Virtual ListViews. Sort numbers: 0 rows" ) For $i = 0 To $iRows / 10000 - 1 $k = $i * 10000 For $j = 0 To 9999 $n = $aItems[$k+$j][$iCol] ; Binary search $lo = 0 $hi = $k + $j - 1 While $lo <= $hi $mi = Int( ( $lo + $hi ) / 2 ) If $n < $aItems[DllStructGetData($tIndex,1,$mi+1)][$iCol] Then $gt = 0 $hi = $mi - 1 Else $gt = 1 $lo = $mi + 1 EndIf WEnd ; Make space for the new value DllCall( $hKernel32Dll, "none", "RtlMoveMemory", "struct*", $pIndex+($mi+1)*4, "struct*", $pIndex+$mi*4, "ulong_ptr", ($k+$j-$mi)*4 ) ; Insert new value DllStructSetData( $tIndex, 1, $k+$j, $mi+1+$gt ) Next WinSetTitle( $hGui, "", "Virtual ListViews. Sort numbers: " & $k + 10000 & " rows" ) Next HourglassCursor( False ) WinSetTitle( $hGui, "", "Virtual ListViews (sorted)" ) EndFunc Run LvVirtArraySort.au3. It takes some time to create the arrays and indexes. But when everything is created, sorting by different columns and switching from one array to another is instantaneous. Because it's easy and fast to save/load a structure to/from a binary file, it may be advantageous to calculate the arrays and indexes in another script before the GUI is opened. $LVN_ODFINDITEM notifications (update 2015-04-01) Three notifications are important for virtual listviews. $LVN_GETDISPINFO (to get information about the rows to display in the listview) and $LVN_ODCACHEHINT (to store rows from a file or database in an array cache before they are displayed with $LVN_GETDISPINFO messages) are already mentioned above. The last is $LVN_ODFINDITEM, which is used to find a row when you press one or a few keys on the keyboard. Information from $LVN_ODFINDITEM is stored in the $tagNMLVFINDITEM structure. The codebox shows the code for $LVN_ODFINDITEM notifications: Case $LVN_ODFINDITEMW Local $tNMLVFINDITEM = DllStructCreate( $tagNMLVFINDITEM, $lParam ) If BitAND( DllStructGetData( $tNMLVFINDITEM, "Flags" ), $LVFI_STRING ) Then Return SearchText( DllStructGetData( $tNMLVFINDITEM, "Start" ), _ ; Start DllStructGetData( DllStructCreate( "wchar[20]", DllStructGetData( $tNMLVFINDITEM, "Text" ) ), 1 ) ) ; Text EndIf Start is the row where you start the search. Text contains the key presses to search for. You have to implement the search function (here SearchText) yourself. If the function finds a row, it should return the index of the row. If not, it should return -1. Run LvVirtArrayFind.au3. Using standard listviews (update 2015-04-01) If not more than 10,000 rows have to be inserted in a listview, a standard listview is sufficiently rapid. Because of speed you should use native (built-in) functions to fill the listview and not functions in GuiListView.au3 UDF. When the listview is filled, you can use all the functions in the UDF. This code shows how to quickly fill a listview with native functions: Func FillListView( $idLV, ByRef $aItems, $iRows ) Local $tLVITEM = DllStructCreate( $tagLVITEM ) Local $pLVITEM = DllStructGetPtr( $tLVITEM ), $k, $s DllStructSetData( $tLVITEM, "Mask", $LVIF_IMAGE ) ; Icon (or image) DllStructSetData( $tLVITEM, "SubItem", 0 ) ; First column HourglassCursor( True ) For $i = 0 To $iRows / 10000 - 1 $k = $i * 10000 For $j = 0 To 9999 ; Text $s = $aItems[$k+$j][0] For $l = 1 To 9 $s &= "|" & $aItems[$k+$j][$l] Next GUICtrlCreateListViewItem( $s, $idLV ) ; Add item and all texts ; Icon Select Case Mod( $k + $j, 3 ) = 0 DllStructSetData( $tLVITEM, "Image", 2 ) ; Icon index Case Mod( $k + $j, 2 ) = 0 DllStructSetData( $tLVITEM, "Image", 1 ) Case Else DllStructSetData( $tLVITEM, "Image", 0 ) EndSelect DllStructSetData( $tLVITEM, "Item", $k + $j ) ; Row GUICtrlSendMsg( $idLV, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon Next WinSetTitle( $hGui, "", "GUICtrlCreateListViewItem ListViews. Fills listview: " & $k + 10000 & " rows" ) Next HourglassCursor( False ) WinSetTitle( $hGui, "", "GUICtrlCreateListViewItem ListViews" ) EndFunc Run LvStandard.au3. LvStandardIni.au3 shows how to quickly load an inifile (LvStandardIni.ini, created with IniWriteSection) into a listview. Because an inifile is a small file (only the first 32767 chars are read) it should always be loaded into a standard listview. Updates Update 2015-03-24 Added two array-examples. An example (LvVirtArrayIcons.au3) that shows how to use checkboxes and icons, and an example (LvVirtArrayColors.au3) that shows how to draw every second row with a different background color. In this post you can find an example where all items are drawn with a random background color. Update 2015-04-01 Cleaned up code in previous examples. Added more examples as described above. Zip updated. UDF versions (2018-04-27) Over the past weeks, new display functions have been added to Data display functions based on virtual listviews, and new functions have been added to use the listviews as embedded GUI controls. All the functions work and are used in much the same way. Apart from the data source, the function parameters are the same for all functions. The display functions support a wide range of features, all specified via a single function parameter $aFeatures, which is the last parameter. The central code to handle $LVN_ODCACHEHINT and $LVN_GETDISPINFO notifications is very optimized code. First of all, the code is implemented through the subclassing technique. This means that messages are received directly from the operating system and not from AutoIt's internal message management code. Messages are returned again directly to the operating system and again without interference with AutoIt's internal message handling code. Next, the code is divided into different include files each taking care of a particular feature. That way, it's avoided that a lot of control statements makes the code slow. And it's enough to include the code that's actually used. One reason why so much work has been done in optimizing code and developing features is that these functions will also work as UDF versions for the examples here. It's far from a trivial task to develop UDF versions of examples like these. Since the first version of the display functions was created in this thread 2½ years ago and then has been continuously developed, it's obvious to use the functions as UDF versions of these examples. The following examples are implemented as UDF versions: Data stored in arrays Data stored in CSV files Data stored in SQLite databases Zip file Examples in zip: LvVirtArray.au3 - Data stored in arrays LvVirtArrayColors.au3 - Alternating row colors LvVirtArrayFind.au3 - $LVN_ODFINDITEM notifications LvVirtArrayIcons.au3 - Checkboxes and icons LvVirtArraySort.au3 - Sorting rows in a virtual listview LvVirtDB.au3 - Data stored in databases (use CreateDB.au3 to create DBs) LvVirtFile.au3 - Data stored in fixed-length record files LvStandard.au3 - Using standard listviews LvStandardIni.au3 - Load inifile into a listview The size of the zip is caused by a 118 KB txtfile, LvVirtFile.txt, used by LvVirtFile.au3, and a 28 KB inifile, LvStandardIni.ini, used by LvStandardIni.au3. Tested with AutoIt 3.3.10 on Windows 7 64 bit and Windows XP 32 bit. Should work on all AutoIt versions from 3.3.10 and all Windows versions. Virtual ListViews.7z Examples Examples based on virtual listviews. Array examples: A lot of rows and random background colors for each cell - This post in another thread Incremental search (update as you type) in a virtual listview - Post 29 Sorting arrays: Rows can be sorted by strings, integers, floats and checkboxes, checked rows in top - Post 48 File sources: A CSV-file with 100,000 rows and 10 columns is data source - Post 56 SQLite examples: Various issues related to the use of a database - Post 34, 35, 43 An example that shows a way to implement a search box - Post 411 point
-
I love chiptune music, but BASS only support XM, IT, S3M, MOD, MTM, UMX and MO3 file format for MOD music. 1 | Nintendo NES and SNES Sound File Players May be you already have some files with extension nsf, nsfe, spc or rsn (unzip rsn files for get spc collection files inside) but you can't play them in a AutoIt script ? So I searched around a bit, and found 2 DLL ( nsf_player.dll and spc_player.dll ) for play Nintendo NES and SNES Sound Files. Interest of those DLL is that they can play from file path or binary data, avoiding temp files. Dll and audio files are embedded in scripts for permit you to test them right away. Some info/download links are in front of each script. 2 | ModPlug Player Another dll found : npmod32.dll who support mod, s3m, xm, med, it, s3z, mdz, itz, xmz and wav files. Interest : it can play some rares chiptune formats, you can also pause, set volume and set position. Inconvenient : do not load from binary datas. Dll and audio files are embedded in script and i have added a gui for permit you to try right away ! Warning : Do not work on Win8. 3 | ZXTune Player 2 (basszxtune.dll v2.4.5) UPDATE of 23 DEC 2016 Using BASSZXTUNE chiptune support for BASS ( Support as0, asc, ay, ftc, gtr, psc, psg, psm, pt1, pt2, pt3, sqt, st1, s, st3, stc, stp, ts, txt, vtx, ym, chi, dmm, dst, m, sqd, str, sid, cop, tf0, tfc, tfd, tfe, $b, $m, ahx, ayc, bin, cc3, d, dsq, esv, fdi, gam, gamplus, gbs, gym, hes, hrm, hrp, lzs, msp, mtc, nsf, nsfe, p, pcd, sap, scl, spc, szx, td0, tlz, tlzp, trd, trs, vgm ) Interest : it can play lot of rares chiptune formats, while benefiting from all bass functions. Inconvenient : dll size.(5860ko) Dll and audio files are embedded in script. 4 | TitchySID Player Files and dll are loaded in memory. Interest : dll size (8ko), you can Play/Stop/Pause/Resume and choose which subsong to play. Inconvenient : only SID audio files supported ( PSID & RSID) Dll and audio files are embedded in script. Tested under Win7 and Win8. Edit : added a Sid header viewer : SidHeaderViewer.au3 5 | MiniFmod Player Interest : dll size (20ko) Inconvenient : only xm audio files supported. 6 | Npnez Player Using npnez.dll (88ko) for play Gameboy Sound System audio files and some others ( kss, hes, nsf, ay, gbr, gbs, gb, nsd, sgc ) Interest : Can be loaded in memory, subsong can be set and volume can be adjusted ( perfect for create a fade when exiting ) Inconvenient : for an unknow reason, only 20% of my hes collection is playable... 7 | µFMOD Player Interest : dll size (10ko), can be loaded in memory, support Play/Stop/Pause/Resume actions and volume can be adjusted ( perfect for create a fade when exiting ) Inconvenient : only xm audio files supported. 8 | MagicV2m Player Interest : dll size (20ko), Play/Stop/IsPlay/SetAutoRepeat/Progress Inconvenient : only v2m audio files supported, V2mPlayStream is not reliable, so prefer V2mPlayFile instead. 9 | OSMEngine Player OSMEngine.dll (80 ko)(Oldskool Musics Engine) permit to play snd, sndh, fc, fc4, fc14 and some rare jam audio files from Amiga/Atari ST(E) Interest : audio can be loaded in memory, and Pause/Resume/SetVolume/GetInfos are available Inconvenient : none at the moment. 10 | Ayfly Player Ayfly.dll (268 ko) is a AY-891x emulator and player who support the following tracker formats : aqt, asc, ay, fxm, gtr, psc, psg, pt1, pt2, pt3, sqt, stc, stp, vtx, ym and zxs (ZX Spectrum Emulator Snapshot) files. Interest : SetVolume/GetInfos are available Inconvenient : a function named "ay_initsongindirect" for load module in memory exists, but due to the poor documentation provided i do not succeed to get it to work... 11 | GMGME Player GMGME.dll is a emulated music DLL that allows you to play ay, gbs, gym, hes, kss, nsf/nsfe, sap, spc and vgm files. Interest : Can play ATARI SAP files (only type B and C) , Set Volume and Set Tempo are available Inconvenient : Dll Size (and his imports) , and audio files can not be loaded in memory. 12 | SC68 Player sc68replay.dll (166 ko) is a Freebasic DLL compiled from "sc68replay" src that allows you to play SC68 (Atari ST and Amiga audio formats) files. Interest : Can play from file and memory Inconvenient : Unfortunatelly for an unknown reason not all sc68 files are supported. 13 | Extended Module Player LibXmp.dll (272 ko) can "read" xm, mod, it, s3m, med, 669 but also some rares formats abk, amd, amf, dbm, digi, dtm, emod, far, flx, fnk, gdm, hsc, imf, j2b, liq, m15, mdl, mfp, mgt, mtm, mtn, okt, psm, ptm, rad, rtm, sfx, smp, stim, stm, stx, ult, umx, wow, ym3812 Despite its name, it's not a "player" but a library that renders module files to RAW PCM data. So the interest in this script was to find a way to convert those raw datas into a "playable" sound. With Waveform Audio Interface i create a pseudo Wav header who permit to play datas as a Wav file. Interest : Can play from file and memory Inconvenient : Time to render datas (depends of file size) 14 | LibModPlug Player LibModPlug.dll (102 ko) can "read" xm, it, mod, s3m, med, 669 and also amf, ams, dbm, dmf, dsm, far, j2b, mdl, mt2, mtm, okt, psm, ptm, stm, ult, umx. As LibXmp.dll, it's a library that renders module files to RAW PCM data. For this one, i create a real binary wave header for be able to play it easily from memory with winmm.dll PlaySoundW function. Interests : Can play from file and memory, and have some nice sound effects : Surround, MegaBass and Reverb (used in script example) It can also replace modplug player(2) for Win 8+ users Inconvenient : Time to render datas (depends of file size) 15 | AdPlug Player AdPlug.dll ( 69ko ) is an AdLib sound player library who is able to play the following files type : A2M, ADL, AMD, BAM, CFF, CMF, D00, DFM, DMO, DRO, DTM, HSC, HSP, IMF, KSM, LAA, LDS, M, MAD, MID, MKJ, MSC, MTK, RAD, RAW, RIX, ROL, S3M, SA2, SAT, SCI, SNG, XAD, XMS, XSM For this one, time to render datas is to long, so i needed to find an other way for play modules. Using Bass.dll and particulary the "BASS_StreamPutData" function i succeeded to play module in loop while rendering it. Both DLL are loaded in memory, and 16 different module types are available in the script. No includes/files needed. Just run it. Warning : for a unique file extension (example .sng), it's sometimes possible to have several filetypes from different trackers ! AdPlug.dll Imports : msvcp71.dll, msvcr71.dll in C:\Windows\SysWOW64 ( VC Redist Installer ) Interests : Can read some obscure rare formats. Inconvenient : Can not read from memory 16 | LibMikmod Player LibMikmod.dll (85ko) will currently play the following common and not so common formats : 669, AMF, DSM, FAR, GDM, IMF, IT, MED, MOD, MTM, S3M, STM, STX, ULT, UNI, XM Interests : Can load from memory Inconvenient : only for full-screen applications, because if the application has not the focus sound is muted Downloads are available in the download section Dedicated to chiptune Lovers ! Music Links : asma.atari.org woolyss.com chipmusic.org demozoo.org modarchive.org modules.pl keygenmusic.net zxtunes.com mazemod.org amigaremix.com pouet.net plopbox.eu Modland1 point
-
Try this: #include <GDIPlus.au3> #include <Memory.au3> #include <WindowsConstants.au3> #NoTrayIcon Global Const $STM_SETIMAGE = 0x0172, $BM_SETIMAGE = 0xF7, $BS_BITMAP = 0x0080 Global $bico = "0x89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF61000000017352474200AECE1CE" & _ "90000000467414D410000B18F0BFC6105000000E249444154384F9D93B11183300C45198559E8E92929188B9E31684241E58" & _ "CC0064E1A5AC74F67F9841B82B9D321E4AF6759C84D533CE7798ED1D668A1306263A9CFDF71B18DE634E9388ED0759D18BE81" & _ "A1692FA094EC976509FBBE8B185F01F33C4B8C35E2D1F717083BDB84699A42DFF719804F4C8109E2A48A7466A1ABE0EEAD554" & _ "A4F6CC3741776DC5E5BF8F8AF18BE5684C6F46305204DE29C2AD264E7DE01530895A141AB8D1540593209246A5C21A58EDC47" & _ "8061182E9B6500E5D0D97F8F80D61E214F5D6D1319DDFADF9866A17E9012807B503FCA06527799ECCD7A7A9D7F919E81F9F48" & _ "210970000000049454E44AE426082" _GDIPlus_Startup() $Form1 = GUICreate("Example", 300, 200, -1, -1, BitOR($WS_THICKFRAME,$WS_SYSMENU)) $btn = GUICtrlCreateButton("",130,70,32,32,$BS_BITMAP) $hButton = GUICtrlGetHandle($btn) $hHBITMAP = _GDIPlus_BitmapCreateFromMemory(Binary($bico), True) _WinAPI_DeleteObject(_SendMessage($hButton, $BM_SETIMAGE, 0, $hHBITMAP)) _GDIPlus_Shutdown() GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 GUIDelete() _WinAPI_DeleteObject($hHBITMAP) Exit EndSwitch WEnd1 point
-
AutoIt3Wrapper will default a list of fileversion fields to the value present in aut2exe.exe (previously the BIN file) in case it needs to update the fileversion section. This has always been the case, but can be change if desired. If $INP_Comment = "" Then $INP_Comment = FileGetVersion($AutoItBin, "Comments") If $INP_Description = "" Then $INP_Description = FileGetVersion($AutoItBin, "FileDescription") If $INP_Fileversion = "" Then $INP_Fileversion = FileGetVersion($AutoItBin) If $INP_LegalCopyright = "" Then $INP_LegalCopyright = FileGetVersion($AutoItBin, "LegalCopyright") If $INP_ProductVersion = "" Then $INP_ProductVersion = FileGetVersion($AutoItBin) Jos1 point
-
I wondered how to make a string grid and played around with some ideas. Since I don't actually need one it's ground to a halt Maybe some of the ideas will be useful to someone. I got most things I was thinking of at least to the stage where I think I could make them work, but there are lots of things missing or incomplete. I know that you can use the Excel UDF's or OpenOffice Calc UDFs but that wasn't the point and an AUtoIt string grid seemed like a good idea to me for a while . source = stringGrid01.zip Edit made a couple of changes based on Yashied's post #4 mgrefStringGrid1 point
-
how to use guictrlsetlimit
rotatorkuf reacted to kylomas for a topic
rotatorcuff, GuiCtrlSetLimit needs to reference the updown control. Try it like this... #include <GUIConstantsEx.au3> local $gui010 = guicreate('') Global $inputRuns = GUICtrlCreateInput("3",10, 110, 40,20) local $up = GUICtrlCreateUpdown($inputRuns) GUICtrlSetLimit($up, 20, 6) guisetstate() while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd kylomas edit: This also works... #include <GUIConstantsEx.au3> local $gui010 = guicreate('') Global $inputRuns = GUICtrlCreateInput("3",10, 110, 40,20) GUICtrlCreateUpdown($inputRuns) GUICtrlSetLimit(-1, 20, 6) guisetstate() while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd1 point -
@all Better is to switch over the plain XML Soap Envelopes instead. This is a working example : #AutoIt3Wrapper_UseX64=N local $objHTTP local $strEnvelope local $strReturn local $objReturn local $strQuery local $strValue $strValue = InputBox("Testing", "Enter your new value here.", 60007) ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $objHTTP = ObjCreate("Microsoft.XMLHTTP") $objReturn = ObjCreate("Msxml2.DOMDocument.3.0") ; Create the SOAP Envelope $strEnvelope = '<?xml version="1.0" encoding="utf-8"?>' & _ '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' & _ '<soap:Body>' & _ '<GetInfoByZIP xmlns="http://www.webserviceX.NET">' & _ '<USZip>'&$strValue&'</USZip>' & _ '</GetInfoByZIP>' & _ '</soap:Body>' & _ '</soap:Envelope>' ; Set up to post to the server $objHTTP.open ("post", "http://www.webservicex.net/uszip.asmx?op=GetInfoByZIP", False) ; Set a standard SOAP/ XML header for the content-type $objHTTP.setRequestHeader ("Content-Type", "text/xml") ConsoleWrite("Content of the Soap envelope : "& @CR & $strEnvelope & @CR & @CR) ; Make the SOAP call $objHTTP.send ($strEnvelope) ; Get the return envelope $strReturn = $objHTTP.responseText ConsoleWrite("-----------" & @CRLF) ConsoleWrite ("Debug Response : "& @CR & $strReturn & @CR & @CR) ConsoleWrite("-----------" & @CRLF) ; Load the return envelope into a DOM $objReturn.loadXML ($strReturn) ConsoleWrite("Return of the SOAP Msg : " & @CR & @CR & $objReturn.XML & @CR & @CR) ; Query the return envelope $strQuery = "SOAP:Envelope/SOAP:Body" $objReturn.selectSingleNode($strQuery) $Soap = $objReturn.Text MsgBox(0,"SOAP Response","The Response is : " & $Soap) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) Endfunc Hope this helps rgds ptrex1 point
-
WinNT object seems to be more accurate. It will probably take some hunting to determine why in our environment networkloginprofile password age would greatly differ from the WinNT entry. $system = "LOCALHOST" $user = "USERNAME" Local $adsPath = "WinNT://" & $system & "/" & $user & ",user" Local $objuser = ObjGet($adsPath) msgbox(0, '' , "System: " & $system & @CRLF & "Name : " & $objuser.name & @CRLF & "Password Age : " & round($objuser.passwordage / 86400) & " days." & @CRLF)1 point
-
The code you're using is outdated for drag and drop. May I suggest that you use _WinAPI_DragQueryFileEx() instead, as this is include with the AutoIt UDFs already, plus it works!1 point
-
click the title bar text to pop-up a menu - now for MS worst OS ever!
argumentum reacted to orbs for a topic
suppose you want to display only a single large control, e.g. a ListView. you have a lot of data, but it may be viewed on a small-screen device. you care about not wasting screen area, but you need at least a few basic operations. sure you could use a menu bar, but real estate is pricey these days... inspired by >this - but not even remotely similar in implementation - let's click on the title bar caption text to pop-up a menu! (while clicking on the vacant area of the title bar is used for dragging, as usual). first let's add a small drop-down-like sign to indicate it's possible to click on the caption text: (the red line indicates the width of the title bar that when clicked will pop-up a menu. it is slightly extended, to compensate for situations where the font is larger. it is here for illustration only). the menu is designed as usual, but triggered by registering the WM_SYSCOMMAND message, and checking that the cursor is at the correct position. unfortunately, Windows XP/2003 do not render extended characters (well or at all), so a standard character was selected for them - see screenshots below. Windows Vista also does a poor job at it. but even more unfortunately, Windows 8 has the title bar caption centered! so here's a quick'n'dirty solution: extend the caption with a lot of whitespaces. this has two side effects - there's the 3-dots sign near the "Minimize" button, and the taskbar icon tooltip is extended. i can live with that... so this is how it looks: Windows 8: Windows Vista: Windows XP: Windows 2000 (for the classic theme): the script (uses >_StringSize by Melba23, but you can set the size fix according to your needs): #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "StringSize.au3" Global $nGUI_W = 700, $nGUI_H = 500 Global $sTitle = 'My Program Title' Global $nOSVersion = _OSVersion() If $nOSVersion < 6 Then ; not rendering ChrW well $sTitle = ' :: ' & $sTitle Else $sTitle &= ' ' & ChrW(9662) EndIf Global $aTitleWidth = _StringSize($sTitle) Global $iTitleWidth = 0 If Not @error Then $iTitleWidth = $aTitleWidth[2] + 3 ; ampirical Global $iTitleOffset = 20 ; ampirical: 16px icon + 4px space If $nOSVersion > 6.1 Then ; Windows 8, Windows 2012 => "align" caption to left, consider increased font size $sTitle &= ' ' $iTitleOffset = $iTitleOffset * 1.2 ; ampirical EndIf $iTitleWidth = $iTitleWidth * 1.3 ; ampirical Global $hGUI = GUICreate($sTitle, $nGUI_W, $nGUI_H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_SYSMENU)) ; indicative label for the position and width of titlebar caption text to trigger menu GUICtrlCreateLabel('', $iTitleOffset, 0, $iTitleWidth, 1) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetBkColor(-1, 0xff0000) Global $gMenu_Dummy = GUICtrlCreateDummy() Global $gMenu = GUICtrlCreateContextMenu($gMenu_Dummy) Global $gMenu_Submenu = GUICtrlCreateMenu('Submenu', $gMenu) Global $gMenu_Option = GUICtrlCreateMenuItem('Option', $gMenu) Global $bOption = True GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateMenuItem('', $gMenu) For $i = 1 To 5 GUICtrlCreateMenuItem('Submenu Item ' & $i, $gMenu_Submenu) GUICtrlSetState(-1, $GUI_CHECKED) Next GUICtrlCreateMenuItem('Item 1', $gMenu) GUICtrlCreateMenuItem('Item 2', $gMenu) GUICtrlCreateMenuItem('Item 3', $gMenu) GUICtrlCreateMenuItem('', $gMenu) Global $gMenu_About = GUICtrlCreateMenuItem('About', $gMenu) Global $gMenu_Close = GUICtrlCreateMenuItem('Close', $gMenu) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg($WM_SYSCOMMAND, '_WM_SYSCOMMAND') GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") Global $msg While True $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $gMenu_Close ExitLoop Case $gMenu_Option $bOption = Not $bOption If $bOption Then GUICtrlSetState($gMenu_Option, $GUI_CHECKED) Else GUICtrlSetState($gMenu_Option, $GUI_UNCHECKED) EndIf EndSwitch WEnd #region context menu and auxiliary funcs Func _ContextMenu_ShowMenu($hWnd, $nContextID, $CtrlID = 0, $n_dx = 0, $n_dy = 0) ; Show a menu in a given GUI window which belongs to a given GUI ctrl Local $arPos[4], $x, $y Local $hMenu = GUICtrlGetHandle($nContextID) If $CtrlID Then $arPos = ControlGetPos($hWnd, "", $CtrlID) $x = $arPos[0] + $n_dx $y = $arPos[1] + $arPos[3] + $n_dy _ContextMenu_ClientToScreen($hWnd, $x, $y) _ContextMenu_TrackPopupMenu($hWnd, $hMenu, $x, $y) EndFunc ;==>_ContextMenu_ShowMenu Func _ContextMenu_ClientToScreen($hWnd, ByRef $x, ByRef $y) ; Convert the client (GUI) coordinates to screen (desktop) coordinates Local $stPoint = DllStructCreate("int;int") DllStructSetData($stPoint, 1, $x) DllStructSetData($stPoint, 2, $y) DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint)) $x = DllStructGetData($stPoint, 1) $y = DllStructGetData($stPoint, 2) ; release Struct not really needed as it is a local $stPoint = 0 EndFunc ;==>_ContextMenu_ClientToScreen Func _ContextMenu_TrackPopupMenu($hWnd, $hMenu, $x, $y) ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>_ContextMenu_TrackPopupMenu Func _WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam) ; to display main menu when click titlebar caption #forceref $hWnd, $iMsg, $wParam, $lParam Local $iMousePos Local $iClientAreaPosX, $iClientAreaPosY If $wParam = 0x0000F012 Then $iMousePos = MouseGetPos(0) _ContextMenu_ClientToScreen($hGUI, $iClientAreaPosX, $iClientAreaPosY) If $iMousePos > $iClientAreaPosX + $iTitleOffset And $iMousePos < $iClientAreaPosX + $iTitleOffset + $iTitleWidth Then _ContextMenu_ShowMenu($hWnd, $gMenu) EndIf EndFunc ;==>_WM_SYSCOMMAND Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) ; to enforce minimum window size #forceref $hWnd, $iMsg, $wParam, $lParam Local $tagMaxinfo If $hWnd = $hGUI Then $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $nGUI_W - 100) DllStructSetData($tagMaxinfo, 8, $nGUI_H - 100) Return 0 EndIf EndFunc ;==>_WM_GETMINMAXINFO Func _OSVersion() $sOSVersion = RegRead('HKLM\Software\Microsoft\Windows NT\CurrentVersion', 'CurrentVersion') If @error Then Return SetError(1, 0, 0) Return Number($sOSVersion) EndFunc ;==>_OSVersion #endregion context menu and auxiliary funcs the entire thing is as crude as hell, and i'm sure there are many more elegant ways to improve it. enjoy!1 point -
NetSession UDF 0.9d (Set embedded browser Internet options on a per-process basis) Welcome to NetSession UDF! With this UDF we provide you with previously unexposed Internet options for your autoit processes which will apply to embedded browser controls created with _IECreateEmbedded. For instance, you can now set a proxy and user-agent for all for your Autoit application's embedded browsers without using the registry settings. This means that you can now have multiple proxy settings for multiple programs/processses, giving each process it's own proxy/agent/other settings for your embedded browser controls and change them within each application as many times as you like. In other words, dynamic per-program (Not shared) Internet settings for any application containing an embedded browser control. There's also a function to clear all of your browser's cookies as well as all flash cookies. Versions: Version 0.9 includes the ability to set an HTTP/SOCKS4/SOCKS5 proxy and browser agent for individual AutoIt processes that can all be running at the same time with different settings. This is easy to use. This UDF started out as code that I worked on years ago and now we're bringing it back to life as a UDF with new features planned. Version 0.9b now has the new _ClearCookies function which will remove all IE and Flash cookies. Version 0.9c has added the "#include-once" directive as a UDF should and an optimization to the _ClearCookies function thanks to jdelaney. _ClearCookies has also been changed to return TRUE or FALSE rather than strings, not pause script execution when deleting IE cookies, and the hidden window flag added for Its shell command. Version 0.9d has the added function _UseTOR. This release comes just minutes after the last release because it slipped my mind that it was on the Planned Features list and is easy to add. This new function simply envokes _SetProxy with the proper parameters for TOR with the option to change the port if your install of TOR isn't using the default port number; otherwise, no parameter is necessary. This will likely be the last release until we have more updates to the DLL/Windows API calls. At the moment this UDF makes use of urlmon.dll to apply settings to your application executables. Our goal is to expose all functionality of this DLL as well as possibly expand into more functionality using other Windows API elements. Important: If you wish to change the settings of an IE control more than once during the life if your program you might have to refresh the IE control or GUI of your app before applying the next change. This was the case years ago. I'll do some testing on this and publish an update to the UDF or add an example of a refresh to the Example Usage. Example usage & notes: #include <NetSession-0.9d.au3> ; Let's include IE.au3 just for this example assuming you're making an embedded browser. #include <IE.au3> ; In this example you would create your embedded IE object and use as follows. _SetProxy('108.247.158.12:8080') ; Now your proxy is set. This would be an HTTP proxy. For SOCKS you would use: _SetProxy('socks=108.247.158.12:1080') ; Or if you have TOR running and would like to use it as your proxy simply use: _UseTOR() ; But if your TOR isn't running on default port 9150 (Like if you changed it to 9292) you must specify your TOR port: _UseTOR(9292) ; The following is an example of setting your user agent: _SetUserAgent('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36') ; At this point any browsing you perform will use the previously set proxy and user agent. Such as: _IENavigate($ie,"http://www.ipchicken.com") ; If your proxy or SOCKS requires authentication you would add the proxy auth to the URL like this: _IENavigate($ie,"http://ProxyUser:ProxyPass@www.ipchicken.com") ; Let's clear all browser & Flash cookies _ClearCookies() ; Note that you can change these settings as many times as you need to in your application and these ; settings will only be applied to the .exe they were set from. This means you don't have to change ; the system-wide proxy or user-agent settings and can have per-.exe embedded browser settings. I welcome anyone who wants to contribute. Any suggestions will be much appreciated. The UDF NetSession-0.9d.au3 is attached to this post. The filename will always reflect the version number and this thread post will be kept up to date. I've chosen 0.9 because at this point we only need to figure out one more thing to consider it a complete 1.0. Version 1.0 will include an advanced authentication mechanism for proxies and socks servers (Better than passing proxy auth via the URL). The reason we want to use the authentication capabilities of the DLL is because when you pass authentication via the URL you can't access HTTPS sites through the proxy (You can if no proxy auth is required). If you can help make this UDF better by improving authentication as just previously mentioned or add any other functionality PLEASE don't hesitate to reply to this thread with some code. Here are the references to how this UDF came about and where you would look to help improve it: http://msdn.microsoft.com/en-us/library/ms775125%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa385148%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa385328%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/aa383630%28v=vs.85%29.aspx http://support.microsoft.com/kb/226473 Current Functions: _SetProxy(string $Proxy) - Sets an HTTP or SOCKS server for embedded IE browsers in the current process. _SetUserAgent(string $Agent) - Sets the user/browser agent for embedded IE browsers in the current process. _ClearCookies() - Deletes all IE and system Flash cookies. Returns a Boolean value. _UseTOR(int $TORPort = 9150) - Sets TOR as your proxy. You must have TOR running. $TORPort is only necessary if your TOR isn't using default 9150. TOR can be downloaded here: https://www.torproject.org/download/download-easy.html Planned Features: Proxy authentication via DLL rather than passing to URL. Function to set HTTP referrer. Support for other (Non-IE) embedded browsers. An ease-of-use function for setting TOR as the proxy server (This can currently be done manually). (Done) Compatability: All known versions of Windows since 2000/XP (Possibly earlier versions as well). Note: The settings applied by this UDF do not appear to affect functions such as InetGet. For those functions you would want to use HttpSetProxy. This UDF is for browser controls (which HttpSetProxy does not affect). Also, the browser must be embedded into the application as with _IECreateEmbedded. It will not work with a new window created with _IECreate. System Requirements: The existance of urlmon.dll on the system usually located in WindowsSystem32 Releases: NetSession-0.9.au3 {OLD} NetSession-0.9b.au3 {OLD} NetSession-0.9c.au3 {OLD} NetSession-0.9d.au3 {Newest} The changes in each version are detailed near the top of this post. !!! WE NEED HELP FOR THE NEXT RELEASE !!! Here's our current (not working) attempt to use a proxy's username & password without passing it in the URL. Without this capability we can't browse to HTTPS sites if proxy auth is required: Please help if you can Happy coding!1 point