Sign in to follow this  
Followers 0
islandspapand

Help !!! transperency on Lbls and Icons

6 posts in this topic

#1 ·  Posted (edited)

Hi

i have some problemes in gettings my Lables and icons to be transperent,

i can make my labels transperent with guictrlsetbgkcolor(-1,"-2") but then the texts look weird. As it is to thick

i can't get my icons to be transpent either Plz Plz Plz some help me

Ps. is there any way i can change the default push button to the currenly active button?

#cs*****************************************
Proxy_Switch.au3 by Krabbe
Created with ISN AutoIt Studio v. 0.94 BETA
Created with ISN Form Studio 2 for ISN AutoIt Studio
Script Version: 1.0
Last Modified: 21-11-2013
Script Function:
Enable and Disable proxy settings in IE as user don't normaly know the path

#ce*****************************************

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
#Include <GuiButton.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <IE.au3>

Global $WlanInf[7]
Global $LanInf[7]
Global $PXYSVR = "proxy.intranet.ap"
Global $PXYPRT = "80"
Global $RegKeyLoc = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Global $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20
Global $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
Global $hImage = @Scriptdir& "\Images\hGUI1.png"
Global $cImage = @Scriptdir& "\Images\cGUI.gif"
Global $hGUI, $cGUI, $BtnEnableDisable, $BtnExit
Global $LblCurrentConnect, $LblCurrentState, $LblSuggestSetting
Global $RegGetProxyCurAdr, $RegGetProxyState

#cs==========$WlanInf============   #cs==========$LanInf=============
| [0] = Name                    |   | [0] = Name                    |
| [1] = MacAdress               |   | [1] = MacAdress               |
| [2] = Connect True/False      |   | [2] = Connect True/False      |
| [3] = Connected 2 Domain name |   | [3] = Connected 2 Domain name |
| [4] = Your Computer Domain    |   | [4] = Your Computer Domain    |
| [5] = IpAdress                |   | [5] = IpAdress                |
| [6] = Gateway                 |   | [6] = Gateway                 |
#ce==============================   #ce==============================
;====================================== Start GDI Magic ================================

_GDIPlus_Startup()                                ; Initialize GDI+ library
$hImage = _GDIPlus_ImageLoadFromFile($hImage) ; Main GUI Bckg Img
$width = _GDIPlus_ImageGetWidth($hImage)          ; Img Width  | GUI Width
$height = _GDIPlus_ImageGetHeight($hImage)        ; Img Height | GUI Height


_MainUI()

Func _MainUI()
Global $hGUI = GUICreate("MSI Recovery Image Finder", $width, $height, -1, -1, $WS_POPUP,$WS_EX_LAYERED)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState(@SW_SHOW,$hGUI)
 For $i = 0 To 240 Step 10
   SetBitmap($hGUI, $hImage, $i)
   Sleep(10)
 Next

Global $cGUI = GUICreate('childgui', $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD,$GUI_WS_EX_PARENTDRAG), $hGUI)
$ChildBckg = GUICtrlCreatePic($cImage, 0, 0, $width, $height)
GUICtrlSetBkColor($ChildBckg, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState($ChildBckg, $GUI_DISABLE)

Global $BtnEnable = GUICtrlCreateButton("Enable",75,85,60,20,$BS_DEFPUSHBUTTON,-1)
GUICtrlSetFont(-1,8,400,0,"Constantia")

Global $BtnDisable = GUICtrlCreateButton("Disable",165,85,60,20,$BS_DEFPUSHBUTTON,-1)
GUICtrlSetFont(-1,8,400,0,"Constantia")

Global $LblCurrentSetting = GUICtrlCreateLabel("",226,35,42,15,-1,-1)
GUICtrlSetFont($LblCurrentSetting,8,400,0,"Constantia")

Global $LblSuggestSetting = GUICtrlCreateLabel("",226,50,42,15,-1,-1)
GUICtrlSetFont($LblSuggestSetting,8,400,0,"Constantia")

Global $LblCurrentConnect = GUICtrlCreateLabel("proxy.intranet.ap:80",173,65,95,15,-1,-1)
GUICtrlSetFont($LblCurrentConnect,8,100,0,"Constantia")
;~ GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)

