Leaderboard
Popular Content
Showing content with the highest reputation on 08/14/2014 in all areas
-
In the last versions of Windows, it has been difficult to automate Windows Explorer. But there are many examples of code like this to extract the selected items: ; Windows Explorer on XP, Vista, 7, 8 $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then Exit ; Shell object $oShell = ObjCreate( "Shell.Application" ) ; Find window For $oWindow In $oShell.Windows() If $oWindow.HWND() = $hExplorer Then ExitLoop Next ; Selected items For $oItem In $oWindow.Document.SelectedItems() ConsoleWrite( $oItem.Path() & @CRLF ) Next It's possible to create these objects with ObjCreateInterface. More precisely, create an IShellBrowser interface for the top level browser of an open Windows Explorer. Plan and code This is the plan: Create an IShellWindows interface to get a list of shell windows Get an IWebBrowserApp object for each window. This is done in two steps: Get an IDispatch object for the window Get the IWebBrowserApp interface Identify the proper shell window with get_HWND of IWebBrowserApp Get an IServiceProvider interface with QueryInterface of IWebBrowserApp Get the IShellBrowser interface with QueryService of IServiceProvider This is the code: Func GetIShellBrowser( $hExplorer ) ; IShellWindows interface Local $pIShellWindows, $oIShellWindows CoCreateInstance( $tCLSID_ShellWindows, $NULL, $CLSCTX_ALL, $tRIID_IShellWindows, $pIShellWindows ) $oIShellWindows = ObjCreateInterface( $pIShellWindows, $sIID_IShellWindows, $dtag_IShellWindows ) ; Number of shell windows Local $iWindows $oIShellWindows.get_Count( $iWindows ) ; Get an IWebBrowserApp object for each window ; This is done in two steps: ; 1. Get an IDispatch object for the window ; 2. Get the IWebBrowserApp interface ; Check if it's the right window Local $pIDispatch, $oIDispatch Local $pIWebBrowserApp, $oIWebBrowserApp, $hWnd For $i = 0 To $iWindows - 1 $oIShellWindows.Item( $i, $pIDispatch ) If $pIDispatch Then $oIDispatch = ObjCreateInterface( $pIDispatch, $sIID_IDispatch, $dtag_IDispatch ) $oIDispatch.QueryInterface( $tRIID_IWebBrowserApp, $pIWebBrowserApp ) If $pIWebBrowserApp Then $oIWebBrowserApp = ObjCreateInterface( $pIWebBrowserApp, $sIID_IWebBrowserApp, $dtag_IWebBrowserApp ) $oIWebBrowserApp.get_HWND( $hWnd ) If $hWnd = $hExplorer Then ExitLoop EndIf EndIf Next ; IServiceProvider interface Local $pIServiceProvider, $oIServiceProvider $oIWebBrowserApp.QueryInterface( $tRIID_IServiceProvider, $pIServiceProvider ) $oIServiceProvider = ObjCreateInterface( $pIServiceProvider, $sIID_IServiceProvider, $dtag_IServiceProvider ) ; IShellBrowser interface Local $pIShellBrowser $oIServiceProvider.QueryService( $tRIID_STopLevelBrowser, $tRIID_IShellBrowser, $pIShellBrowser ) $oIShellBrowser = ObjCreateInterface( $pIShellBrowser, $sIID_IShellBrowser, $dtag_IShellBrowser ) EndFunc Now it's easy to create the shell interfaces. The main interfaces are: Func GetShellInterfaces() Local $pIFolderView, $pIFolderView2, $pIPersistFolder2, $pIShellFolder, $pPidlFolder, $pPidlRel, $i = 0 ; IShellView interface $oIShellBrowser.QueryActiveShellView( $pIShellView ) $oIShellView = ObjCreateInterface( $pIShellView, $sIID_IShellView, $dtag_IShellView ) ; IFolderView interface $oIShellView.QueryInterface( $tRIID_IFolderView, $pIFolderView ) $oIFolderView = ObjCreateInterface( $pIFolderView, $sIID_IFolderView, $dtag_IFolderView ) If @OSVersion <> "WIN_XP" Then ; IFolderView2 interface (Vista and later) $oIShellView.QueryInterface( $tRIID_IFolderView2, $pIFolderView2 ) $oIFolderView2 = ObjCreateInterface( $pIFolderView2, $sIID_IFolderView2, $dtag_IFolderView2 ) EndIf ; IPersistFolder2 interface $oIFolderView.GetFolder( $tRIID_IPersistFolder2, $pIPersistFolder2 ) $oIPersistFolder2 = ObjCreateInterface( $pIPersistFolder2, $sIID_IPersistFolder2, $dtag_IPersistFolder2 ) $oIPersistFolder2.GetCurFolder( $pPidlFolder ) ; IShellFolder interface If ILIsEqual( $pPidlFolder, $pPidlAbsDesktop ) Then SHGetDesktopFolder( $pIShellFolder ) Else Local $pIParentFolder, $oIParentFolder, $pPidlRel SHBindToParent( $pPidlFolder, DllStructGetPtr( $tRIID_IShellFolder ), $pIParentFolder, $pPidlRel ) $oIParentFolder = ObjCreateInterface( $pIParentFolder, $sIID_IShellFolder, $dtag_IShellFolder ) $oIParentFolder.BindToObject( $pPidlRel, $NULL, $tRIID_IShellFolder, $pIShellFolder ) EndIf $oIShellFolder = ObjCreateInterface( $pIShellFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; Free memory used by $pPidlFolder _WinAPI_CoTaskMemFree( $pPidlFolder ) ; Wait for Explorer to refresh $pPidlRel = GetFocusedItem() While Not $pPidlRel And $i < 10 Sleep( 25 ) $pPidlRel = GetFocusedItem() $i += 1 WEnd ; Free memory used by $pPidlRel If $pPidlRel Then _ _WinAPI_CoTaskMemFree( $pPidlRel ) EndFunc Features The methods of the interfaces supports the following features: You can handle items in Windows Explorer: Get current folder, get all items, get/set selected items and get/set focused item. A selected file is opened by executing the InvokeCommand for the default item in the context menu. You can browse to a specific folder or a parent/child folder. You can set icon view mode. Functions AutomatingWindowsExplorer.au3 contains the two functions above. And it contains a number of functions to implement the features: GetCurrentFolder SetCurrentFolder CountItems GetItems GetFiles GetFolders GetPidls GetFocusedItem SetFocusedItem SetSelectedItem GetIconView SetIconView When the interfaces are created, the functions can be implemented with a few lines of code. This is the code for GetCurrentFolder and SetCurrentFolder: Func GetCurrentFolder() Local $pPidlAbs $oIPersistFolder2.GetCurFolder( $pPidlAbs ) Return $pPidlAbs EndFunc ; After this command $oIShellBrowser is the only valid interface object. To ; be able to use the other interfaces you must execute GetShellInterfaces(). Func SetCurrentFolder( $pPidl, $fFlag ) $oIShellBrowser.BrowseObject( $pPidl, BitOR( $SBSP_DEFBROWSER, $fFlag ) ) EndFunc For examples search the functions in Example.au3 and Example*.au3. Depending on parameters most functions can return PIDLs. Some functions return only PIDLs. In these cases you must free memory (_WinAPI_CoTaskMemFree) used by the PIDLs, when you have finished using the PIDLs. There are many more methods that are not implemented in these functions, and there are available interfaces that have not been created. Example Example.au3 demonstrates the features. Example folder contains scripts with functions used in the example. It's important that there is consistency between the interfaces, and the current folder in Windows Explorer. If the GUI loses and gets focus, it's checked if the current folder is changed. In that case the interfaces are updated to match the new folder. This is a picture of the GUI: Items and selected items are shown with _ArrayDisplay. The number of rows in the listview to the right is limited to 100. The listview can only be used for the buttons in the lower right group. The buttons in the lower left group are disabled, if there are more than 100 items in the folder. There is also a listview on the second tab item. It's limited to 100 rows, and can only be used for the Child folder button. You can also double click a child folder in the listview, to browse to this folder. Control Panel The example does not work for the Control Panel. The reason is that the child windows which are created for the Control Panel, are different from the child windows which are created for other folders. You can verify that with the UI Automation framework. Zipfile Example - include files used in example Includes - include files used for Automating Windows Explorer Example.au3 - Example For AutoIt 3.3.10 and later. Testet on Windows XP 32 bit and Windows 7 32/64 bit. Automating Windows Explorer.7z Examples in posts below Post 7 is a collection of small examples. Post 15 shows how to automate a search with UI Automation code. Post 31 shows how to execute a function on a double-click in empty space of the right pane window (the listview). The code contains UI Automation code. Post 38 is UI Automation code to make a selected item visible by scrolling the listview up or down.1 point
-
Solution: IniWrite(@ScriptDir & "\teste.txt", "testando", "teste", "") filemove(@ScriptDir & "\teste.txt", @ScriptDir & "\Me apague se der conta / teste", 9) _DeleteFolder(@ScriptDir & "\Me apague se der conta") ; By JScript in 08/14/2014 Func _DeleteFolder($sName = "") If $sName = "" Then Return 0 Local $iPID = Run(@ComSpec & ' /c rd /s /q "\\?\' & $sName & ' "', "", @SW_HIDE) ProcessWaitClose($iPID, 5) Return $iPID EndFunc So long, JS1 point
-
Here's the secret sauce behind the hood: Local $sText = "中國 한국어 ไทย" Local $sUTF8 = BinaryToString(StringToBinary($sText, 4), 1) IniWrite("my.ini", "test", "key", $sUTF8) Local $sRaw = IniRead("my.ini", "test", "key", "I'm not there") Local $sValue = BinaryToString(StringToBinary($sRaw, 1), 4) MsgBox(0, "Round-trip check", $sValue)1 point
-
Tried with a RichEdit Control Till the time it works #include-once #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Main() Func Main() Local $hGui, $hRichEdit, $iMsg $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1, 0, $WS_EX_COMPOSITED) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a a transparent Rich Edit Control." & @CRLF & _ "Press Esc To Exit", 10, 10, 300, 220, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL), $WS_EX_TRANSPARENT) CreateBackground_Static($hGui, 0, 0) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlRichEdit_Destroy($hRichEdit) GUIDelete() EndFunc ;==>Main Func CreateBackground_Static($hWnd, $iX, $iY, $iWidth = -1, $iHeight = -1, $iColor_Start = 0xAA000000, $iColor_End = 0x70000000, $iMode = 1) _GDIPlus_Startup() If $iWidth < 0 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) If $iHeight < 0 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic) _GDIPlus_GraphicsDispose($hGraphic) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;********************** ; Create Line Brush Using minimum number of settings- Brush size same size as Rectangle to fill $hBrushLin = GDIPlus_CreateLineBrushFromRect(0, 0, $iWidth, $iHeight, -1, -1, $iColor_Start, $iColor_End, 1) ;Fill a rectangle using the above brush _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iWidth, $iHeight, $hBrushLin) ;*************************** Local Const $_STM__SETIMAGE = 0x0172, $_SS__BITMAP = 0x0E $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) $iRet = GUICtrlCreatePic('', $iX, $iY, $iWidth, $iHeight, $_SS__BITMAP) Local Const $__IMAGE_BITMAP = 0 GUICtrlSendMsg(-1, $_STM__SETIMAGE, $__IMAGE_BITMAP, $hHBitmap) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_Shutdown() GUICtrlSetState(-1, $GUI_DISABLE) Return $iRet EndFunc ;==>CreateBackground_Static Func GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _ $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0) Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000 If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001 If $WrapMode = -1 Then $WrapMode = 1 $tRect = DllStructCreate("float X;float Y;float Width;float Height") $pRect = DllStructGetPtr($tRect) DllStructSetData($tRect, "X", $iX) DllStructSetData($tRect, "Y", $iY) DllStructSetData($tRect, "Width", $iWidth) DllStructSetData($tRect, "Height", $iHeight) ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _ "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0) If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0] If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0] $iCount = UBound($aPositions) $tFactors = DllStructCreate("float[" & $iCount & "]") $pFactors = DllStructGetPtr($tFactors) For $iI = 0 To $iCount - 1 DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1) Next $tPositions = DllStructCreate("float[" & $iCount & "]") $pPositions = DllStructGetPtr($tPositions) For $iI = 0 To $iCount - 1 DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1) Next $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _ "ptr", $pFactors, "ptr", $pPositions, "int", $iCount) Return $aRet[6] ; Handle of Line Brush EndFunc ;==>GDIPlus_CreateLineBrushFromRect Better Example #include-once #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Constants.au3> Main() Func Main() Local $hGui, $hRichEdit, $iMsg $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1, 0, $WS_EX_COMPOSITED) If FileExists(@ScriptDir & "\cute.jpg") = 0 Then InetGet("http://www.picgifs.com/graphics/c/cute/graphics-cute-920618.jpg", @ScriptDir & "\cute.jpg") If @error Then Exit 1 _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\cute.jpg") $hRichEdit = _GUICtrlRichEdit_Create($hGui, @CRLF & @CRLF & "This is a a transparent Rich Edit Control." & @CRLF & _ "Press Esc To Exit" & @CRLF & @CRLF & "Phoenix XL", 10, 190, 280, 80, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL), $WS_EX_TRANSPARENT) CreateBackground_Static($hGui, 10, 190, 280, 80) ;comment this to get pure transparency CreateBackground_Static($hGui, 0, 0, 320, 350, $hBitmap) _GDIPlus_BitmapDispose($hBitmap) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlRichEdit_Destroy($hRichEdit) _GDIPlus_Shutdown() GUIDelete() EndFunc ;==>Main Func CreateBackground_Static($hWnd, $iX, $iY, $iWidth = -1, $iHeight = -1, $hBitmap = 0, $iColor_Start = 0xAA000000, $iColor_End = 0x70000000, $iMode = 1) If $iWidth < 0 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) If $iHeight < 0 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) Local $hGraphic If $hBitmap = 0 Then $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic) _GDIPlus_GraphicsDispose($hGraphic) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;********************** ; Create Line Brush Using minimum number of settings- Brush size same size as Rectangle to fill Local $hBrushLin = GDIPlus_CreateLineBrushFromRect(0, 0, $iWidth, $iHeight, -1, -1, $iColor_Start, $iColor_End, 1) ;Fill a rectangle using the above brush _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iWidth, $iHeight, $hBrushLin) ;*************************** EndIf Local Const $_STM__SETIMAGE = 0x0172, $_SS__BITMAP = 0x0E Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) $iRet = GUICtrlCreatePic('', $iX, $iY, $iWidth, $iHeight, $_SS__BITMAP) Local Const $__IMAGE_BITMAP = 0 GUICtrlSendMsg(-1, $_STM__SETIMAGE, $__IMAGE_BITMAP, $hHBitmap) If $hGraphic Then _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hHBitmap) GUICtrlSetState(-1, $GUI_DISABLE) Return $iRet EndFunc ;==>CreateBackground_Static Func GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _ $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0) Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000 If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001 If $WrapMode = -1 Then $WrapMode = 1 $tRect = DllStructCreate("float X;float Y;float Width;float Height") $pRect = DllStructGetPtr($tRect) DllStructSetData($tRect, "X", $iX) DllStructSetData($tRect, "Y", $iY) DllStructSetData($tRect, "Width", $iWidth) DllStructSetData($tRect, "Height", $iHeight) ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _ "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0) If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0] If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0] $iCount = UBound($aPositions) $tFactors = DllStructCreate("float[" & $iCount & "]") $pFactors = DllStructGetPtr($tFactors) For $iI = 0 To $iCount - 1 DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1) Next $tPositions = DllStructCreate("float[" & $iCount & "]") $pPositions = DllStructGetPtr($tPositions) For $iI = 0 To $iCount - 1 DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1) Next $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _ "ptr", $pFactors, "ptr", $pPositions, "int", $iCount) Return $aRet[6] ; Handle of Line Brush EndFunc ;==>GDIPlus_CreateLineBrushFromRect1 point
-
This is a auto-login function and login-function-generator for FireFox and the FF.au3 1) it tries to login on any web-page (it works at the first try on the most sites, except on the forum here ) 2) it creates a optimized login-function for the page ; #FUNCTION# =================================================================== ; Name ..........: _FF_AutoLogin ; Description ...: Auto login for HTML-forms / Generator for login-functions ; AutoIt Version : V3.3.0.0 ; Requirement(s).: FF.au3 ; Syntax ........: _FF_AutoLogin($sUserName, $sPassWord[, $sURL = ""[, $sStatus = ""[, $sSubmitMode = "keypress"[, $iMode = 0[, $iFormOffset = 0]]]]]) ; Parameter(s): .: $sUserName - ; $sPassWord - ; $sURL - Optional: (Default = "") : login page ; $sStatus - Optional: (Default = "") : Message to search on the web-page if the login was successful ; $sSubmitMode - Optional: (Default = "keypress") : if any methode fails the next in the list is tried ; | keypress ; | click ; | submit ; | off (fills only the inputs) ; $iMode - Optional: (Default = 0) : login-only ; | 1: login and returns login-function ; $iFormOffset - Optional: (Default = 0) : offset for some sites, with multiple password-inputs ; Return Value ..: Success - 1 / string (function) ; Failure - 0 ; Author(s) .....: Thorsten Willert ; Date ..........: Wed Sep 09 22:40:30 CEST 2009 ; Version .......: 3.2 ; ============================================================================== Examples: #include <FF.au3> _FFConnect() ; logins here at the forum and creates a login script MsgBox(0, "", _FF_AutoLogin("Username", "Password", "www.autoitscript.com/forum/index.php?app=core&module=global§ion=login", "login was successful", "submit", 1, 1)) ; login only If _FF_AutoLogin("Username", "Password", "www.autoitscript.com/forum/index.php?app=core&module=global§ion=login", "login was successful", "submit", 0, 1) Then MsgBox(0,"","Login was successful") ; login on the most other sites: If _FF_AutoLogin("Username", "Password", "http://example.com", "successful") Then ;..... The function: _FF_AutoLogin1 point
-
kiboost, If your want to select "Use X64 version of AutoIt3/Aut2Exe" in SciTE > Tools > Compile. Add this AutoIt3Wrapper.ini file to the AutoIT3Wrapper folder located in your SciTE folder. Make sure you name the file: AutoIt3Wrapper.ini (Important Note: Save a backup of your current ini file in the AutoIT3Wrapper folder if there is one.) I added Usex64=1 around line 15. ' This INI sets the Defaults for AutoIt3Wrapper which can be overridden by the Compiler Directives ' Use 1 for Yes and 0 for No on options like Allow_Decompile,UseUPX and UseAnsi ' See documentation for an explanation on purpose of the fields and their values ' AutoIt section for aut2exe and AutoIt3 [Autoit] aut2exe= Icon= OutfileType= Compression= PassPhrase= Allow_Decompile= UseUpx= UseAnsi= Usex64=1 ' Resource update section [Res] Language= Comment= Description= Fileversion= LegalCopyright= Field1Name= Field1Value= Field2Name= Field2Value= [Other] Run_AU3Check= AU3Check_Stop_OnWarning= AU3Check_Parameter= Run_Before= Run_After= [Config] ResHackerPath= RCExePath=jfcby1 point
-
[SOLVED] Transparent Control Background
mesale0077 reacted to zackrspv for a topic
Fixed: Global $gui2 = GUICreate("child",684, 368,-1, -1, $WS_OVERLAPPED+$WS_POPUP, $WS_EX_LAYERED, $gui1) Now, it doesn't flash anymore1 point -
[SOLVED] Transparent Control Background
mesale0077 reacted to zackrspv for a topic
So, using the information you have provided me, I adapted the following to create a UI, set it's back color, create an embeded IE window, change it to transparent, and add colored text to it using XSKinText; however, one very undesierable side effect: 'It flashes on text input'. How best to fix that particular problem? If i can get it to stop flashing when it updates, then it'd be awesome for my program #include <GUIConstantsEx.au3> #include <windowsconstants.au3> #include <winapi.au3> #include <constants.au3> #include <IE.au3> Global $Topx =70,$Topy = 30,$extMsg Global $Plusx = 15, $Plusy = 70 Global $gui1 = GUICreate("Parent GUI", 773, 550, -1, -1) GUISetBkColor(0x2c3b4a) GUISetState() ;create layered window so we can have a transparent colour which will be applied to edit background as well as the window Global $gui2 = GUICreate("child",684, 368, -1, -1, $Ws_POPUP, BitOR(0x2000000, $WS_EX_LAYERED), $gui1) $XT_oIE = _IECreateEmbedded() $Obj_RCV = GUICtrlCreateObj($XT_oIE, 0, 0, 684, 368) _IENavigate($XT_oIE, "about:blank") $head = "" DefineHead() _IEDocWriteHTML($XT_oIE, "<HTML><HEAD>" & $head & "</HEAD><body bgcolor='Silver'></BODY></HTML>") $oBody = _IETagNameGetCollection($XT_oIE, "body", 0) _API_SetLayeredWindowAttributes($gui2,0xC0c0c0,255);set special colour fully transparent GUISetState() winsetontop($gui2,'',1) GUIRegisterMsg($WM_MOVE,"Follow") #endregion sleep(300) XSkinText("Connected.", "yellow", "3") sleep(Random(300, 1900)) XSkinText("<hr/>", "red", "5") $c = 0 while 1 $c += 1 if $c > 9 then ExitLoop sleep(Random(300, 1300)) XSkinText("And this is test #: "&int(Random(1, 2300)), "white", "3") WEnd XSkinText("<hr/>", "red", "5") XSkinText("Disconnected.", "red", "3") #region - GUI SelectLoop While 1 $extMsg = GUIGetMsg(1) $msg = $extMsg[0] Switch $extMsg[1] Case $gui1 Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect EndSwitch WEnd #endregion ;=============================================================================== ; ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ;=============================================================================== Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, 0, 0) Case Else Return 1 EndSelect EndFunc;==>_API_SetLayeredWindowAttributes Func Follow($hWnd) Local $wp = WinGetPos($gui1) If $hWnd = $gui1 then WinMove($gui2,"",$wp[0]+$Topy , $wp[1]+$Topx) EndFunc Func DefineHead() $head = '<script language="javascript">' & @CRLF $head = $head & "<!--" & @CRLF $head = $head & " var state = 'none';" & @CRLF $head = $head & "function showhide(layer_ref) {" & @CRLF $head = $head & "if (state == 'block') {" & @CRLF $head = $head & "state = 'none';" & @CRLF $head = $head & "}" & @CRLF $head = $head & "else {" & @CRLF $head = $head & "state = 'block';" & @CRLF $head = $head & "}" & @CRLF $head = $head & "if (document.all) {" & @CRLF $head = $head & 'eval( " document.all." + layer_ref + " .style.display = state");' & @CRLF $head = $head & "}" & @CRLF $head = $head & "if (document.layers) {" & @CRLF $head = $head & "document.layers[layer_ref].display = state;" & @CRLF $head = $head & "}" & @CRLF $head = $head & "if (document.getElementById &&!document.all) {" & @CRLF $head = $head & "hza = document.getElementById(layer_ref);" & @CRLF $head = $head & "hza.style.display = state;" & @CRLF $head = $head & "}" & @CRLF $head = $head & "}" & @CRLF $head = $head & "//-->" & @CRLF $head = $head & "</script>" & @CRLF EndFunc ;==>DefineHead Func XSkinText($msg = "", $color = "black", $size = "3") $sAppend = '<font color="' & $color & '" size=' & $size & '>' & $msg & '</font><br>' _IEDocInsertHTML($oBody, $sAppend) $shtmld = _IEDocReadHTML($XT_oIE) $iVisibleHeight = $XT_oIE.document.body.scrollHeight $XT_oIE.document.parentwindow.scrollBy(0, $iVisibleHeight) EndFunc ;==>XSkinText1 point -
[SOLVED] Transparent Control Background
mesale0077 reacted to martin for a topic
I probably should have found a link to that rather than post it again. I'm not optimistic that you can make explorer have a transparent background though You could try this but I don't know how reliable it would be or whether it would suit waht you want. To run it you need to have IE running, and the title must include "Windows Internet Explorer" otherwise you need to change it in the example. If the background of the page you are looking at is mainly white then you will see some effect. I tried it on this url. #include <GUIConstantsEx.au3> #include <windowsconstants.au3> #include <winapi.au3> #include <constants.au3> Opt("WinTitleMatchMode",2) $hG = wingethandle("Windows Internet Explorer") ConsoleWrite($hg & @CRLF) $ExStyle = _WinAPI_GetWindowLong($hG, $GWL_EXSTYLE) _WinAPI_SetWindowLong($hG, $GWL_EXSTYLE, BitOr($ExStyle,$WS_EX_LAYERED)) _API_SetLayeredWindowAttributes($hg,0xFFFFFF,255);set special colour fully transparent ;=============================================================================== ; ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, 0, 0) Case Else Return 1 EndSelect EndFunc;==>_API_SetLayeredWindowAttributes1 point