Leaderboard
Popular Content
Showing content with the highest reputation on 07/10/2014 in all areas
-
Just wrote one (it's not perfect but a good starting point): ;Proof of concept version #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> ;example _GDIPlus_Startup() Global $hGUI = GUICreate("Test", 300, 200), $aGUIGetMsg GUISetState() Global $hGUI_TrayMessage = CreateTrayMessage("Text Message" & @CRLF & @CRLF & "Coded by UEZ 2014 using GDI+ ;-)", 350, 100) Sleep(500) ShowTrayMessage($hGUI_TrayMessage) Do $aGUIGetMsg = GUIGetMsg(1) Switch $aGUIGetMsg[1] Case $hGUI Switch $aGUIGetMsg[0] Case $GUI_EVENT_CLOSE _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Case $hGUI_TrayMessage Switch $aGUIGetMsg[0] Case $GUI_EVENT_PRIMARYDOWN HideTrayMessage($hGUI_TrayMessage) EndSwitch EndSwitch Until False Func CreateTrayMessage($sText, $iW, $iH) Local Const $hGUI_TrayMessage = GUICreate("", $iW, $iH, @DesktopWidth, @DesktopHeight, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) Local Const $hBmp_TP = _GDIPlus_BitmapCreateTrayMessage($sText, $iW, $iH) _WinAPI_BitmapSetTransparent($hGUI_TrayMessage, $hBmp_TP) GUISetState(@SW_HIDE, $hGUI_TrayMessage) _GDIPlus_ImageDispose($hBmp_TP) Return $hGUI_TrayMessage EndFunc ;==>CreateTrayMessage Func ShowTrayMessage($__hGUI_TrayMessage) Local $aSize = WinGetPos($__hGUI_TrayMessage, "") Local $iW = $aSize[2], $iH = $aSize[3] Local $aPos = _Toast_Locate($iW, $iH) WinMove($__hGUI_TrayMessage, "", $aPos[0], @DesktopHeight, $iW, $iH) GUISetState(@SW_SHOWNA, $__hGUI_TrayMessage) WinMove($__hGUI_TrayMessage, "", $aPos[0], $aPos[1], $iW, $iH, 4) Return 1 EndFunc ;==>ShowTrayMessage Func HideTrayMessage($__hGUI_TrayMessage) GUISetState(@SW_SHOWNA, $__hGUI_TrayMessage) Local $aSize = WinGetPos($__hGUI_TrayMessage, "") Local $iW = $aSize[2], $iH = $aSize[3] Local $aPos = _Toast_Locate($iW, $iH) WinMove($__hGUI_TrayMessage, "", $aPos[0], @DesktopHeight, $iW, $iH + 4, 5) GUISetState(@SW_HIDE, $__hGUI_TrayMessage) Return 1 EndFunc ;==>HideTrayMessage ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_BitmapCreateTrayMessage ; Description ...: Creates a tooltip like window using GDI+ ; Syntax ........: _GDIPlus_BitmapCreateTrayMessage($sText[, $iW = 70[, $iH = 50[, $sFont = "Arial"[, $fFontSize = 12[, ; $iBGColor = 0xD0101010[, $iFontColor = 0xFF000000[, $iRadius = 8[, $hImage = 0[, $iImgPosX = 8[, ; $iImgPosY = 4[, $iImgW = 16[, $iImgH = 16[, $bGDIBmp = 1]]]]]]]]]]]]]) ; Parameters ....: $sText - A string value. ; $iW - [optional] An integer value. Default is 70. ; $iH - [optional] An integer value. Default is 50. ; $sFont - [optional] A string value. Default is "Arial". ; $fFontSize - [optional] A boolean value. Default is 12. ; $iBGColor - [optional] An integer value. Default is 0xD0101010. ; $iFontColor - [optional] An integer value. Default is 0xFF000000. ; $iRadius - [optional] An integer value. Default is 8. ; $hImage - [optional] A handle value. Default is 0. ; $iImgPosX - [optional] An integer value. Default is 8. ; $iImgPosY - [optional] An integer value. Default is 4. ; $iImgW - [optional] An integer value. Default is 16. ; $iImgH - [optional] An integer value. Default is 16. ; $bGDIBmp - [optional] A binary value. Default is 1. ; Return values .: bitmap handle (GDI+ format bitmap) ; Version .......: 0.90 build 2014-10-07 ; Author ........: UEZ ; Modified ......: ; Remarks .......: AutoIt version 3.3.9.18+ and Win7+ is needed. Don't forget to dispose returned bitmap handle! ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GDIPlus_BitmapCreateTrayMessage($sText, $iW = 70, $iH = 40, $sFont = "Arial", $fFontSize = 12, $iBGColor = 0xD0101010, $iFontColor = 0xFFFFFFFF, $iRadius = 8, $hImage = 0, $iImgPosX = 8, $iImgPosY = 4, $iImgW = 16, $iImgH = 16, $bGDIBmp = 0) Local $iPenSize = 1, $iSize = 12, $iSize2 = $iSize / 2, $iDX = $iW / 2 Local $iWidth = $iW - $iPenSize - $iSize, $iHeight = $iH - $iPenSize - $iSize Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) Local $hPath = _GDIPlus_PathCreate(), $hMatrix = _GDIPlus_MatrixCreate() Local $iX = 0, $iY = 0 _GDIPlus_PathAddArc($hPath, $iWidth - ($iRadius * 2), 0, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_PathAddArc($hPath, $iWidth - ($iRadius * 2), $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_PathAddLine($hPath, $iWidth - ($iRadius * 2), $iHeight, $iDX + $iSize2, $iHeight) _GDIPlus_PathAddArc($hPath, 0, $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_PathAddArc($hPath, 0, 0, $iRadius * 2, $iRadius * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2) _GDIPlus_GraphicsSetTransform($hCtxt, $hMatrix) Local $hBrush_Shadow = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetCenterColor($hBrush_Shadow, 0x00FFFFFF) _GDIPlus_PathBrushSetSurroundColor($hBrush_Shadow, 0x80000000) _GDIPlus_PathBrushSetGammaCorrection($hBrush_Shadow, True) _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush_Shadow) Local $hEffect = _GDIPlus_EffectCreateBlur(4.5, 1) _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect) _GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2) _GDIPlus_GraphicsSetTransform($hCtxt, $hMatrix) Local $hBrush = _GDIPlus_BrushCreateSolid($iBGColor) _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush) Local $hPen = _GDIPlus_PenCreate(0xFF000000, $iPenSize) _GDIPlus_GraphicsDrawPath($hCtxt, $hPath, $hPen) _GDIPlus_PathReset($hPath) Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFormat = _GDIPlus_StringFormatCreate() Local $tLayout = _GDIPlus_RectFCreate($iRadius, $iRadius, $iWidth, $iHeight) _GDIPlus_StringFormatSetAlign($hFormat, 0) _GDIPlus_StringFormatSetLineAlign($hFormat, 0) _GDIPlus_BrushSetSolidColor($hBrush, $iFontColor) _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, $fFontSize * 1.3, 0) _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush) If $hImage Then _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hImage, 0, 0, _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), $iImgPosX, $iImgPosY, $iImgW, $iImgH) EndIf _GDIPlus_EffectDispose($hEffect) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush_Shadow) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hCtxt) If $bGDIBmp Then Local $hGDIBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hGDIBmp EndIf Return $hBitmap EndFunc ;==>_GDIPlus_BitmapCreateTrayMessage Func _WinAPI_BitmapSetTransparent($hGUI, $hImage, $iOpacity = 0xFF) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) $tSize.X = _GDIPlus_ImageGetWidth($hImage) $tSize.Y = _GDIPlus_ImageGetHeight($hImage) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_WinAPI_BitmapSetTransparent ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Toast_Locate ; Description ...: Find Systray and determine Toast start position and movement direction ; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height) ; Parameters ....: $iToast_Width - required width of slice ; $iToast_Height - required height of slice ; Author ........: Melba23 - using some code from guinness and MilesAhead ; Modified.......: ; Remarks .......: This function is used internally by _Toast_Show ; =============================================================================================================================== Func _Toast_Locate($iToast_Width, $iToast_Height) Local $tWorkArea ; Define return array Local $aToast_Data[3] ; Determine which struct syntax to use to use If @AutoItVersion < "3.3.8.0" Then $tWorkArea = DllStructCreate("long Left;long Top;long Right;long Bottom") Else $tWorkArea = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct") EndIf ; Check if Taskbar is hidden Local $aRet = DllCall("shell32.dll", "uint", "SHAppBarMessage", "dword", 0x00000004, "ptr*", 0) ; $ABM_GETSTATE If BitAND($aRet[0], 0x01) Then ; Find hidden taskbar Local $iPrevMode = Opt("WinTitleMatchMode", 4) Local $aTray_Pos = WinGetPos("[CLASS:Shell_TrayWnd]") Opt("WinTitleMatchMode", $iPrevMode) ; If error in finding systray If Not IsArray($aTray_Pos) Then Return SetError(2, 0, -1) ; Determine direction of Toast motion and starting position If $aTray_Pos[1] > 0 Then $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10 $aToast_Data[1] = $aTray_Pos[1] - $iToast_Height - 2 $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM ElseIf $aTray_Pos[0] > 0 Then $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT $aToast_Data[0] = $aTray_Pos[0] - $iToast_Width - 2 $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10 $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT ElseIf $aTray_Pos[2] > @DesktopWidth - 70 Then $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10 $aToast_Data[1] = $aTray_Pos[1] + $aTray_Pos[3] $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP ElseIf $aTray_Pos[3] >= @DesktopHeight Then $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT $aToast_Data[0] = $aTray_Pos[0] + $aTray_Pos[2] $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10 $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT EndIf Else ; Determine available work area ; $SPI_GETWORKAREA = 48 DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", 48, "uint", 0, "ptr", DllStructGetPtr($tWorkArea), "uint", 0) If @error Then Return SetError(2, 0, -1) Local $aWorkArea[4] = [DllStructGetData($tWorkArea, "Left"), DllStructGetData($tWorkArea, "Top"), _ DllStructGetData($tWorkArea, "Right"), DllStructGetData($tWorkArea, "Bottom")] ; Determine direction of Toast motion and starting position If $aWorkArea[3] <> @DesktopHeight Then $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10 $aToast_Data[1] = $aWorkArea[3] - $iToast_Height - 2 $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM ElseIf $aWorkArea[2] <> @DesktopWidth Then $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT $aToast_Data[0] = $aWorkArea[2] - $iToast_Width - 2 $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10 $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT ElseIf $aWorkArea[1] <> 0 Then $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10 $aToast_Data[1] = $aWorkArea[1] $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP ElseIf $aWorkArea[0] <> 0 Then $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT $aToast_Data[0] = $aWorkArea[0] $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10 $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT EndIf EndIf Return $aToast_Data EndFunc ;==>_Toast_Locate Thx to Melba23 for the _Toast_Locate function. Works only for Win7+ operating systems. Br, UEZ2 points
-
New SciTE4AutoIt3 available with updated SciTE v3.4.1
jaberwacky reacted to Jos for a topic
It was actually put back on request so have no intent to remove it unless at one point it is going to be an issue. This is determined by the following parameter: word.characters.$(au3)=$(chars.alpha)$(chars.numeric)$(chars.accented).$_@# Jos1 point -
Something like this ? Local $aFiles[] = [ "1.mp3", "2.txt", "3.wav", "4.wma", "5.doc"] For $i = 0 To UBound($aFiles) - 1 If StringRegExp($aFiles[$i], "(?i)\.(?:wav|mp3|wma)$") Then ConsoleWrite($aFiles[$i] & @CRLF) Next1 point
-
In StringRegExp, pipe is used for OR. ==> ".mp3|.wav|.wma"1 point
-
This process is actually used in some high-end mission-critical embedded systems, but the those OS part don't compare to Windows, Linux, MacInTrash and such.1 point
-
can i take a part from a window!!
yousefsamy reacted to lorenkinzel for a topic
"(my idea is moving scroll bar to the position what i want and hide it)" Is it that you want to scroll to a particular area on the web page and then hide the scrollbars?1 point -
You can't have If / Then / Else on the same line.1 point
-
Can you please post the full script? Most of the time the error is caused somewhere else (missing quote etc.).1 point
-
It's just so I can continue using the latest dev tools without a really ugly hack that we use. Visual Studio 2013 supports XP SP3 out of the box - that's a decent level to aim at.1 point
-
Switch this: $oActivitySelect = _IEGetObjById($oIE, "print") to this: $oActivitySelect = _IEGetObjByName($oIE, "print")1 point
-
This seems to work for me: #include <IE.au3> Local $hWin, $siteURL $siteURL = "https://your.url.here/" Run("C:\Program Files (x86)\Juniper Networks\Network Connect 7.1.17\dsNetworkConnect.exe") $hWin = WinWait("Network Connect - Sign In", "", 10) If $hWin = 0 Then ConsoleWrite("WinWait failure" & @CRLF) Exit EndIf ControlSetText($hWin, "", "[CLASS:Edit; INSTANCE:1]", $siteURL) ControlClick($hWin, "", "[CLASS:Button; INSTANCE:1]") Do Sleep(2000) $oIE = _IEAttach ($hWin, "embedded") Until IsObj($oIE) If @error = $_IEStatus_Success Then ConsoleWrite("_IEAttach success" & @CRLF) _IELoadWait($oIE) If @error = $_IEStatus_Success Then ConsoleWrite("_IELoadWait success" & @CRLF) $Button = _IEGetObjByName($oIE, "btnSubmit") _IEAction($Button, "click") Else ConsoleWrite("_IELoadWait failure" & @CRLF) EndIf Else ConsoleWrite("_IEAttach failure" & @CRLF) EndIf1 point
-
File Name: AutoIt v3.3.13.1 Beta File Submitter: Jon File Submitted: 09 Jul 2014 File Category: Beta 3.3.13.1 (9th July, 2014) (Beta) AutoIt: - Added: FileGetAttrib() returns encrypted attribute. - Added #2365: FileFindNextFile() - information in @extended. - Added #2647: Return the line count from FileReadToArray() in @extended. - Fixed: Functions fixed for extended length paths: FileOpen(), FileCopy(), FileMove(), FileDelete(). Click here to download this file1 point
-
If Statement
232showtime reacted to l3ill for a topic
Tested on Win 7 32 Bit (Working) >Running AU3Check (3.3.12.0) HotKeySet("{`}", "TogglePause") = Pauses script ( NO additional msgbox popup ) Yes - opens Paint No - opens Calc.exe If I may make a suggestion: Instead of using MsgBox for this, build a little GUI and use Switch case... Edit: - you could also do something like this if you want to stick to MsgBox Using Select Case instead of If statement: #include <Inet.au3> Local $PublicIP = _GetIP() $iMsgBoxAnswer = MsgBox(1, "IP Address", "Your IP Address is: " & $PublicIP & @CRLF & "Copy to Clipboard?") Select Case $iMsgBoxAnswer = 1 ;OK ClipPut($PublicIP) Case $iMsgBoxAnswer = 2 ;Cancel EndSelect1 point -
By the way, this.. $foo = SomeFunction($param [,$param2="foo" [,$param3="bar"]]) means that the first parameter is required, but the second and third are optional. You don't include the square brackets or the "=value" parts in the function call, they are simply to let you know what it and isn't optional, and what the default values (that you don't send) would be. e.g. $foo = SomeFunction($variable) or $foo = SomeFunction($variable, $another_variable) or $foo = SomeFunction($variable, $another_variable, $and_another) would all be fine. The $variables could be actual values, e.g. $foo = SomeFunction("foo", "bar", 256) These are fairly standard coding conventions which if you have no expreience of, might be slightly confusing. ;o) Cor1 point
-
How to look for a string in a browser and fire a function when found?
kosu reacted to somdcomputerguy for a topic
Welcome to the Forums here. I have re-written and shrunk down a bit of code that I use regularly. This bit of code only requires that IE be installed on the machine it is run on. Change the variable $Find from peace, as it is now, to hate to see the difference. Good luck with you project. #include <INet.au3> Local $URL = "http://somdcomputerguy.com", $Source, $Result, $Find = "peace" $Source = _INetGetSource($URL) $Result = StringInStr($Source, $Find) If $Result <> 0 Then MsgBox(0, "", "Yay!") Else MsgBox(0, "", "No " & $Find & " at " & $URL) EndIf I am very poor at commenting my code, so refer to the Help file for any function or code logic descriptions.1 point -
You can use my Typos() fuzzy comparison function: Typos.au3 It computes the edit distance between two strings, that is the number of omissions, insertions, changes or swap of letters necessary to transform one string into the other. If you compare several strings in succession and keep one having the smallest errors (typos) you'll be home. Optionally, you can use two distinct wildcards in the second string: _ and % (the same characters than in SQL LIKE.) _ is a single character joker, much like ? in Windows filename patterns % may represent one or more characters, like Windows * (but % may only appear at the end of the second parameter) Try it and post again if you have problems using it.1 point