Global $IcnExit = GUICtrlCreateIcon("imageres.dll",98,267,10,16,16,-1,-1)
GUICtrlSetBkColor($IcnExit,$GUI_BKCOLOR_TRANSPARENT)

Global $IcnHelp = GUICtrlCreateIcon("imageres.dll",99,249,10,16,16,-1,-1)
GUICtrlSetBkColor($IcnHelp,0x373737)

_GetCurrentProxyState()
_GetActiveSSID()
GUISetState(@SW_SHOW,$cGUI)




    
While 1

_ChkIfProxyStateChanged()
$nMsg = GUIGetMsg()
    Switch $nMsg
        
        Case $GUI_EVENT_CLOSE, $IcnExit
            Exit
        
        Case $IcnHelp
            MsgBox(16,"Help","Coming Soon")
            
        Case $BtnEnable
            $RegWriteProxyEnable = RegWrite($RegKeyLoc, "ProxyEnable", "REG_DWORD", "1")
            DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
            $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
            If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") =  Failed  >Error code: ' & @error & @crlf) ;### Debug Console
            BitAND(GUICtrlSetState($BtnDisable,$GUI_ENABLE),GUICtrlSetState($BtnEnable,$GUI_DISABLE))
            BitAND(GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr),GUICtrlSetData($LblCurrentSetting,"Enabled"))
            
            
        Case $BtnDisable
            $RegWriteProxyDisable = RegWrite($RegKeyLoc, "ProxyEnable", "REG_DWORD", "0")
            DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
            $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
            If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") =  Failed  >Error code: ' & @error & @crlf) ;### Debug Console
            BitAND(GUICtrlSetState($BtnDisable,$GUI_DISABLE),GUICtrlSetState($BtnEnable,$GUI_ENABLE))
            BitAND(GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr),GUICtrlSetData($LblCurrentSetting,"Disabled"))
            
    EndSwitch
WEnd
EndFunc

Func _GetCurrentProxyState()
$RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") =  Failed  >Error code: ' & @error & @crlf) ;### Debug Console
ConsoleWrite('$RegGetProxyCurAdr = ' & $RegGetProxyCurAdr & '   >Error code: ' & @error & @crlf) ;### Debug Console
;~ If $RegGetProxyCurAdr <> "proxy.intranet.ap:80" Then
;~      $RegWriteProxyAdr = RegWrite($RegKeyLoc, "ProxyServer", "REG_SZ", $PXYSVR & ":" & $PXYPRT)
;~      DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
;~      $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
;~      GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr)
;~  Else
;~      $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer")
;~      GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr)
;~ EndIf
$RegGetProxyState = RegRead($RegKeyLoc,"ProxyEnable")
ConsoleWrite('$RegGetProxyState = ' & $RegGetProxyState & ' >Error code: ' & @error & @crlf) ;### Debug Console
If $RegGetProxyState = 0 Then BitAND(GUICtrlSetData($LblCurrentState,"Disabled"),GUICtrlSetState($BtnEnable,$GUI_ENABLE),GUICtrlSetState($BtnDisable,$GUI_DISABLE))
If $RegGetProxyState = 1 Then BitAND(GUICtrlSetData($LblCurrentState,"Enabled"),GUICtrlSetState($BtnEnable,$GUI_DISABLE),GUICtrlSetState($BtnDisable,$GUI_ENABLE))
EndFunc

Func _ChkIfProxyStateChanged()
$RegGetProxyState = RegRead($RegKeyLoc,"ProxyEnable")
ConsoleWrite('Current Proxy State = ' & $RegGetProxyState & '   >Error code: ' & @error & @crlf)

; If user changes proxy manualy while the prg is running
If GUICtrlRead($LblCurrentSetting)="Enabled" And $RegGetProxyState = 0 Then
        GUICtrlSetState($BtnDisable,$GUI_DISABLE)
        GUICtrlSetState($BtnEnable,$GUI_ENABLE)
        GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr)
        GUICtrlSetData($LblCurrentSetting,"Disabled")
EndIf

