Leaderboard
Popular Content
Showing content with the highest reputation on 09/16/2013 in all areas
-
_GUIDisable() - Create a dimmed effect on a GUI.
mesale0077 reacted to guinness for a topic
I was inspired by an example in s!mpL3 LAN Messenger, in which when you wanted to change the Password the current GUI had a dimmed effect until the Password was set. I therefore decided to create _GUIDisable which creates the same effect. I also utilised a Function mentioned by Mat and created by Yashied in the topic. Example: or continue for those interested in the original UDF with more options ... UDF with Global variable: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _GUIDisable ; AutoIt Version : v3.2.2.0 or higher ; Language ......: English ; Description ...: Creates a dimming effect on the current/selected GUI. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. ; =============================================================================================================================== ; #INCLUDES# ==================================================================================================================== #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; #GLOBAL VARIABLES# ============================================================================================================ Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax Global $__aGUIDisable[$__iGUIDisableMax] ; #CURRENT# ===================================================================================================================== ; _GUIDisable: Creates a dimming effect on the current/selected GUI. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __GUIDisable_WM_SIZE: Automatically re-sizes the dimmed effect when the GUI is re-sized. ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUIDisable ; Description ...: Creates a dimming effect on the current/selected GUI. ; Syntax ........: _GUIDisable($hWnd[, $iAnimate = 1[, $iBrightness = 5[, $bColor = 0x000000]]]) ; Parameters ....: $hWnd - GUI handle the effect should be applied to. This can either be a variable of the GUI handle or -1 for the current GUI. ; $iAnimate - [optional] Animate the dimmed effect. Animate = 1 or don't animate = 0. Default is 1. ; $iBrightness - [optional] Percentage of how bright the effect is. Default is 5. ; $bColor - [optional] Color of the dimming effect. Default is 0x000000. ; Return values .: Success - Returns handle of dimmed GUI. ; Failure - Returns 0 and sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 If $iAnimate = Default Then $iAnimate = 1 EndIf If $iBrightness = Default Then $iBrightness = 5 EndIf If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) If @error Then Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) EndIf GUICtrlDelete($iLabel) EndIf If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then If $iAnimate Then DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $__aGUIDisable[$__hGUIDisableHWnd], 'dword', 250, 'dword', $AW_SLIDE_OUT_TOP) EndIf GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) $__aGUIDisable[$__hGUIDisableHWnd] = 0 $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 Else $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd Local $iLeft = 0, $iTop = 0 Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) Local $aStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) If UBound($aStyle) Then If BitAND($aStyle[0], $WS_SIZEBOX) Then If RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\', 'CurrentVersion') >= 6.0 Then ; Windows Vista+. If $iIsClassicTheme Then $iLeft -= 1 $iTop -= 1 Else $iLeft -= 5 $iTop -= 5 EndIf Else $iLeft -= 1 $iTop -= 1 EndIf EndIf EndIf Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft, $iTop, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) GUIRegisterMsg($WM_SIZE, '__GUIDisable_WM_SIZE') If $iAnimate Then DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $__aGUIDisable[$__hGUIDisableHWnd], 'dword', 250, 'dword', $AW_SLIDE_IN_TOP) Else GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) EndIf GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) EndIf Return $__aGUIDisable[$__hGUIDisableHWnd] EndFunc ;==>_GUIDisable ; #INTERNAL_USE_ONLY#============================================================================================================ Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $iHeight = _WinAPI_HiWord($lParam) Local $iWidth = _WinAPI_LoWord($lParam) If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) If @error = 0 Then WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>__GUIDisable_WM_SIZEExample 1: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <Constants.au3> #include '_GUIDisable.au3' Example_1() Func Example_1() Local $hGUI = GUICreate('_GUIDisable()', 300, 100, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MINIMIZEBOX)) Local $iButton_1 = GUICtrlCreateButton('Effect 1', 5, 5, 100, 25) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKSIZE + $GUI_DOCKTOP) Local $iButton_2 = GUICtrlCreateButton('Effect 2', 5, 30, 100, 25) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKSIZE + $GUI_DOCKTOP) GUISetState(@SW_SHOW, $hGUI) Local $hDisableGUI = 0, $hTimer = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iButton_1 ; Enable the dimmed effect on the current GUI with the animation turned on. _GUIDisable(-1, 1, 25) MsgBox($MB_SYSTEMMODAL, '_GUIDisable()', 'See how the GUI is now dimmed. Once you select OK, you''ll have 5 seconds to re-size the GUI!' & @CRLF & @CRLF & _ 'If you wish to exit the 5 second timer, then simply select "Close" to exit the loop.') $hTimer = TimerInit() Do ; Exit the loop if $GUI_EVENT_CLOSE is captured by GUIGetMsg(). If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop EndIf Sleep(10) Until TimerDiff($hTimer) > 5000 ; Disable the dimmed effect with the animation turned on and add focus to the current GUI. _GUIDisable(-1, 1) Case $iButton_2 ; Enable the dimmed effect on the current GUI without the animation. $hDisableGUI = _GUIDisable($hGUI, 0, 25, 0x7D26CD) ; Pass handle of dimmed GUI to the MsgBox, just the same as passing $hGUI. MsgBox($MB_SYSTEMMODAL, '_GUIDisable(' & $hGUI & ')', 'See how the GUI is now dimmed with a Purple color.', 0, $hDisableGUI) ; Disable the dimmed effect without the animation and add focus back to the previous GUI. _GUIDisable($hGUI, 0) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example_1All of the above has been included in a ZIP file. GUIDisable.zip Previous downloads: 420+. Updated: 01/02/20131 point -
I ran that code with an avi on my system and it worked fine. Perhaps it has something to do with the avi you're using.1 point
-
Read the help file for that function, your parameters for GUICtrlCreateAvi are wrong.1 point
-
Don't try to race in a Grand Prix, until you've learnt to drive a car. I suggest you do some of the Tutorials available, both here in the Wiki and in the Examples section. There are also many examples in your AutoIt install folder, plus some basics in the Help file. Once you grasp the basics, then your next steps to what you want will be easier, and any time you need help along your journey, just post your code here, and we will give you any necessary assistance or advice.1 point
-
This example randomly clicks controls within a chosen window. This example chose the Calculator window. #include <WinAPI.au3> #include <Array.au3> #include <Misc.au3> Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client Local $sWinTitle = "[Title:Calculator]", $iIndex = 1, $iRndNum If WinExists($sWinTitle) = 0 Then Run("Calc.exe") WinActivate("[Title:Calculator]") WinWaitActive("[Title:Calculator]") _RandomlyClickControls($sWinTitle) Func _RandomlyClickControls($WindowTitle) Local $text = WinGetClassList($WindowTitle, "") $text = StringStripWS($text, 2) Local $aText = StringRegExp($text, "\V+", 3) _ArraySort($aText) Local $aClassNN[UBound($aText)] $aClassNN[0] = $aText[0] & $iIndex For $i = 1 To UBound($aText) - 1 If $aText[$i] = $aText[$i - 1] Then $iIndex += 1 Else $iIndex = 1 EndIf $aClassNN[$i] = $aText[$i] & $iIndex Next Do $iRndNum = Random(0, UBound($aClassNN) - 1, 1) Local $aPos = ControlGetPos($WindowTitle, "", $aClassNN[$iRndNum]) MouseMove($aPos[0] + 4, $aPos[1] + 4, 10) MouseClick("left") Sleep(1000) Until _IsPressed("1B") ; Press and hold "Esc" key for over a second to exit EndFunc ;==>_RandomlyClickControls Occasionally, you may need to click on "CE" button due to "invalid input" occurring.1 point
-
No native function, and no UDF that I've seen or heard of. Of course you could make one. There are UDF's which gather information about Windows/GUIs, so that's where you could start.1 point
-
NO no! it's not what I mean! you are welcomed any time.1 point
-
More help, according to (5 posts) and Anti - Double - Open #include <Misc.au3> #include <MsgBoxConstants.au3> If _Singleton("test", 1) = 0 Then MsgBox($MB_SYSTEMMODAL, "Warning", "An occurence of test is already running") Exit EndIf MsgBox($MB_SYSTEMMODAL, "OK", "the first occurence of test is running") good luck1 point
-
1 point
-
wow that really tells me nothing. thanks, i guess. but i suppose it's about on par with the rest of the useless information you've provided. bravo. now i see why you get flamed all the time on your posts, 'TheSaint' ROFLMAO1 point
-
Yup: #include <IE.au3> #include <Array.au3> $oIE = _IECreate() Local $sHTML = '<html><body><img src="http://aut1.autoit-cdn.com/site/wp-content/themes/TheCorporation/images/logo@2x.png" width="210" height="72" alt="AutoItScript" id="logo" /></body></html>' _IEBodyWriteHTML($oIE, $sHTML) Local $RetArray[1][2] Local $OneImage = _IEGetObjById($oIE, 'logo') If IsObj($OneImage) Then Local $AttrObj = $OneImage.attributes If IsObj($AttrObj) Then Local $TotalNumberOFAttr = $AttrObj.length For $i = 0 to $TotalNumberOFAttr-1 Local $PropertyName = $AttrObj.item($i).nodeName Local $PropertyValue = $AttrObj.item($i).nodeValue If $PropertyValue <> '' Then _ArrayAddEx($RetArray, $PropertyName, $PropertyValue) Next EndIf EndIf _ArrayDisplay($RetArray) _IEQuit($oIE) Func _ArrayAddEx(ByRef $__Array, $value1, $value2) ReDim $__Array[UBound($__Array)+1][2] $__Array[0][0] = UBound($__Array)-1 $__Array[UBound($__Array)-1][0] = $value1 $__Array[UBound($__Array)-1][1] = $value2 EndFunc1 point