Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/05/2015 in all areas

  1. I built my own libcurl for AutoIt based on BinaryCall UDF. libcurl - the multiprotocol file transfer library The Features: Pure AutoIt script, no DLLs needed.Build with SSL/TLS and zlib support (without libidn, libiconv, libssh2).Full easy-interface and partial multi-interface support.Data can read from or write to autoit variables or files.Smaller code size (compare to most libcurl DLL).The version information of this build: Curl Version: libcurl/7.42.1SSL Version: mbedTLS/1.3.10Libz Version: 1.2.8Protocols: ftp,ftps,http,httpsHere are the helper functions (not include in libcurl library). Curl_DataWriteCallback()Curl_DataReadCallback()Curl_FileWriteCallback()Curl_FileReadCallback()Curl_Data_Put()Curl_Data_Get()Curl_Data_Cleanup()See the example script for detail usage. Curl.zip
    1 point
  2. For those who use ListViews and wish to call a Function to grab the contents of the ListView into a 2D array, then _GUICtrlListView_CreateArray() is for you. It will Return an array with the contents of the ListView inc. the number of rows, columns & column names. Simply run the Example to get an idea of the output. Thanks. Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_CreateArray ; Description ...: Creates a 2-dimensional array from a listview. ; Syntax ........: _GUICtrlListView_CreateArray($hListView[, $sDelimeter = '|']) ; Parameters ....: $hListView - Control ID/Handle to the control ; $sDelimeter - [optional] One or more characters to use as delimiters (case sensitive). Default is '|'. ; Return values .: Success - The array returned is two-dimensional and is made up of the following: ; $aArray[0][0] = Number of rows ; $aArray[0][1] = Number of columns ; $aArray[0][2] = Delimited string of the column name(s) e.g. Column 1|Column 2|Column 3|Column nth ; $aArray[1][0] = 1st row, 1st column ; $aArray[1][1] = 1st row, 2nd column ; $aArray[1][2] = 1st row, 3rd column ; $aArray[n][0] = nth row, 1st column ; $aArray[n][1] = nth row, 2nd column ; $aArray[n][2] = nth row, 3rd column ; Author ........: guinness ; Remarks .......: GUICtrlListView.au3 should be included. ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|') Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView) If $iColumnCount < 3 Then $iDim = 3 - $iColumnCount EndIf If $sDelimeter = Default Then $sDelimeter = '|' EndIf Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']] For $i = 0 To $iColumnCount - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $i) $aReturn[0][2] &= $aColumns[5] & $sDelimeter Next $aReturn[0][2] = StringTrimRight($aReturn[0][2], StringLen($sDelimeter)) For $i = 0 To $iItemCount - 1 For $j = 0 To $iColumnCount - 1 $aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListView_CreateArrayExample use of Function: #include <Array.au3> ; Required only for _ArrayDisplay(). #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> Example() Func Example() Local $iWidth = 600, $iHeight = 400, $iListView = 0 Local $hGUI = GUICreate('_GUICtrlListView_CreateArray()', $iWidth, $iHeight, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) _CreateListView($hGUI, $iListView) Local $iGetArray = GUICtrlCreateButton('Get Array', $iWidth - 90, $iHeight - 28, 85, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) Local $iRefresh = GUICtrlCreateButton('Refresh', $iWidth - 180, $iHeight - 28, 85, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) GUISetState(@SW_SHOW, $hGUI) Local $aReturn = 0, $aStringSplit = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iGetArray $aReturn = _GUICtrlListView_CreateArray($iListView, Default) ; Use | as the default delimeter. _ArrayDisplay($aReturn, '_GUICtrlListView_CreateArray() array.') $aStringSplit = StringSplit($aReturn[0][2], '|') _ArrayDisplay($aStringSplit, 'StringSplit() to retrieve column names.') Case $iRefresh GUICtrlDelete($iListView) _CreateListView($hGUI, $iListView) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func _CreateListView($hGUI, ByRef $iListView) ; Thanks to AZJIO for this function. Local $aClientSize = WinGetClientSize($hGUI) $iListView = GUICtrlCreateListView('', 0, 0, $aClientSize[0], $aClientSize[1] - 30) GUICtrlSetResizing($iListView, $GUI_DOCKBORDERS) Sleep(250) Local $iColumns = Random(1, 5, 1) __ListViewFill($iListView, $iColumns, Random(25, 100, 1)) ; Fill the ListView with Random data. For $i = 0 To $iColumns _GUICtrlListView_SetColumnWidth($iListView, $i, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($iListView, $i, $LVSCW_AUTOSIZE_USEHEADER) Next EndFunc ;==>_CreateListView Func __ListViewFill($hListView, $iColumns, $iRows) ; Required only for the Example. If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) EndIf Local $fIsCheckboxesStyle = (BitAND(_GUICtrlListView_GetExtendedListViewStyle($hListView), $LVS_EX_CHECKBOXES) = $LVS_EX_CHECKBOXES) _GUICtrlListView_BeginUpdate($hListView) For $i = 0 To $iColumns - 1 _GUICtrlListView_InsertColumn($hListView, $i, 'Column ' & $i + 1, 50) _GUICtrlListView_SetColumnWidth($hListView, $i - 1, -2) Next For $i = 0 To $iRows - 1 _GUICtrlListView_AddItem($hListView, 'Row ' & $i + 1 & ': Col 1', $i) If Random(0, 1, 1) And $fIsCheckboxesStyle Then _GUICtrlListView_SetItemChecked($hListView, $i) EndIf For $j = 1 To $iColumns _GUICtrlListView_AddSubItem($hListView, $i, 'Row ' & $i + 1 & ': Col ' & $j + 1, $j) Next Next _GUICtrlListView_EndUpdate($hListView) EndFunc ;==>__ListViewFill
    1 point
  3. So I think it's time to publish this little tutorial I have made on using DllCall() and DllStructs. It's not near completion but I think it's a good start at least This tutorial is mostly aimed for people who have never used DllCall() before or have very limited knowledge about it. In the future I will update it with more advanced topics so more advanced users can make use of it too. Well here goes. Dealing_with_Dll.pdf Previous downloads: 31 Suggestions, language corrections and errors in the tutorial is of course welcome.
    1 point
  4. ​You have right, but it should be used in this way: Local $aresults[2] = [1, 1]
    1 point
  5. These are transaction statements. Transactions are explained in any SQL tutorial and in the SQLite docs but here is a short (?) answer: A transaction is a way to isolate a given connection from changes made by other connections. Outside of a transaction block, SQLite is in "autocommit" mode, that is, every individual statement automagically starts a transaction which ends (is commited) after the end of the statement execution. This is necessary even for reads (select ...) since you want to obtain a consistent snapshot of the DB thru your select with no possibility for another connection to change what you're reading. This is done by locking the whole DB file with a read lock which still allows others to do the same and perform selects concurrently. Of course, individual (non transacted) write statements (schema change, inserts, updates) use a write lock, thus disabling concurrent writes. A simple "read" transaction is a way to group read-only statements as if they were a single atomic operation. For instance you can use a read transaction to gather data from various source that can't be put together with a single select statement. This will ensure you get consistent data, where no other connection can modify it under your feet while you're reading. Now suppose you have to perform an operation similar to cash withdrawing from an ATM (without looking at the gory details of what happens inside the ATM). From the bank point of view, you want to perform an atomic operation consisting of several steps: check that the account exists and disable any change to the accountcheck that the account allows the operation (enough credit or under debit limit)allow the cash to be distributedcheck that the cash was effectively taken off the machinerecord the operationsubtract the amount givenunlock the account so that other operations can now take placeYou must ensure that all ("commit") or none ("rollback") of the above steps happen as a whole, else something wrong will happen for one of the parties. For instance you can't allow another money withdrawal (e.g. by bank transfer order) from the account while the operation is taking place. You can't allow account closing during the process either, and so on. What you need here to perform such a read-modify-write operation is an immediate transaction with "begin immediate" ... "end". This uses an advisory lock placed at once, meaning that the lock owner (the connection) is going to first read but intends to later write to the DB. Before the first write (insert/update) statement starts, the advisory lock is escaladated to an exclusive lock, allowing no other operation on the DB, because its content will be changing at any time from now. When the "end" or "commit" (or "rollback" to cancel the transaction) is encountered, the write lock is released and other operations can resume. SQLite simply resets the internal autocommit flag for the connection when it encounters the begin of a transaction and sets it back again before the "end" or "commit", which is where all the changes you've made actually occur. An exclusive transaction places an exclusive (write) lock at the beginning of the transaction, contrary to an immediate transaction. Now there is another concept which is the journal mode. Default journal mode allows ONE writer OR many readers concurrently. The WAL journal mode allows ONE writer AND many readers concurrently. But note that WAL mode use memory-mapped file(s) and can't be used at all over a network. You can change the journal mode by a pragma and this setting is persistent for the DB until changed again, if ever. Hope this explains a bit on the transactional machinery.
    1 point
  6. TheDcoder, From the Help file for FileRead (once again you appear not to have read it before posting): If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large files this will be much slower than using filehandles.M23
    1 point
  7. czardas! wow this looks complex yet concise. truly an amazing job. thank you thank you thank you! you have no idea how much this has helped me!
    1 point
  8. Oh sorry, it was a typo. Chr($1) make that ChrW(0x$1)
    1 point
  9. SadBunny

    FileWrite Error

    That loop exits as soon as _StringBetween fails. Didn't you mean to have the loop exit as soon as it succeeds instead? Something like... $attemptCount = 0 Do $attemptCount += 1 If $attemptCount > 1 Then Sleep(1000) Local $sHTML = _IEBodyReadHTML($oIE) $serwer = GUICtrlRead($serwer) $start = "<h2>Swiat " & $serwer & " </h2>" $end = "</p>" Local $aArray = _StringBetween($sHTML, $start, $end) Until IsArray($aArray) ; or: Until @error = 0, or: Until $aArray <> 0 ;If $aArray = 0 Then ; <-- this check isn't necessary any more if you make sure you only reach this point if and when the _StringBetween returned an array MsgBox(0, "", "work") $handle = FileOpen("odbiorcy.txt", 2) FileWrite($handle, $aArray[0]) FileClose($handle) ;EndIf /edit: you may also want to throw a Sleep(1000) in that loop to wait a second between each check. /edit 2: indentation in codebox above is broken for some reason.
    1 point
  10. Try the helpfile for all functions that start with _Excel_ to see everything that can be done with Excel sheets with an out-of-the-box installation of the full AutoIt package. The helpfile comes with fully working example scripts for each and every function. Try StringRegExp and StringInStr for searching a string for certain patterns. StringRegExp and String[Left/Mid/Right] (and more) can help you getting parts from a string. Try the functions starting with Control to interact with controls of your GUI. Yes, this can also be done to work on hidden/non-active/backgrounded/etc. GUIs and/or controls. The helpfile has working example scripts for all of those functions. Good luck!
    1 point
  11. There is something like this maybe in Examples ou GHS which you can use(*). Just realize that there is no guarantee that such an external locking is not failproof unless you carefully implement a guard delay and re-read: 1) PC1 looks for a locking file and waits until it finds none 2) PC1 creates its locking file 3) PC1 waits "some time" : you have zero guarantee that the file created will actually make it on the magnetic surface by the moment you get a successful return of the function, so waiting for "some time" is necessary. How long should that be is a total mystery to me. 4) PC1 looks again for all locking files 5) If there is only the one it created, then it's OK for PC1 to access the DB 6) If PC2 also created its own locking file at approximately the same time, PC1 and PC2 will collaborate to delete the locking file with the most recent timestamp (requires high-definition time, like µs) and proceed accordingly. "Most recent" may be a different point in time than expected, because PCs are not synchronized down to a small fraction of a second. Yet two or more PCs may use the same timestamp even if the probability is low; then some order of priority based on PC name must take force. 7) Some machinery has to deal with dead locking files after a PC leaves a hot one (app crash, power outage, network disruption, whatever). In short: manual file locking is cumbersome and slow as hell at best, prone to errors in all cases. (*) I found that thread: https://www.autoitscript.com/forum/topic/117033-file-locking-with-cooperative-semaphores
    1 point
  12. Hi SadBunny, BINGO!!! it's working. Thank you very much. Also thanks to I3ill. Thank you.
    1 point
  13. $string = "With Viber, everyone in the world can connect. Freely. More than 516 million Viber users text, make HD-quality phone and video calls, and send photo and video messages worldwide over Wifi or 3G - for free.* Viber Out can be used to make calls to non-Viber mobile and landline numbers at low rates. Viber is available for many smartphones and platforms. Viber is compatible with and optimized for Android tablets! Use Viber on your tablet and phone simultaneously.\nOn Viber, your phone number is your ID. The app syncs with your mobile contact list, automatically detecting which of your contacts have Viber. \n\n\u2022 Message your friends\n\u2022 Make free phone and video calls with HD sound quality\n\u2022 Share photos, video messages, voice messages, locations, stickers and emoticons\n\u2022 Download stickers and animated stickers from the Sticker Market; sort and reorder your stickers.\n\u2022 Create group messages with up to 100 participants; become an Admin and manage your group chats \u2013 edit info and delete participants\n\u2022 Follow Public Chats \u2013 get on the inside with your favorite personalities; watch their conversations unfold in real-time, \u2018like\u2019 comments and share multi-media content\n\u2022 Play games with Viber characters, Violet and Legcat; see how many coins you can earn\n\u2022 Android Wear support \u2013 send and receive messages from your watch\n\u2022 Push notifications guarantee that you never miss a message or call, even when Viber is off\n\u2022 Integration with native contact list for calls and messages\n\u2022 Support for the Viber Desktop application on Windows and Mac\n\nLocalized to: Arabic, Catalan, Chinese (SP), Chinese (TR), Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hebrew, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese (BR), Portuguese (PT), Romanian, Russian, Slovak, Spanish, Swedish, Tagalog, Thai, Turkish, Ukrainian and Vietnamese\nViber is completely free with no advertising. \nWe value your privacy. \n\nFollow us for updates and news:\nFacebook - http:\/\/facebook.com\/viber\nTwitter - http:\/\/twitter.com\/viber\n\n(*) Network data charges may apply\n\n\n\n\n\n\n\n\n\n" $string = StringReplace($string, '\n', @CRLF) $string = StringReplace($string, '\/', '/') $string = Execute('"' & StringRegExpReplace($string, '\\u(\d\d\d\d)', '" & Chr($1) & "') & '"')
    1 point
  14. But... But... There's literally an example on that page (the second one) that does a regexp replace with a backreference and writes it to console, it does literally exactly what you ask. All you have to do is drop the pattern and the replace string in the example, fix the escaping in the strings to adhere to C# string escape rules, and run it. I tried it on http://rextester.com/, works like a charm. Took me a few minutes to minutes to put it all together. including the two google searches. Note that I never wrote any C# code ever before in my life. It's really not that hard.
    1 point
  15. You could create a new section of the INI file that holds the tooltip string values you want to use, check to see if a tooltip string is defined and if it is create the tooltips where BrewMan suggested. Of course if you want to use a label instead of applying the tooltip to the check box then you will create it there and apply the tooltip to it. [Checkbox_Labels] 0=Checkbox #1 1=Checkbox #2 2=Checkbox #3 3=Checkbox #4 [Checkbox_States] 0=0x23360DF63FDDE053F89F1864102527EA 1=0x1F6967D2953411A647B876176E99BF4C 2=0x10256744BEA75A6381A2B24B1353728C 3=0xA168136AD9279E110FC818EB08D61A9B [Checkbox_Tooltips] 0= 1=Tooltip Text for Checkbox #2 2=Tooltip Text for Checkbox #3 3=
    1 point
  16. Looks like I added .top when I posted the code. It should be Local $o_Console = $o_IE.document.parentWindow.consoleFor me (Win 8.1 / IE 11) it requires the developer tools to already be open, and the document mode to be 5, 7, or 8. You could automate that with ControlSend() and WinWait() if you wanted.
    1 point
  17. There's not enough code there to give you a good answer, not to mention it isn't runable. I'd need to at least see what is in ReadIni for example, you could put the tooltip command somewhere like this. For $x = 0 To UBound($aCheckboxes) - 1 $aCheckboxes[$x][0] = _CreateCheckbox($aCheckboxes[$x][0], $iX, $iY, ) If _Crypt_HashData($aCheckboxes[$x][0] & "|" & $sINIFile & "|" & $GUI_CHECKED, $CALG_MD5) = $aCheckboxes[$x][1] Then GUICtrlSetState(-1, BitOR($GUI_CHECKED, $GUI_DISABLE)) EndIf $iY += 20 GUICtrlSetTip($aCheckboxes[$x][0], "Some text goes here") Next But I don't know how you'd want to determine which checkboxes need tooltips and which don't, and where you'd get the text for the tooltip. But you can always use an If/Then statement to figure out if you want to apply a tooltip to a particular checkbox.
    1 point
  18. hydranix

    FileWrite Error

    Add error checking to your script, if _StringBetween() returns an error, try repeating the _IEBodyReadHTML() part of the script a couple tomes until _StringBetween() either works or until it has failed a few times and exit the script with your own error stating this.
    1 point
  19. Hello all, this script(wrapper) uses Alternative Data Streams to store INI formatted data in the active executable even while it is running. This is great for standalone executables, or storing data you don't want a user being able to edit! There are four simple commands: Func _iniwrite($section, $key, $value, $stream = "DEFAULT") return IniWrite(@ScriptFullPath&":"&$stream, $section, $key, $value) EndFunc Func _iniread($section, $key, $default = "", $stream = "DEFAULT") return IniRead(@ScriptFullPath&":"&$stream, $section, $key, $default) EndFunc Func _inidelete($section, $key = "", $stream = "DEFAULT") if $key <> "" Then Return IniDelete(@ScriptFullPath&":"&$stream, $section, $key) Else Return IniDelete(@ScriptFullPath&":"&$stream, $section) EndIf EndFunc Func _inirenamesection($section, $newsection, $flag = 0, $stream = "DEFAULT") return IniRenameSection(@ScriptFullPath&":"&$stream, $section, $newsection, $flag) EndFunc Simply copy and paste these functions into your script!
    1 point
  20. http://autoit-script.ru/index.php/topic,12724.15.html #include <WinAPI.au3> #include <Array.au3> $hGui = GUICreate('Test', 400, 300) $iListView = GUICtrlCreateListView('Line |Data', 2, 2, 394, 268) ; $iListView = GUICtrlCreateListView('Line', 2, 2, 394, 268) $hListView = GUICtrlGetHandle(-1) ; $hListView = $iListView For $i = 1 To 1000 GUICtrlCreateListViewItem('Line ' & $i & '|' & Random(1000, 9999, 1), $iListView) ; GUICtrlCreateListViewItem('Line '&$i, $iListView) Next GUISetState() $hTimer = TimerInit() $aReturn = _GUICtrlListView_GetAllTextToArray($hListView) $extended = @extended If @error < 0 Then Exit MsgBox(0, 'Message', 'List empty') $sTime = Round(TimerDiff($hTimer)) & ' ms' ; MsgBox(262144, 'Information', _ ; "Items: " & _WinAPI_LoWord($extended) & @LF & _ ; "Columns: " & _WinAPI_HiWord($extended)) _ArrayDisplay($aReturn, $sTime) Func _GUICtrlListView_GetAllTextToArray($hListView) If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) If Not IsHWnd($hListView) Then Return SetError(1, 0, 0) EndIf Local $hWin, $iItems, $iSubitems $hWin = _WinAPI_GetParent($hListView) If Not $hWin Then Return SetError(2, 0, 0) $iItems = ControlListView($hWin, '', $hListView, 'GetItemCount') If Not $iItems Then Return SetError(-1, 0, 0) $iSubitems = ControlListView($hWin, '', $hListView, 'GetSubItemCount') ; If Not $iSubitems Then Return SetError(-2, 0, 0) If Not $iSubitems Then $iSubitems = 1 Local $aReturn[$iItems][$iSubitems] = [[$iItems]] ; For $i = 0 To $iItems - 1 ; For $j = 0 To $iSubitems - 1 ; $aReturn[$i][$j] = ControlListView($hWin, '', $hListView, 'GetText', $i, $j) ; Next ; Next For $j = 0 To $iSubitems - 1 For $i = 0 To $iItems - 1 $aReturn[$i][$j] = ControlListView($hWin, '', $hListView, 'GetText', $i, $j) Next Next Return SetError(0, _WinAPI_MakeLong($iItems, $iSubitems), $aReturn) EndFunc ;==>_GUICtrlListView_GetAllTextToArray
    1 point
  21. WinGetHandle("") will return the active window's handle.
    1 point
×
×
  • Create New...