; If user changes proxy manualy while the prg is running    
If GUICtrlRead($LblCurrentSetting)="Disabled" And $RegGetProxyState = 1 Then
        GUICtrlSetState($BtnDisable,$GUI_ENABLE)
        GUICtrlSetState($BtnEnable,$GUI_DISABLE)
        GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr)
        GUICtrlSetData($LblCurrentSetting,"Enabled")
EndIf

EndFunc

Func _GetActiveSSID()
Global $Output = "", $colItems = "", $colItems1 = ""

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
   For $objItem In $colItems
    If StringInStr($objItem.Caption,"Intel") Then
        If $objItem.NetConnectionID = "Wireless Network Connection" Then
            $WlanInf[0] = $objItem.Description
            $WlanInf[1] = $objItem.MACAddress
            $WlanInf[2] = $objItem.NetEnabled
        ElseIf  $objItem.NetConnectionID = "Local Area Connection" Then
            $LanInf[0] = $objItem.Description
            $LanInf[1] = $objItem.MACAddress
            $LanInf[2] = $objItem.NetEnabled
        EndIf
        $Output=""
    EndIf
   Next
Else
   Msgbox(0,"WMI Output ERROR","No WMI Objects Found for class: " & "Win32_NetworkAdapter",2)
   SetError(1,0,"Error in WMI Win32_NetworkAdapter")
Endif

$colItems1 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems1) then
   For $objItem In $colItems1
    If StringInStr($objItem.Caption,"Intel") <> 0 Then
        If BitAND($WlanInf[1] = $objItem.MACAddress, $WlanInf[0] = $objItem.Description) Then
            $WlanInf[3] = $objItem.DNSDomain
            $WlanInf[4] = $objItem.DNSDomainSuffixSearchOrder(0)
            $WlanInf[5] = $objItem.IPAddress(0)
            $WlanInf[6] = $objItem.DefaultIPGateway(0)
        ElseIf BitAND($LanInf[1] = $objItem.MACAddress, $LanInf[0] = $objItem.Description) Then
            $LanInf[3] = $objItem.DNSDomain
            $LanInf[4] = $objItem.DNSDomainSuffixSearchOrder(0)
            $LanInf[5] = $objItem.IPAddress(0)
            $LanInf[6] = $objItem.DefaultIPGateway(0)
        EndIf 
    EndIf
   Next
Else
   Msgbox(0,"WMI Output ERROR","No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration",2)
   SetError(2,0,"Error in WMI Win32_NetworkAdapterConfiguration")
Endif

If $LanInf[3] <> "intranet.ap" Then 
    GUICtrlSetData($LblSuggestSetting,"Disabled")
Else
    GUICtrlSetData($LblSuggestSetting,"Enabled")
EndIf

EndFunc  

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $hGUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc

Func SetBitmap($hGUI, $hImage, $iOpacity)
    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)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc

post-62798-0-26861300-1385380029_thumb.p

post-62798-0-79065300-1385380038_thumb.g

Edited by islandspapand

Share this post


Link to post
Share on other sites



Ps. is there any way i can change the default push button to the currenly active button?

 

You can use the button style $BS_DEFPUSHBUTTON

Your main problem is the graphic part, that is how your GUI should look. Then can you provide an image of how your GUI should look ?

Regards :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks allot,

I was thinking that i want both Buttons to have $bs_defpushbutton, so the enabled button is the default push.

What sould i do to change between the Buttons as i guess there ONLY can Be One default push.

Picture of disired GUI add'ed (still with the grey around the icons and Labels that i wish to remove)
 

post-62798-0-46032900-1385384145_thumb.p

Edited by islandspapand

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Graphics part

Here we go

#include-once
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>

Global $hImage = @ScriptDir & "\Images\hGUI1.png"

_GDIPlus_Startup() ; Initialize GDI+ library
$hImage = _GDIPlus_ImageLoadFromFile($hImage) ; Main GUI Bckg Img
$width = _GDIPlus_ImageGetWidth($hImage) ; Img Width  | GUI Width
$height = _GDIPlus_ImageGetHeight($hImage) ; Img Height | GUI Height


_MainUI()

