Jump to content

Leaderboard

Popular Content

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

  1. rickybobby, Look at #pragma in the Help file. M23
    2 points
  2. FredAI

    Set Acl permissions UDF

    Hi. I've been working on this for a while. I think now it's good enough to post it here. Functions to do most everything with the DACL and ownership on all types of objects: Files or folders, Registry keys, services, Kernel and WMI objects, etc. Here's a good example to test: #include 'Permissions.au3' _InitiatePermissionResources() FileWrite(@ScriptDir&'test.txt','Test') Local $TI = TimerInit() Local $ret = _DenyAllAccess(@ScriptDir&'test.txt',$SE_FILE_OBJECT,@UserName) Local $TD = TimerDiff($TI) MsgBox(0,'','Deny all access to test.txt and take ownership:'&@CRLF&@CRLF& _ '_DenyAllAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _GrantReadAccess(@ScriptDir&'test.txt',$SE_FILE_OBJECT,'Administrators') $TD = TimerDiff($TI) MsgBox(0,'','Grant everyone read access, all access to admins and system, and set the owner: Admins group'&@CRLF&@CRLF& _ '_GrantReadAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _GrantAllAccess(@ScriptDir&'test.txt') $TD = TimerDiff($TI) MsgBox(0,'','Grant everyone access'&@CRLF&@CRLF& _ '_GrantAllAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _CopyFullDacl(@ScriptDir&'test.txt',$SE_FILE_OBJECT,@ScriptDir) $TD = TimerDiff($TI) MsgBox(0,'','Restore all inherited permissions'&@CRLF&@CRLF& _ '_CopyFullDacl return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Local $aPerm[2][3] = [['Restricted',1,$GENERIC_ALL],['Users',1,$GENERIC_ALL]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Add two granted access aces: Restricted and Users'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Dim $aPerm[2][3] = [['Restricted',1,$GENERIC_READ],['Users',1,$GENERIC_READ]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Give only read access to the Restricted and Users groups'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Dim $aPerm[2][3] = [['Restricted',0,$GENERIC_ALL],['Users',0,$GENERIC_ALL]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Deny access to the Restricted and Users groups'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Local $Hndl = _Permissions_OpenProcess(@AutoItPID) Local $SDBefore = _GetObjectStringSecurityDescriptor($Hndl,$SE_KERNEL_OBJECT) Local $CODRet = _ClearObjectDacl($Hndl,$SE_KERNEL_OBJECT) Local $DARet = _DenyAllAccess($Hndl,$SE_KERNEL_OBJECT) Local $SDAfter = _GetObjectStringSecurityDescriptor($Hndl,$SE_KERNEL_OBJECT) $TD = Round(TimerDiff($TI),2) MsgBox(0,'', 'Deny everyone access to the current process:'&@CRLF&@CRLF& _ '@AutoItPID original security descriptor: '&@CRLF&$SDBefore&@CRLF&@CRLF& _ '_ClearObjectDacl return value: '&$CODRet&@CRLF&@CRLF& _ '_DenyAllAccess_ return value: '&$DARet&@CRLF&@CRLF& _ 'New @AutoItPID security descriptor: '&@CRLF& _ $SDAfter&@CRLF&@CRLF& 'Time taken: '&$TD&' miliseconds.') _Permissions_CloseHandle($Hndl) FileDelete(@ScriptDir&'test.txt') _ClosePermissionResources()I'm planning to add functions to deal with the Sacl in the future, even though I don't think it's very important. Edit: Let me know if you need an example for the registry. Updated: Fixed a bug in the _ClearObjectDacl function. I thought that adding a null DACL would work fine, but it causes problems later when adding a new DACL. Those who have downloaded, please update. Shoot! Now it wasn't clearing the DACL at all. Updated again. I think it's fixed now. Updated 9/11/2011 - Added the security descriptor functions and removed unnecessary constants. Updated 10/11/2011 - There were some functions missing in the index, and some parameters in the comments. Also removed the "MustDeclareVars" option. (About 50 total downloads before) Update 12/12/2011 - Added more functions: New Update 12/12/2011 - Missing declaration keywords in 3 constants. Sorry Update 16/12/2011 - Added support for all object types, including window and process handles. Added more functions, modified most of them, and removed one. Here's the new function list: Updated 22/2/2012.. This time I'm including SecurityConstants.au3 and FileConstants.au3 to prevent constants conflicts. Added a few more functions and fixed a few bugs. Also added the ability to include the inherited aces in the _EditObjectPermissions function. Now the permissions array can have four elements (optional). It will still work with three elements arrays though. The fourth element is intended to have the inheritance flag for the corresponding ace. Here's the new list of functions: 400 previous downloads Permissions.au3
    1 point
  3. water

    get information from pdf

    Maybe >this thread helps?
    1 point
  4. JohnQSmith

    Auto update SVN?

    If you're talking about your local checkout, from that folder you will want to run svn update This will update your working copy to match what is on the server. You don't need to check if your working copy and the server have matching versions as the update command will either update your checkout or do nothing if you're already at the same HEAD revision as the server.
    1 point
  5. You could also look at the source code for >MacroGamer which uses a method that times delays between keystrokes. Bear in mind, that code uses a lot of older includes that don't exist any longer and probably won't run as-is, but it can give you some ideas.
    1 point
  6. Arkinden, Do you mean the BackSpace button? Send("{BACKSPACE}") ; or (and I really like this abbreviation as it reminds me so much of "Chat"!) Send("{BS}") M23
    1 point
  7. JohnOne, I have several methods to do this - but most would fall foul of the "no keylogger" rule and so will remain on my hard drive! The best I ever managed which was did not break the rules is in this script - which is far from perfect. M23
    1 point
  8. Or use: #AutoIt3Wrapper_Res_ProductVersion=2.1
    1 point
  9. BOycaonguyen88, Use the new #pragma directive: #pragma compile(ProductVersion, 2.1) M23
    1 point
  10. Melba23

    OnEvent mode benefits?

    Prime03, Glad you found that tutorial useful - there are lots of others in the Wiki to discover. M23
    1 point
  11. Melba23

    OnEvent mode benefits?

    BrewmanNH, It has since I started using AutoIt. SlowCoder74, In the main script, as far as I am concerned, practically never - look at the Interrupting a running function tutorial in the Wiki to see one time it might be. But I often run the tray menu in TrayOnEvent mode. M23
    1 point
  12. gil900, You cannot save the timing in a wav header - there is nowhere to put it. What you will have to do is get the timing from the mp3 section of the resource before you play it. Anyway I have been having fun today with this! Here is my version of a script to convert an mp3 file to a hybrid wav fileL ; Basic wav header blocks $sHdr_1 = "0x52494646" $sHdr_2 = "57415645666D74201E0000005500020044AC0000581B0000010000000C00010002000000B600010071056661637404000000640E060064617461" $sAlign_Buffer = "00" ; Select mp3 file $sFile = FileOpenDialog("Select mp3 file to convert", @ScriptDir, "mp3 (*.mp3)") If Not $sFile Then Exit ; Read mp3 file $sMp3 = StringTrimLeft(Binary(FileRead($sFile)), 2) $iMp3Size = StringLen($sMp3) ; Get file size $iFileSize = FileGetSize($sFile) ; Convert to required format $iMp3Size = StringRegExpReplace(Hex($iFileSize, 8), "(..)(..)(..)(..)", "$4$3$2$1") $iWavSize = StringRegExpReplace(Hex($iFileSize + 63, 8), "(..)(..)(..)(..)", "$4$3$2$1") ; Construct hybrid wav file $sHybridWav = $sHdr_1 & $iWavSize & $sHdr_2 & $iMp3Size & $sMp3 If Mod($iMp3Size, 2) Then $sHybridWav &= $sAlign_Buffer EndIf ; Save new file $sFile = FileSaveDialog("Select filename for new file", @ScriptDir, "wav (*.wav)") If Not $sFile Then Exit $hFile = FileOpen($sFile, 2 + 16) FileWrite($hFile, $sHybridWav) FileClose($hFile) It will take any mp3 file - even one with an ID3 tag - and convert it to a hybrid wav file by adding a valid wav header (and padding the file by one byte if required). A valid wav header contains sizing data and so needs to be calculated for each file - you cannot just add the same string to every mp3. And then I developed this script to play the hybrid wav file from the resource table - reading the timing from the file itself: #AutoIt3Wrapper_Res_File_Add=Sound.wav, RT_RCDATA, SOUND #include <Date.au3> #include <Resources.au3> _Play_Resource_Sound("SOUND") Func _Play_Resource_Sound($sName) ; Read resource into memory $pResPointer = _ResourceGet($sName) $iResSize = @extended $tResStruct = DllStructCreate("byte[" & $iResSize & "]", $pResPointer) $sSound = DllStructGetData($tResStruct, 1) ; Calculate CBR timing $iTrackLen_CBR = _CBR_Timing(StringLeft($sSound, 5120), $iResSize) $iBitrate = @extended ; Look for VBR timing $iTrackLen_VBR = _VBR_Timing(StringLeft($sSound, 5120)) ; Play sound Local $SND_NODEFAULT = 2 Local $iFlag = BitOR($SND_MEMORY, $SND_ASYNC, $SND_NODEFAULT) DllCall("winmm.dll", "int", "sndPlaySound", "ptr", $pResPointer, "UINT", $iFlag) ; Show results If $iTrackLen_VBR = 0 Then MsgBox(0, "CBR", _Convert_Timing($iTrackLen_CBR) & @CRLF & $iBitrate & " - " & Hex($iBitrate * 100, 8)) Else MsgBox(0, "VBR", _Convert_Timing($iTrackLen_VBR) & @CRLF & $iBitrate & " - " & Hex($iBitrate * 100, 8)) EndIf EndFunc ;==>_Play_Resource_Sound Func _Convert_Timing($iMs) Local $iHours, $iMins, $iSecs _TicksToTime($iMs, $iHours, $iMins, $iSecs) Return StringFormat("%02i:%02i:%02i", $iHours, $iMins, $iSecs) EndFunc ;==>_Convert_Timing Func _CBR_Timing($sSound, $iResSize) ; Look for start of MP3 header Local $iMP3_Start = StringInStr($sSound, "FFF") If Not $iMP3_Start Then Return SetError(1, 0, 0) EndIf Local $sSound_Header = StringMid($sSound, $iMP3_Start, 8) ; Create look up table (this is only filled for MPEG-1 layer III) Local $aBit_Table[14] = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320] ; Look up bitrate $iBitrate = $aBit_Table[Number("0x" & StringMid($sSound_Header, 5, 1)) - 1] ; Length in ms Return SetExtended($iBitrate, Int($iResSize * 8 / $iBitrate)) EndFunc ;==>_CBR_Timing Func _VBR_Timing($sTag) Local $iXingPos = StringInStr($sTag, "58696E67") ; Xing If Not $iXingPos Then Return SetError(1, 0, 0) EndIf ; Read fields flag Local $iFrames, $iFlags = Number("0x" & StringMid($sTag, $iXingPos + 14, 2)) If BitAND($iFlags, 1) = 1 Then $iFrames = Number("0x" & StringMid($sTag, $iXingPos + 16, 8)) Else Return SetError(1, 0, 0); No frames field EndIf ; Now to find Samples per frame & Sampling rate ; Go back to the frame header start Local $sHeader = StringMid($sTag, $iXingPos - 72, 8) ; Read the relevant bytes Local $iMPEGByte = Number("0x" & StringMid($sHeader, 4, 1)) Local $iFreqByte = Number("0x" & StringMid($sHeader, 6, 1)) ; Decode them ; 8 = MPEG-1, 0 = MPEG-2 Local $iMPEGVer = BitAND($iMPEGByte, 8) ; 2 = Layer III, 4 = Layer II, 6 = Layer I Local $iLayerNum = BitAND($iMPEGByte, 6) Local $iSamples Switch $iLayerNum Case 6 $iSamples = 384 Case 4 $iSamples = 1152 Case 2 Switch $iMPEGVer Case 8 $iSamples = 1152 Case 0 $iSamples = 576 Case Else $iSamples = 0 EndSwitch Case Else $iSamples = 0 EndSwitch ; If not valid return If $iSamples = 0 Then Return SetError(1, 0, 0) ; 0 = bit 00, 4 = Bit 01, 8 = Bit 10 Local $iFrequency, $iFreqNum = BitAND($iFreqByte, 12) Switch $iFreqNum Case 0 $iFrequency = 44100 Case 4 $iFrequency = 48000 Case 8 $iFrequency = 32000 Case Else $iFrequency = 0 EndSwitch ; If not valid return If $iFrequency = 0 Then Return SetError(1, 0, 0) ; MPEG-2 halves the value If $iMPEGVer = 0 Then $iFrequency = $iFrequency / 2 ; Duration in ms = No of frames * Samples per frame / Sampling freq * 1000 Return Int(($iFrames * $iSamples / $iFrequency) * 1000) EndFunc ;==>_VBR_Timing Do not cancel the MsgBox if you want to verify the duration as the sound will stop immediately! Looking forward to some feedback. M23
    1 point
  13. Exactly what I would have suggested
    1 point
  14. Why don't you try exploring the UDF and make the changes yourself? Water gave you a great head start. Just go through it step by step.
    1 point
  15. Thanks you for your message, I'm glad FastFind prove to be useful :-)
    1 point
  16. It's been a while since I've been back to check this thread, but I'm still using this library in almost every au3 project I do. Despite occasional bugs, it saves me so much work, and makes my scripts MUCH faster. I've downloaded a copy of your source from github and will try making sense of it if I find the time and motivation. Thanks for your contribution, it's much appreciated!
    1 point
  17. Danp2

    FF.au3 (V0.6.0.1b-10)

    This is your issue. Try opening and saving the file with a different encoding method.
    1 point
  18. Here is a half a$$ script I wrote to check ff and mozrepl status (it is only reliable if firefox.exe is installed in default location). I just use "get status" button. Hope it is helpful to you. #Region ;************ Includes ************ #include <GUIConstantsEx.au3> #include <Misc.au3> #include <GuiEdit.au3> #include <File.au3> #include <WinAPIEx.au3> #include <APIConstants.au3> #EndRegion ;************ Includes ************ If _Singleton("Mozrepl Manager.exe", 1) = 0 Then MsgBox(0, "Mozrepl Manager is already running! ", " Using multiple copies of this script is unsupported! ") Exit EndIf Opt("MustDeclareVars", 1) Opt("TrayIconDebug", 1) HotKeySet("{END}", "__MyExit") Global $MSG Global $FireFoxInst = False, $FMOZREPLINST = False, $FMOZREPAUTOSTART = False Global $HMAINGUI = GUICreate("Mozrepl Manager", 540, 150, -1, -1) Global $ECONSOLE = GUICtrlCreateEdit("", 1, 30, 540, 120, -1) GUICtrlSetFont(-1, 10) Global $BREPLSTATUS = GUICtrlCreateButton("Get Status", 4, 4, 60, 20) Global $BINSTALLMOZREPL = GUICtrlCreateButton("Install Mozrepl", 68, 4, 74, 20) Global $BFIREFOXSTATUS = GUICtrlCreateButton("Firefox Exists", 146, 4, 70, 20) GUISetState() $FireFoxInst = __FIREFOXEXISTS() While 1 $MSG = GUIGetMsg(1) Select Case $MSG[0] = $GUI_EVENT_CLOSE And $MSG[1] = $HMAINGUI __MYEXIT() Case $MSG[0] = $BREPLSTATUS And $MSG[1] = $HMAINGUI __REPLSTATUS() Case $MSG[0] = $BINSTALLMOZREPL And $MSG[1] = $HMAINGUI __INSTALLMOZREPL() Case $MSG[0] = $BFIREFOXSTATUS And $MSG[1] = $HMAINGUI __FIREFOXEXISTS() EndSelect WEnd Func __INSTALLMOZREPL() ShellExecute("https://addons.mozilla.org/firefox/downloads/file/205776/mozrepl-1.1.2-fx.xpi?src=dp-btn-primary", "", "", "open") EndFunc ;==>__INSTALLMOZREPL Func __REPLSTATUS() Local $AFILELIST, $LISTERROR, $RETURN, $VAR, $BOOL If Not $FireFoxInst = True Then _GUICtrlEdit_AppendText($ECONSOLE, " Firefox is not installed at the directory: " & @AppDataDir & "\Mozilla" & @CRLF) _GUICtrlEdit_AppendText($ECONSOLE, " First install Firefox" & @CRLF & " This program only supports Firefox installed on your boot drive" & @CRLF) Return EndIf Local $DEFAULTNAME, $ARR = _FileListToArray(@AppDataDir & "\Mozilla\Firefox\Profiles", "*", 2) If IsArray($ARR) Then For $I = 1 To $ARR[0] $VAR = StringInStr($ARR[$I], ".default") If $VAR > 0 Then $DEFAULTNAME = $ARR[$I] _GUICtrlEdit_AppendText($ECONSOLE, "Found default profile folder" & @CRLF & "Default Profile: " & $DEFAULTNAME & @CRLF) ExitLoop EndIf Next EndIf _GUICtrlEdit_AppendText($ECONSOLE, "Searching " & @AppDataDir & "\Mozilla\Firefox\Profiles\" & $DEFAULTNAME & " for prefs.js" & @CRLF) $ARR = _FileListToArray(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $DEFAULTNAME, "prefs.js") Local $PREFFILE If IsArray($ARR) Then For $I = 1 To $ARR[0] If $ARR[$I] = "prefs.js" Then _GUICtrlEdit_AppendText($ECONSOLE, "Found prefs.js" & @CRLF) $PREFFILE = $ARR[$I] ExitLoop EndIf Next If Not $PREFFILE = "prefs.js" Then _GUICtrlEdit_AppendText($ECONSOLE, "prefs.js not found. You will have to install The Mozrepl Addon with Firefox." & @CRLF) Return EndIf EndIf $VAR = _FileReadToArray(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $DEFAULTNAME & "\" & $PREFFILE, $ARR) If $VAR = 0 Then If @error = 1 Then _GUICtrlEdit_AppendText($ECONSOLE, " Error opening prefs.js" & @CRLF) If @error = 2 Then _GUICtrlEdit_AppendText($ECONSOLE, " Error reading prefs.js" & @CRLF) Return EndIf If IsArray($ARR) Then Local $STRING _GUICtrlEdit_AppendText($ECONSOLE, "Checking if Mozrepl is installed" & @CRLF) $VAR = "" For $I = 1 To $ARR[0] $VAR = StringInStr($ARR[$I], "mozrepl") If $VAR > 0 Then $FMOZREPLINST = True _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl is installed already" & @CRLF) For $J = 1 To $ARR[0] $STRING = StringInStr($ARR[$J], 'user_pref("extensions.mozrepl.autoStart", true);') If $STRING > 0 Then $FMOZREPAUTOSTART = True _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl is already set to auto start" & @CRLF) Return EndIf Next If $STRING = 0 Then $FMOZREPAUTOSTART = False _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl is not set to auto start" & @CRLF) Local $FILE = FileOpen(@AppDataDir & "\Mozilla\Firefox\Profiles\" & $DEFAULTNAME & "\" & $PREFFILE, 1) If Not $FILE > -1 Then $BOOL = FileWrite($FILE, 'user_pref("extensions.mozrepl.autoStart", true);') If $BOOL = 1 Then $FMOZREPAUTOSTART = True _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl is now set to auto start" & @CRLF) Return EndIf Else _GUICtrlEdit_AppendText($ECONSOLE, "Error occurred trying to open prefs.js" & @CRLF) _GUICtrlEdit_AppendText($ECONSOLE, "Alternately, you could open Firefox/Tools/Mozrepl then select activate on start up." & @CRLF) Return EndIf EndIf ExitLoop EndIf Next If $VAR = 0 Then $FMOZREPLINST = False _GUICtrlEdit_AppendText($ECONSOLE, "Mozrepl not found" & @CRLF) EndIf EndIf EndFunc ;==>__REPLSTATUS Func __FIREFOXEXISTS() Local $VAR = DirGetSize(@AppDataDir & "\Mozilla\Firefox", 3) If $VAR = -1 And @error = 1 Then _GUICtrlEdit_AppendText($ECONSOLE, " Firefox is not installed at the directory: " & @AppDataDir & "\Mozilla" & @CRLF) _GUICtrlEdit_AppendText($ECONSOLE, " First install Firefox" & @CRLF & " This program only supports Firefox installed on your boot drive" & @CRLF) $FireFoxInst = False Return $FireFoxInst EndIf If $VAR >= 0 Then _GUICtrlEdit_AppendText($ECONSOLE, "Firefox is installed at the directory: " & @AppDataDir & "\Mozilla\Firefox" & @CRLF) $FireFoxInst = True Return $FireFoxInst EndIf EndFunc ;==>__FIREFOXEXISTS Func __MYEXIT() GUIDelete($HMAINGUI) Exit EndFunc ;==>__MYEXIT
    1 point
  19. Instead of creating a new topic I chose to post here. This way we may be able to gather the necessary code to demonstrate all the personalizations in a single ListView. Edit in Place isn't for now one of the things I need or have in mind for my current project. One awesome example: And this example that I remember seeing working in the past, but now the code is outdated; haven't looked at it in a while: As for the multiline, I found a trick: Display multiline content with fly-over tooltips: It does what it says, but it's not very helpful (visually) and it's a bit annoying. I have an idea, though. I just need a little help: #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;#include <APIConstants.au3> #include <WinAPIEx.au3> ; from http://www.autoitscript.com/forum/topic/98712-winapiex-udf/ Global Const $ODT_LISTVIEW = 102 Global Const $ODA_DRAWENTIRE = 0x1 ; #################################### ; adjustment of the icon positioning, according to windows version Global $iAdjustV = 0 If $__WINVER > 0x0600 Then $iAdjustV = 1 ; $__WINVER defined in WinAPIEx, $__WINVER > 0x0600 means Vista+ ; #################################### ; WM_MEASUREITEM allows setting the row height Global $iListView_row_height = 50 GUIRegisterMsg($WM_MEASUREITEM, "WM_MEASUREITEM") ; place before listview creation - message sent once for each ownerdrawn control created ;GUIRegisterMsg($WM_MEASUREITEM, "") ; call this after last ownerdrawn listview created ; --------------------------------------------------- _GDIPlus_Startup() $hGUI = GUICreate("ListView Set Item State", 700, 300) $cButton_CheckAll = GUICtrlCreateButton("Check All", 10, 275, 100, 20) $cButton_UncheckAll = GUICtrlCreateButton("UnCheck All", 120, 275, 100, 20) $cButton_StatesToArray = GUICtrlCreateButton("States to Array", 230, 275, 100, 20) ; listview 1 ----------------------------------------------- $iListView_row_height = 25 $cListView = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_REPORT, $LVS_OWNERDRAWFIXED, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL)) GUICtrlSetFont(-1, 11, 400, 0, "Calibri", 5) $hListView = GUICtrlGetHandle($cListView) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES)) $hIml_Listview = _GUIImageList_Create(16, 16, 5, 3) $hBitmap_Icon = _Load_BMP_From_Mem(_Icon_Image_Checkbox_Unchecked(), True) _GUIImageList_Add($hIml_Listview, $hBitmap_Icon) _WinAPI_DeleteObject($hBitmap_Icon) $hBitmap_Icon = _Load_BMP_From_Mem(_Icon_Image_Checkbox_Checked(), True) _GUIImageList_Add($hIml_Listview, $hBitmap_Icon) _WinAPI_DeleteObject($hBitmap_Icon) ; ########################################################## ; this "breaks" WM_MEASUREITEM ;_GUICtrlListView_SetImageList($hListView, $hIml_Listview, 1) ; why do we need this anyway? ; ########################################################## ; Add columns _GUICtrlListView_AddColumn($hListView, " ", 0) For $i = 1 To 3 _GUICtrlListView_AddColumn($hListView, "Column " & $i, 100) Next Local $aItems[30][4] For $row = 1 To 30 $aItems[$row-1][0] = "this won't show up" $aItems[$row-1][1] = "Row " & $row & ": Col 1" $aItems[$row-1][2] = "Row " & $row & ": Col 2" $aItems[$row-1][3] = "Row " & $row & ": Col 3" Next ; if you add items via _GUICtrlListView_AddArray(), the drawing will become unstable. ; also, the checkboxes don't appear unless you click their respective subitem. _GUICtrlListView_DeleteAllItems($hListView) ;_GUICtrlListView_AddArray($hListView, $aItems) __GUI_ListView_Add_Array($hListView, $aItems) ; workaround ; ----------------------------------------------------------- ; listview 2 ----------------------------------------------- $iListView_row_height = 40 $cListView_2 = GUICtrlCreateListView("", 400, 2, 298, 268, BitOR($LVS_REPORT, $LVS_OWNERDRAWFIXED, $LVS_SHOWSELALWAYS)) GUICtrlSetFont(-1, 11, 400, 0, "Calibri", 5) $hListView_2 = GUICtrlGetHandle($cListView_2) _GUICtrlListView_SetExtendedListViewStyle($hListView_2, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) ; Add columns For $i = 1 To 3 _GUICtrlListView_AddColumn($hListView_2, "2 - Column " & $i, 90) Next ; Add items For $row = 1 To 20 _GUICtrlListView_AddItem($hListView_2, "Row " & $row & ": Col 0", 0) _GUICtrlListView_AddSubItem($hListView_2, $row - 1, "Row " & $row & ", resize me!" & @CRLF & "-----------Col 1", 1, 0) If $row <> 3 Then _GUICtrlListView_AddSubItem($hListView_2, $row - 1, "Row " & $row & ": Col 2", 2, 0) Else ; if you comment the line below and click+drag to resize this ListView's columns, the drawing will become unstable _GUICtrlListView_AddSubItem($hListView_2, $row - 1, "", 2, 0) EndIf Next ; ----------------------------------------------------------- GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM") GUISetState() ; Loop until user exits While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cButton_CheckAll _LV_ImgCheckboxes_CheckAll($hListView) Case $cButton_UncheckAll _LV_ImgCheckboxes_UncheckAll($hListView) Case $cButton_StatesToArray $aLVStates = _LV_ImgCheckboxes_StatesToArray($hListView) _ArrayDisplay($aLVStates) EndSwitch WEnd GUIDelete() _GUIImageList_Destroy($hIml_Listview) _GDIPlus_Shutdown() Exit Func _LV_ImgCheckboxes_CheckAll($hWnd) _GUICtrlListView_BeginUpdate($hWnd) For $i = 0 To _GUICtrlListView_GetItemCount($hWnd) - 1 For $y = 0 To _GUICtrlListView_GetColumnCount($hWnd) - 1 _GUICtrlListView_SetItemImage($hWnd, $i, 1, $y) Next Next _GUICtrlListView_EndUpdate($hWnd) EndFunc ;==>_LV_ImgCheckboxes_CheckAll Func _LV_ImgCheckboxes_UncheckAll($hWnd) _GUICtrlListView_BeginUpdate($hWnd) For $i = 0 To _GUICtrlListView_GetItemCount($hWnd) - 1 For $y = 0 To _GUICtrlListView_GetColumnCount($hWnd) - 1 _GUICtrlListView_SetItemImage($hWnd, $i, 0, $y) Next Next _GUICtrlListView_EndUpdate($hWnd) EndFunc ;==>_LV_ImgCheckboxes_UncheckAll Func _LV_ImgCheckboxes_StatesToArray($hWnd) Local $iColumns = _GUICtrlListView_GetColumnCount($hWnd) If $iColumns = 0 Then Return SetError(1) Local $iItems = _GUICtrlListView_GetItemCount($hWnd) If $iItems = 0 Then Return SetError(2) Local $aStates[$iItems][$iColumns] For $i = 0 To $iItems - 1 For $y = 0 To $iColumns - 1 $aStates[$i][$y] = _GUICtrlListView_GetItemImage($hWnd, $i, $y) Next Next Return $aStates EndFunc ;==>_LV_ImgCheckboxes_StatesToArray Func __GUI_ListView_Add_Array($hListView, ByRef $array) If Not IsArray($array) Then Return SetError(1, 0, 0) ; not an array Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView) ; if the number of columns between the array and the listview doesn't match: If UBound($array,2) <> $iColumnCount Then Return SetError(3, 1, 0) Switch UBound($array, 0) Case 1 ; 1-dimensioned array _GUICtrlListView_BeginUpdate($hListView) For $r = 0 To UBound($array, 1) - 1 _GUICtrlListView_AddItem($hListView, $array[$r], 0) Next _GUICtrlListView_EndUpdate($hListView) Case 2 ; 2-dimensioned array _GUICtrlListView_BeginUpdate($hListView) Local $first_row For $r = 0 To UBound($array, 1) - 1 If $r = 0 Then $first_row = _GUICtrlListView_AddItem($hListView, $array[$r][0], 0) Else _GUICtrlListView_AddItem($hListView, $array[$r][0], 0) EndIf Next For $r = 0 To UBound($array, 1) - 1 For $c = 1 To UBound($array, 2) - 1 _GUICtrlListView_AddSubItem($hListView, $first_row + $r, $array[$r][$c], $c, 0) Next Next _GUICtrlListView_EndUpdate($hListView) Case Else Return SetError(2, 0, 0) ; invalid array (over 2 dimensions) EndSwitch Return EndFunc Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") Local $nNotifyCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $nNotifyCode Case $NM_CLICK Local $tINFO = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $iItem = DllStructGetData($tINFO, "Index") Local $iSubitem = DllStructGetData($tINFO, "SubItem") If $iSubitem == 2 And StringLen(_GUICtrlListView_GetItemText($hListView, $iItem, $iSubitem)) > 0 Then ;ConsoleWrite("painting row "&$iItem+1&" col "&$iSubitem+1&@CRLF) _GUICtrlListView_SetItemImage($hListView, $iItem, Not _GUICtrlListView_GetItemImage($hListView, $iItem, $iSubitem), $iSubitem) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) Local $tagDRAWITEMSTRUCT, $iBrushColor, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC $timer = TimerInit() $tagDRAWITEMSTRUCT = DllStructCreate( _ "uint cType;" & _ "uint cID;" & _ "uint itmID;" & _ "uint itmAction;" & _ "uint itmState;" & _ "hwnd hItm;" & _ "hwnd hDC;" & _ "int itmRect[4];" & _ "dword itmData" _ , $lParam) If DllStructGetData($tagDRAWITEMSTRUCT, "cType") <> $ODT_LISTVIEW Then Return $GUI_RUNDEFMSG $cID = DllStructGetData($tagDRAWITEMSTRUCT, "cID") $itmID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID") $itmAction = DllStructGetData($tagDRAWITEMSTRUCT, "itmAction") $itmState = DllStructGetData($tagDRAWITEMSTRUCT, "itmState") $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm") $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC") Local $aDefaultVariables[9] = [$tagDRAWITEMSTRUCT, $iBrushColor, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC] Switch $cID ; will look for ControlID, not window handle. Case $cListView Switch $itmAction Case $ODA_DRAWENTIRE Local $aRowColors[2] = [0xFDFDFD, 0xEEDDBB] Local $aRectMargins[4] = [6, -1, -4, 0] Local $aTextFormatting[5] = [-1, _ BitOR($DT_VCENTER, $DT_SINGLELINE, $DT_CENTER, $DT_END_ELLIPSIS), _ BitOR($DT_VCENTER, $DT_SINGLELINE, $DT_CENTER, $DT_END_ELLIPSIS), _ BitOR($DT_VCENTER, $DT_SINGLELINE, $DT_RIGHT, $DT_END_ELLIPSIS), _ BitOR($DT_VCENTER, $DT_SINGLELINE, $DT_END_ELLIPSIS)] __WM_DRAWITEM_ListView($hListView, $aDefaultVariables, $aRowColors, $aRectMargins, $aTextFormatting) ; end case EndSwitch ; end case Case $cListView_2 Switch $itmAction Case $ODA_DRAWENTIRE Local $aRowColors[2] = [0xFDFDFD, 0x00FFFF] Local $aRectMargins[4] = [6, -1, 0, 0] Local $aTextFormatting[3] = [BitOR($DT_VCENTER, $DT_SINGLELINE), _ BitOR($DT_EDITCONTROL, $DT_WORDBREAK), _ BitOR($DT_VCENTER, $DT_SINGLELINE)] __WM_DRAWITEM_ListView($hListView_2, $aDefaultVariables, $aRowColors, $aRectMargins, $aTextFormatting) ; end case EndSwitch ; end case EndSwitch ConsoleWrite(Round(TimerDiff($timer),2) & @TAB & "WM_DRAWITEM" & @CRLF) Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM Func __WM_DRAWITEM_ListView($hListView, ByRef $aDefaultVariables, ByRef $aRowColors, ByRef $aRectMargins, ByRef $aTextFormatting) Local $iSubItemCount = _GUICtrlListView_GetColumnCount($hListView) If UBound($aTextFormatting) < $iSubItemCount Then ConsoleWrite("!> Error: invalid parameters in __WM_DRAWITEM_ListView()" & @CRLF) Return EndIf Local $tagDRAWITEMSTRUCT, $iBrushColor, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC $tagDRAWITEMSTRUCT = $aDefaultVariables[0] $iBrushColor = $aDefaultVariables[1] $cID = $aDefaultVariables[2] $itmID = $aDefaultVariables[3] $itmAction = $aDefaultVariables[4] $itmState = $aDefaultVariables[5] $hItm = $aDefaultVariables[6] $hDC = $aDefaultVariables[7] If _GUICtrlListView_GetItemSelected($hListView, $itmID) Then $iBrushColor = $aRowColors[1] Else $iBrushColor = $aRowColors[0] EndIf ; create a brush with the desired color: Local $aBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $iBrushColor) ; get the rectangle for the whole row and fill it: Local $iLeft = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) DllStructSetData($tagDRAWITEMSTRUCT, "itmRect", $iLeft + 0, 1) ; +0 is the left margin _WinAPI_FillRect($hDC, DllStructGetPtr($tagDRAWITEMSTRUCT, "itmRect"), $aBrush[0]) ; draw the text in each subitem For $i = 0 To $iSubItemCount - 1 ; get subitem text: Local $iSubItmText = _GUICtrlListView_GetItemText($hListView, $itmID, $i) ; get subitem coordinates for drawing its respective text: Local $aSubItmRect = _GUICtrlListView_GetSubItemRect($hListView, $itmID, $i) ; the function above accepts not only subitems (one-based index), but also main item (index=0) ; pass the coordinates to a DLL struct: Local $iSubItmRect = DllStructCreate("int Left;int Top;int Right;int Bottom") DllStructSetData($iSubItmRect, 1, $aSubItmRect[0] + $aRectMargins[0]) ; left margin DllStructSetData($iSubItmRect, 2, $aSubItmRect[1] + $aRectMargins[1]) ; upper margin DllStructSetData($iSubItmRect, 3, $aSubItmRect[2] + $aRectMargins[2]) ; right margin DllStructSetData($iSubItmRect, 4, $aSubItmRect[3] + $aRectMargins[3]) ; bottom margin Local $tRect = DllStructGetPtr($iSubItmRect) ;#cs If $cID == $cListView And StringLen($iSubItmText) > 0 And $aTextFormatting[$i] <> - 1 Then Local $hIcon = _GUIImageList_GetIcon($hIml_Listview, _GUICtrlListView_GetItemImage($hListView, $itmID, $i)) If $i = 0 Then ; the first column of a listview needs more handling than the other columns (sub-items) #cs ; positioning for the icon: DllStructSetData($iSubItmRect, "Left", DllStructGetData($iSubItmRect, "Left") + 12) _WinAPI_DrawIconEx($hDC, DllStructGetData($iSubItmRect, "Left") - 16, Int((DllStructGetData($iSubItmRect, "Bottom") + DllStructGetData($iSubItmRect, "Top") - 16)/2) + $iAdjustV, $hIcon, 16, 16) ; positioning for the text: DllStructSetData($iSubItmRect, "Left", DllStructGetData($iSubItmRect, "Left") + 4) #ce ElseIf $i == 2 Then _WinAPI_DrawIconEx($hDC, DllStructGetData($iSubItmRect, "Left"), Int((DllStructGetData($iSubItmRect, "Bottom") + DllStructGetData($iSubItmRect, "Top") - 16) / 2) - 1 + $iAdjustV, $hIcon, 16, 16) ; positioning for the text: DllStructSetData($iSubItmRect, "Left", DllStructGetData($iSubItmRect, "Left") + 20) EndIf _GUIImageList_DestroyIcon($hIcon) EndIf ;#ce If $aTextFormatting[$i] = -1 Then ; do nothing (don't draw any text) Else _WinAPI_DrawText($hDC, $iSubItmText, $tRect, $aTextFormatting[$i]) EndIf Next EndFunc ;==>__WM_DRAWITEM_ListView Func WM_MEASUREITEM($hWnd, $Msg, $wParam, $lParam) Local $tMEASUREITEMS = DllStructCreate("uint cType;uint cID;uint itmID;uint itmW;uint itmH;ulong_ptr itmData", $lParam) If DllStructGetData($tMEASUREITEMS, "cType") <> $ODT_LISTVIEW Then Return $GUI_RUNDEFMSG DllStructSetData($tMEASUREITEMS, "itmH", $iListView_row_height) ; row height Return 1 EndFunc ;==>WM_MEASUREITEM ; Based on File to Base64 String Code Generator ; by UEZ ; http://www.autoitscript.com/forum/topic/...ng-code-generator-v103-build-2 ;====================================================================================== ; Function Name: Load_BMP_From_Mem ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap ; ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+ ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created ; ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown() ; ; Requirement(s): GDIPlus.au3, Memory.au3 and _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format), ; Error: 0 ; Error codes: 1: $bImage is not a binary string ; 2: unable to create stream on HGlobal ; 3: unable to create bitmap from stream ; ; Author(s): UEZ ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and ; Yashied for _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Version: v0.97 Build 2012-01-04 Beta ;======================================================================================= Func _Load_BMP_From_Mem($bImage, $hHBITMAP = False) If Not IsBinary($bImage) Then Return SetError(1, 0, 0) Local $aResult Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary Local Const $len = BinaryLen($memBitmap) ;get length of image Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002) Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents If @error Then SetError(2, 0, 0) Local Const $hStream = $aResult[3] $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface If @error Then SetError(3, 0, 0) Local Const $hBitmap = $aResult[2] Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _ "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak $tMem = 0 $tVARIANT = 0 If $hHBITMAP Then Local Const $hHBmp = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>_Load_BMP_From_Mem Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) Local $tBIHDR, $Ret, $tData, $pBits, $hResult = 0 $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0) If (@error) Or ($Ret[0]) Then Return 0 $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $Ret[2], $Ret[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) $pBits = DllStructGetData($tData, 'Scan0') If Not $pBits Then Return 0 $tBIHDR = DllStructCreate('dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword') DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, 2, $Ret[2]) DllStructSetData($tBIHDR, 3, $Ret[3]) DllStructSetData($tBIHDR, 4, 1) DllStructSetData($tBIHDR, 5, 32) DllStructSetData($tBIHDR, 6, 0) $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0) If (Not @error) And ($hResult[0]) Then DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $Ret[2] * $Ret[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0')) $hResult = $hResult[0] Else $hResult = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmap, $tData) Return $hResult EndFunc ;==>_GDIPlus_BitmapCreateDIBFromBitmap Func _Decompress_Binary_String_to_Bitmap($Base64String) $Base64String = Binary($Base64String) Local $iSize_Source = BinaryLen($Base64String) Local $pBuffer_Source = _WinAPI_CreateBuffer($iSize_Source) DllStructSetData(DllStructCreate('byte[' & $iSize_Source & ']', $pBuffer_Source), 1, $Base64String) Local $pBuffer_Decompress = _WinAPI_CreateBuffer(8388608) Local $Size_Decompressed = _WinAPI_DecompressBuffer($pBuffer_Decompress, 8388608, $pBuffer_Source, $iSize_Source) Local $b_Result = Binary(DllStructGetData(DllStructCreate('byte[' & $Size_Decompressed & ']', $pBuffer_Decompress), 1)) _WinAPI_FreeMemory($pBuffer_Source) _WinAPI_FreeMemory($pBuffer_Decompress) Return $b_Result EndFunc ;==>_Decompress_Binary_String_to_Bitmap Func _Icon_Image_Checkbox_Unchecked() Local $Base64String $Base64String &= '7rBIAAABABAQEAFwCAAAaAUAABYAAMwAKAAYAJAAIAAYAVwZAQBAAQIYDgCAgAAAANfc3ADZ3t4AANvg4ADe4uIAAOLl5QDl6OgAAOns7ADs7+8AAO/x8QDx8/MAAPT19QD29/cAAPj5+QD6+/sAAPz9/QD+/v7wAP///xNc/wB/AD8A/z8APwA/AD8APwA/AD8ACAAb4HYLAAEJAOEBCgsMAA0ODxAREhISbeIBCQcC4gEIBwLiAQfbBwLiAQYHAuIBBQcC4gG2BAcC4gEDBwLiAQIHAv/jAQcC5AEGAuIB7BceAOCfHgN/AG0A4QZhAA==' Return _Decompress_Binary_String_to_Bitmap(_Base64Decode($Base64String)) EndFunc ;==>_Icon_Image_Checkbox_Unchecked Func _Icon_Image_Checkbox_Checked() Local $Base64String $Base64String &= 'z7BIAAABABAQEAFwCAAAaAUAABYAAMwAKAAYAJAAIAAYAVwZAQBAAQIYDgCAgAAAAISEhADe3t5AAN7n5wDnAQbvCO8A7wEG9/cA9/EABv///xN4/wE/AD8A/z8APwA/AD8AHwAMAOB6CwAGAQkA4QEHCAkJCR4KAgDjAQcC5AEHCAKDAwLiAQYHBwICAwI54gEFBsABAwLjAQUCxgIkBOIBBAUCRQbjAVgEBQUCAuQBAwUCCPPkAQUCBwjkAQYC4gHsF3seAOCfA38AbQDhBmEA' Return _Decompress_Binary_String_to_Bitmap(_Base64Decode($Base64String)) EndFunc ;==>_Icon_Image_Checkbox_Checked Func _Base64Decode($input_string) Local $struct = DllStructCreate("int") Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", DllStructGetPtr($a), "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, "") Return DllStructGetData($a, 1) EndFunc ;==>_Base64Decode For me this is awesome already. But how would I draw different font sizes, or even different fonts, within the same subitem? In essential trying to resemble the Outlook lists (From, Subject, Body, all into one "cell"). And then there's the vertical alignment. $DT_VCENTER only seems to work with single line.
    1 point
  20. The short answer to your question is "Yes". Now it begs some explanations to be really useful to you. Case #1: several processes are using one or several database(s) hosted on the same computer at the same time... easy. Case #2: several processes need to share one or more database over a network... not easy Case #1: be sure to read and understand the locking mecanism inside SQLite (see the SQLite docs). Now for each connection, use _SQLite_Timeout to specify a large enough timeout (more about this later). Then wrap _every_ Read-Modify-Write (RMW) transaction inside _SQLite_Exec($hDb, "begin immediate;") and _SQLite_Exec($hDb, "commit;") Immediate keyword is crucial in that it informs SQLite to place a reserved lock on the DB file, which will block subsequent attempt to obtain a write lock, until _you_ commit. In the meantime, read (select) operations by concurrent processes can run without being blocked. Also read locks can't be promoted to write locks in the meantime, as it would result in a deadlock situation, which your mission is to avoid like the plague. The timeout value needs to be long enough to allow for _any_ sequence ot RMW or W transactions to complete. SQLite does no serialization of the requests, so your applications must be ready to accept being delayed for possibly longer than the duration of only one RMW transaction by another process. In this framework, you never have to worry about receiving "Database is busy" error. In a low concurrency context like mine, I may have up to 7 processes using the DB, but I setup 15 minutes of timeout! (One of the process is a weekly Vacuum, another is a hourly live backup, which are both slow operations). If your context needs to be more responsive, then decrease the timeout down to a value you can cope with, but always test and deal for SQLITE_BUSY condition inside after any SQLite operation inside a transaction or not (even for reads!). Case #2 is much harder. SQLite uses the underlying filesystem to insure proper locking, but it turns out than almost every implementation of NFS, SMB, ... has enough bugs to sometimes cause DB corruption. Exposing how and why things are this way is a bit too much for this answer. Let's say that, without using a intermediate client/server layer, SQLite over a network isn't safe. Don't give up if you need it anyway, there are a number of open-source implementations available that allow such operation with excellent success. Hope this clears some mud. There are much information about all this in the SQLite web documentation.
    1 point
  21. Well, since you asked so nicely, here you go: #include <GUIConstants.au3> GUICreate("Lod3n's Bandwidth Monitor",220,100,0,0,-1,$WS_EX_TOOLWINDOW) $label1 = GUICtrlCreateLabel ( "Waiting for data...", 10, 5,200,20) $progressbar1 = GUICtrlCreateProgress (10,20,200,20,$PBS_SMOOTH) $label2 = GUICtrlCreateLabel ( "Waiting for data...", 10, 50,200,20) $progressbar2 = GUICtrlCreateProgress (10,65,200,20,$PBS_SMOOTH) GUISetState () $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $inmax = 0 $outmax = 0 $lastin = 0 $lastout = 0 while 1 ;$colItems = $objWMIService.ExecQuery("SELECT BytesReceivedPersec,BytesSentPersec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) $colItems = $objWMIService.ExecQuery("SELECT BytesReceivedPersec,BytesSentPersec FROM Win32_PerfRawData_Tcpip_NetworkInterface", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $newin = $objItem.BytesReceivedPersec $newout = $objItem.BytesSentPersec ;new realtime counter code... if $lastin = 0 and $lastout = 0 Then $lastin = $newin $lastout = $newout endif $in = $newin - $lastin $out = $newout - $lastout $lastin = $newin $lastout = $newout if $in <> 0 and $out <> 0 Then if $in > $inmax then $inmax = $in if $out > $outmax then $outmax = $out $inP = int(($in / $inmax) * 100) $outP = int(($out / $outmax) * 100) ;$in = $in/1024 ;$out = $out/1024 $intext = "Bytes In/Sec: " & int($in) & " [" &$inP & "% of record]" & @CRLF $outtext = "Bytes Out/Sec: " & int($out) & " [" &$outP & "% of record]" &@CRLF GUICtrlSetData ($progressbar1,$inP) GUICtrlSetData ($label1,$intext) GUICtrlSetData ($progressbar2,$outP) GUICtrlSetData ($label2,$outtext) EndIf ExitLoop ; I only care about the first network adapter, yo Next EndIf sleep(1000) ; bytes PER SECOND If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop WEnd
    1 point
×
×
  • Create New...