Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/24/2014 in all areas

  1. The GDI+ v1.1 built-in blur code is too slow and the effect doesn't look very well at least on my Win 8.1 notebook. I changed the code a little bit using the blur code from eukalyptus and added an option to blur-in (by default not enabled) the image. The code doesn't require GDI+ v1.1 and should run also on WinXP (not tested). #include <GDIPlus.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() MessageBoxBlurBackground("Is this what you are looking for?") _GDIPlus_Shutdown() Func MessageBoxBlurBackground($sText, $sHeader = "Question", $iFlag = 4 + 32 + 262144, $fBlur = 0.15, $bBlurIn = False, $iTimeOut = 0) ;coded by UEZ Local $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]"), $aFullScreen = WinGetPos($hFullScreen) Local Const $iW = $aFullScreen[2], $iH = $aFullScreen[3] Local $hGui = GUICreate("", $iW, $iH, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_APPWINDOW)) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) ;capture full screen Local $hWnd = _WinAPI_GetDesktopWindow() Local $hDDC = _WinAPI_GetDC($hWnd) Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC) Local $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH) _WinAPI_SelectObject($hCDC, $hHBitmap) _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $aFullScreen[0], $aFullScreen[1], $SRCCOPY) ;copy captured screen to bitmap _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBitmap) Local $hBmp_GDIPlus_BitmapBlurred, $i Switch $bBlurIn Case True GUISetState(@SW_SHOWNA) For $i = 2 To 7 Step 0.5 $hBmp_GDIPlus_BitmapBlurred = _GDIPlus_BitmapBlur($hBitmap, $iW, $iH, 1 / $i) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBmp_GDIPlus_BitmapBlurred, 0, 0, $iW, $iH) ;copy blurred image to GUI _GDIPlus_BitmapDispose($hBmp_GDIPlus_BitmapBlurred) Next Case Else $hBmp_GDIPlus_BitmapBlurred = _GDIPlus_BitmapBlur($hBitmap, $iW, $iH, $fBlur) GUISetState(@SW_SHOWNA) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBmp_GDIPlus_BitmapBlurred, 0, 0, $iW, $iH) ;copy blurred image to GUI _GDIPlus_BitmapDispose($hBmp_GDIPlus_BitmapBlurred) EndSwitch Local $iRet = MsgBox($iFlag, $sHeader, $sText, $iTimeOut, $hGui) ;cleanup resources _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) GUIDelete($hGui) Return $iRet EndFunc Func _GDIPlus_BitmapBlur($hBitmap, $iW, $iH, $fScale = 0.15, $qual = 6); by eukalyptus Local Const $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) Local Const $hBmpSmall = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics) Local Const $hGfxSmall = _GDIPlus_ImageGetGraphicsContext($hBmpSmall) _GDIPlus_GraphicsSetPixelOffsetMode($hGfxSmall, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBmpBig = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics) Local Const $hGfxBig = _GDIPlus_ImageGetGraphicsContext($hBmpBig) _GDIPlus_GraphicsSetPixelOffsetMode($hGfxBig, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) _GDIPlus_GraphicsScaleTransform($hGfxSmall, $fScale, $fScale) _GDIPlus_GraphicsSetInterpolationMode($hGfxSmall, $qual) _GDIPlus_GraphicsScaleTransform($hGfxBig, 1 / $fScale, 1 / $fScale) _GDIPlus_GraphicsSetInterpolationMode($hGfxBig, $qual) _GDIPlus_GraphicsDrawImageRect($hGfxSmall, $hBitmap, 0, 0, $iW, $iH) _GDIPlus_GraphicsDrawImageRect($hGfxBig, $hBmpSmall, 0, 0, $iW, $iH) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBmpSmall) _GDIPlus_GraphicsDispose($hGfxSmall) _GDIPlus_GraphicsDispose($hGfxBig) Return $hBmpBig EndFunc ;==>_GDIPlus_BitmapBlur Br, UEZ
    2 points
  2. Here my version: $sString = "/storage/sdcard0/test/auto-import" & @CRLF & _ "/storage/sdcard0/test/projects" & @CRLF & _ "/storage/sdcard0/test/auto-import1" & @CRLF & _ "/storage/sdcard0/test/auto-import2" & @CRLF & _ "/storage/sdcard0/test2/auto-export" MsgBox(0, "Test", FindCommonPath($sString)) Func FindCommonPath($sString) Local $a = StringSplitW($sString, "/") ReDim $a[UBound($a)][UBound($a, 2) - 1] ;remove last row Local $i, $iY, $iX = UBound($a, 2) - 1, $bEqual = True, $sCommon = "/" Do For $iY = 0 To UBound($a) - 2 If $a[$iY][$iX] <> $a[$iY + 1][$iX] Then $bEqual = False ExitLoop EndIf Next If $bEqual Then For $i = 1 To UBound($a, 2) - 1 $sCommon &= $a[0][$i] & "/" Next $sCommon = StringTrimRight($sCommon, 1) ExitLoop EndIf If $iX > 1 Then ReDim $a[UBound($a)][UBound($a, 2) - 1] $iX = UBound($a, 2) - 1 $bEqual = True Else ExitLoop EndIf Until False Return $sCommon EndFunc ; #FUNCTION# ======================================================================================================================================== ; Name .................: StringSplitW() ; Description ..........: Splits a string into columns instead of rows as it is done by SplitString(), like a csv file to a 2d array ;-) ; Syntax ...............: StringSplitW($sString, $sDelimiter, $iWidthLen) ; Parameters ...........: $sString - string to split ; $sDelimiter - [optional] the delimter how to split the string ; $iWidthLen - [optional] length of the row (amount of columns - default is 256) ; Return values .......: Success - 2d array ; Error 1 - either $sString or $delimter is not set ; Error 2 - array width exceeded ; Error 3 - error splitting string ; ; Version .............: v0.96 build 2015-01-20 beta ; Author ..............: UEZ ; Modified ............: ; Remarks .............: RegEx take from http://stackoverflow.com/questions/4476812/regular-expressions-how-to-replace-a-character-within-quotes ; Related .............: StringSplit, StringReplace, StringRegExpReplace, StringLen, StringStripCR ; =================================================================================================================================================== Func StringSplitW($sString, $sDelimiter = ";", $sQuotationMark = '"', $sDummy = "¦", $iWidthLen = 256) If $sString = "" Or $sDelimiter = "" Then Return SetError(1, 0, 0) Local $chk, $iWidth, $i, $j, $k, $iLen, $iMax = 1, $iMaxWidth Local $aPos[1], $l = 0 Local $aSplit = StringSplit(StringStripCR($sString), @LF) If @error Then Return SetError(3, 0, 0) Local $aVertical[$aSplit[0]][$iWidthLen], $iDelimiterLen = StringLen($sDelimiter) - 1, $sLine For $k = 1 To $aSplit[0] $iLen = StringLen($aSplit[$k]) If $iLen > 1 Then $sLine = StringRegExpReplace($aSplit[$k], '(?m)\' & $sDelimiter & '(?=[^' & $sQuotationMark & ']*' & $sQuotationMark & '(?:[^' & $sQuotationMark & '\r\n]*' & $sQuotationMark & '[^' & $sQuotationMark & ']*' & $sQuotationMark & ')*[^' & $sQuotationMark & '\r\n]*$)', $sDummy) $chk = StringReplace($sLine, $sDelimiter, $sDelimiter) $iWidth = @extended If $iWidth > $iWidthLen Then Return SetError(2, 0, 0) If $iWidth >= $iMax Then $iMax = $iWidth + 1 Switch $iWidth Case 0 $aVertical[$l][0] = $sLine Case Else Dim $aPos[$iWidth * 2 + 2] $j = 1 $aPos[0] = 1 For $i = 0 To $iWidth - 1 $aPos[$j] = StringInStr($sLine, $sDelimiter, 0, $i + 1) - 1 $aPos[$j + 1] = $aPos[$j] + 2 + $iDelimiterLen $j += 2 Next $aPos[UBound($aPos) - 1] = StringLen($sLine) $j = 0 For $i = 0 To UBound($aPos) - 1 Step 2 $aVertical[$l][$j] = StringMid(StringReplace($sLine, $sDummy, $sDelimiter), $aPos[$i], $aPos[$i + 1] - $aPos[$i] + 1) $j += 1 Next EndSwitch $l += 1 EndIf Next ReDim $aVertical[$l][$iMax] Return $aVertical EndFunc Br, UEZ
    1 point
  3. Alexxander, I have just seen your edit. To run this over a unknown number of strings you can do something like this: #include <MsgBoxConstants.au3> #include <Array.au3> Global $aTest[3] = ["/storage/sdcard0/test/auto-import", "/storage/sdcard0/test/auto-import2", "/storage/sdcard0/fred"] MsgBox($MB_SYSTEMMODAL, "Common", _Extract_Common($aTest)) Func _Extract_Common($aArray) Local $aCommon = StringSplit($aArray[0], "/") For $i = 0 To UBound($aArray) - 1 ; Split next string $aSplit = StringSplit($aArray[$i], "/") ; Determine smallest array size $iLast = ( ($aCommon[0] < $aSplit[0]) ? ($aCommon[0]) : ($aSplit[0]) ) ; Loop through arrays and compare elements $sCommon = "" For $j = 1 To $iLast If $aSplit[$j] <> $aCommon[$j] Then ; ReDim common array and reset count ReDim $aCommon[$j] $aCommon[0] = $j - 1 ExitLoop EndIf Next Next Return _ArrayToString($aCommon, "/", 1) & "/" EndFunc I hope that does the trick. M23
    1 point
  4. Alexxander, No doubt an SRE guru will come up with a one-liner, but you can also do it like this: #include <MsgBoxConstants.au3> Global $aTest_1[2] = ["/storage/sdcard0/test/auto-import", "/storage/sdcard0/test/projects"] Global $aTest_2[2] = ["/storage/sdcard0/test/auto-import1", "/storage/sdcard0/test/auto-import2"] MsgBox($MB_SYSTEMMODAL, "Common", _Extract_Common($aTest_1)) MsgBox($MB_SYSTEMMODAL, "Common", _Extract_Common($aTest_2)) Func _Extract_Common($aArray) ; Split strings $aSplit_0 = StringSplit($aArray[0], "/") $aSplit_1 = StringSplit($aArray[1], "/") ; Determine smallest array size $iLast = ( ($aSplit_0[0] > $aSplit_1[0]) ? ($aSplit_1[0]) : ($aSplit_0[0]) ) ; Loop through arrays and compare elements $sCommon = "" For $i = 1 To $iLast If $aSplit_0[$i] == $aSplit_1[$i] Then ; Add to common string $sCommon &= $aSplit_0[$i] & "/" Else ; No point in looking further ExitLoop EndIf Next Return $sCommon EndFunc All clear? M23
    1 point
  5. I do not think that FF.au3 can do that. You can build your own function to do what you want. The function could be : - checks if Firefox is open (if yes, do not proceed) - search for FF user profile (locates the prefs.js file) - edit the prefs.js file and adds the line user_pref("general.useragent.override","Some string"); I give you a point to start it with a function to list the user's profile(s) path(s) #Include <File.au3> #Include <Array.au3> ; just used for ArrayDisplay in the example $aProfiles = _FF_ProfilesList() _ArrayDisplay($aProfiles) Func _FF_ProfilesList() Local $aResult[1][2] = [[0]] Local $sProfiles = @AppDataDir & "\Mozilla\Firefox\profiles.ini" Local $aSections = IniReadSectionNames($sProfiles) If @error OR NOT IsArray($aSections) Then Return SetError(1, 1, 0) For $i = 1 To $aSections[0] If $aSections[$i] <> "General" Then Local $sProfileName = IniRead($sProfiles, $aSections[$i], "Name", "error") Local $bIsRelative = IniRead($sProfiles, $aSections[$i], "IsRelative", "error") Local $sProfilePath = IniRead($sProfiles, $aSections[$i], "Path", "error") If $bIsRelative = "error" OR $sProfilePath = "error" OR $sProfileName = "error" Then ContinueLoop If $bIsRelative = "1" Then $sProfilePath = _PathFull( @AppDataDir & "\Mozilla\Firefox\" & StringReplace($sProfilePath, "/", "\") ) If NOT FileExists($sProfilePath & "\prefs.js") Then ContinueLoop $aResult[0][0] = UBound($aResult) Redim $aResult[ UBound($aResult) + 1][2] If IniRead($sProfiles, $aSections[$i], "Default", "error") = "1" Then $aResult[0][1] = UBound($aResult) - 1 $aResult[UBound($aResult) - 1][0] = $sProfileName $aResult[UBound($aResult) - 1][1] = $sProfilePath EndIf Next If $aResult[0][1] = "" AND $aResult[0][0] > 0 Then $aResult[0][1] = 1 Return $aResult EndFunc
    1 point
  6. Bowmore

    Object ID

    If you wand an ID that is guaranteed to be unique when a database records are created off line then I suggest that you use GUIDs Global Unique IDentifiers Each client could create their own IDs with no worries about duplicates being generated A quick Autoit function for creating GUIDs with an example of how to use it. #Include <WinAPI.au3> For $i = 1 To 10 $ID = _GetGuid() ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ID = ' & $ID & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Next Func _GetGuid() Static Local $tGuid = DllStructCreate($tagGUID) Static Local $ptrtGuid = DllStructGetPtr($tGuid) DllCall("OLE32.DLL", "dword", "CoCreateGuid", "ptr", $ptrtGuid) Return _WinAPI_StringFromGUID($ptrtGuid) EndFunc ;==>_GetGuid
    1 point
×
×
  • Create New...