Func _MainUI()
    Global $hGUI = GUICreate("MSI Recovery Image Finder", $width, $height, -1, -1, $WS_POPUP,$WS_EX_LAYERED)
    GUISetState(@SW_SHOW, $hGUI)

    Global $cGUI = GUICreate('childgui', $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI)
    GUISetBkColor(0xFFFFFF)
    _WinAPI_SetLayeredWindowAttributes($cGUI, 0xFFFFFF)

    Global $BtnDisable = GUICtrlCreateButton("Disable", 165, 85, 60, 20)
    GUICtrlSetFont(-1, 8, 400, 0, "Constantia")

    Global $BtnEnable = GUICtrlCreateButton("Enable", 75, 85, 60, 20)
    GUICtrlSetFont(-1, 8, 400, 0, "Constantia")

    GUICtrlSetDefBkColor($GUI_BKCOLOR_TRANSPARENT)

    Global $LblCurrentSetting = GUICtrlCreateLabel("Enabled", 226, 40, 42, 15, -1, -1)
    Global $LblSuggestSetting = GUICtrlCreateLabel("Enabled", 226, 52, 42, 15, -1, -1)


    Global $LblCurrentConnect = GUICtrlCreateLabel("proxy.intranet.ap:80", 173, 65, 95, 15)
    GUICtrlSetFont($LblCurrentConnect, 8, 100, 0, "Constantia")
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    Global $IcnExit = GUICtrlCreateIcon("imageres.dll", 98, 267, 10, 16, 16, BitOR($SS_ICON, $SS_NOTIFY))
    Global $IcnHelp = GUICtrlCreateIcon("imageres.dll", 99, 249, 10, 16, 16, $BS_ICON)

    GUISetState(@SW_SHOW, $cGUI)

    For $i = 0 To 240 Step 10
        SetBitmap($hGUI, $hImage, $i)
        Sleep(10)
    Next


    While 1

        $nMsg = GUIGetMsg()
        Switch $nMsg

            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $GUI_EVENT_PRIMARYDOWN
                _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0) ;SC_DRAGMOVE = 0xF012

            Case $BtnEnable
                GUICtrlSetState($BtnEnable, $GUI_DISABLE)
                GUICtrlSetState($BtnDisable, $GUI_ENABLE)
                GUICtrlSetState($BtnDisable, $GUI_FOCUS)


            Case $BtnDisable
                GUICtrlSetState($BtnDisable, $GUI_DISABLE)
                GUICtrlSetState($BtnEnable, $GUI_ENABLE)
                GUICtrlSetState($BtnEnable, $GUI_FOCUS)

        EndSwitch
    WEnd

    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

EndFunc   ;==>_MainUI

Func SetBitmap($hGUI, $hImage, $iOpacity)
    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)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap 

Regards :)

Phoenix XL

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thank you sooooooooooooo much Phoenix XL :D

i was playing around with the     GUISetBkColor(0xABCDEF)   _WinAPI_SetLayeredWindowAttributes($cGUI, 0xABCDEF) could just not get it to work :P

Could you expaind this part to me?

    

        Case $GUI_EVENT_PRIMARYDOWN
                _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0) ;SC_DRAGMOVE = 0xF012

if i want the blue around the labels to dissaper then i sould just change to the same color as my background?

Edited by islandspapand

Share this post


Link to post
Share on other sites

The painting occurs with respect to the bkcolor of the layered window.

I have modified the code (the bkcolor and a bit cleanup), check it by yourself.

_SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0) ;SC_DRAGMOVE = 0xF012

 

It is responsible to move the GUI whenever you drag the main GUI(instead of hittesting, this is preferred).

Regards :)

Phoenix XL


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • GordonFreeman
      By GordonFreeman
      Hi, i searched some topics but cannot found a simple way to do that:
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) GUISetState(@SW_SHOW) ; I tried this but user reported that it work in 2006, not seems work actually $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu) GuiCtrlSetImage($fileitem, "shell32.dll", 4) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Also tried:
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) GUISetState(@SW_SHOW) $filemenu = TrayCreateMenu("&File") $fileitem = TrayCreateItem("Open",$filemenu) ;GuiCtrlSetImage($fileitem, "shell32.dll", 4) ;GuiCtrlSetImage(TrayItemGetHandle($fileitem), "shell32.dll", 4) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Well.. thanks in advance!
       
      Ok. I found this working example from Yashied. If i cannot find a simple then i will go with it
      #Include <GUIConstantsEx.au3> #Include <GUIMenu.au3> #Include <Constants.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $hMenu, $hForm, $hFile = 1000, $idNew, $idExit $hForm = GUICreate('Menu', 400, 300) $hFile = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem ($hFile, 0, ' &Favorites', $idNew) _GUICtrlMenu_InsertMenuItem ($hFile, 1, '', 0) _GUICtrlMenu_InsertMenuItem($hFile, 2, ' E&xit', $idExit) $hMenu = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hMenu, 0, '&File', 0, $hFile) _GUICtrlMenu_SetMenu($hForm, $hMenu) _GUICtrlMenu_SetItemBmp($hFile, 0, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\shell32.dll', 43, 16, 16)) _GUICtrlMenu_SetItemBmp($hFile, 2, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\shell32.dll', 27, 16, 16)) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _CreateBitmapFromIcon($iBackground, $sIcon, $iIndex, $iWidth, $iHeight) Local $hDC, $hBackDC, $hBackSv, $hIcon, $hBitmap $hDC = _WinAPI_GetDC(0) $hBackDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight) $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap) $hIcon = _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) If Not @error Then _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, $DI_NORMAL) _WinAPI_DestroyIcon($hIcon) EndIf _WinAPI_SelectObject($hBackDC, $hBackSv) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteDC($hBackDC) Return $hBitmap EndFunc ;==>_CreateBitmapFromIcon Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd') Local $Ret = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then Return SetError(1, 0, 0) EndIf Return $hIcon EndFunc ;==>_WinAPI_PrivateExtractIcon Ok, i noticed that is a pain create submenu with _GUICtrlMenu_CreatePopup to do like in Tray, and Tray better located, then i need images/icon with Tray functions, some workaround?? 
    • WoodGrain
      By WoodGrain
      Hi All,
      I'm using UseTraySetIcon("shell32.dll", xx) to set my tray icon to a specific icon while running, is there a way I can specify this icon when I compile my script into an exe so my exe icon is the same?
      Thanks!
    • nacerbaaziz
      By nacerbaaziz
      Hi guys
      I have an inquiry please
      I want an example of how to add an icon file to the compiled autoit file and how to use it in GUICtrlCreateIcon
      Preferably in a separate list within the resourceFor example myIcons
      I hope my request is clear and I hope you will help me solve this problem
      Because I found an example in the help files but I did not understand the method well
    • amimemeami
      By amimemeami
      I have a simple script that switches between IE and Chrome for the default browser, I even made a custom half chrome half ie icon for it. Question is, can I have the script toggle between two icons to signify the last browser it changed to? I would have the active browser's half of the icon in color, and inactive half grey scale. As a workaround, I put link next to it, and refresh the icon cache after it runs. 
      #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\..\Icons\IE_Chrome.ico #AutoIt3Wrapper_Outfile=..\..\..\..\Users\dmking\Desktop\Browser Switcher.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $sCurrentDefault = RegRead('HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice',"ProgId") if $sCurrentDefault = "IE.HTTP" Then     ChromeDefault() Else     IEDefault() EndIf ;~ Run("ie4uinit.exe -ClearIconCache") Run("C:\Windows\System32\ie4uinit.exe -ClearIconCache") Func IEDefault()     RegWrite("HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice","Progid","REG_SZ","IE.FTP")     RegWrite("HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice","Progid","REG_SZ","IE.HTTP")     RegWrite("HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice","Progid","REG_SZ","IE.HTTPS")     RegWrite("HKCU\Software\Clients\StartMenuInternet","","REG_SZ","IEXPLORE.EXE") EndFunc Func ChromeDefault()     RegWrite("HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice","Progid","REG_SZ","ChromeHTML")     RegWrite("HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice","Progid","REG_SZ","ChromeHTML")     RegWrite("HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice","Progid","REG_SZ","ChromeHTML")     RegWrite("HKCU\Software\Clients\StartMenuInternet","","REG_SZ","Google Chrome") EndFunc  
    • Masum
      By Masum
      Hi all,
      Can the default Koda icon for forms be changed? If so, how?
      Thanks