Jump to content

UAC logo in GUI


Crash
 Share

Recommended Posts

Hi, I am curious how other software have an UAC logo in their GUI. ESET Smart Security and Avira have it. I don't think they go around and insert a picture for that, but uses some sort of scripts. Because in Vista, it appears as the default 4 colours while in Win7, it appears as the 2-coloured logo, or to be simple, the logo is not the same as in Vista. You can see that they uses scripts, but not by inserting pictures. Is there any scripts in AutoIt to do this?

post-53187-12580833314226_thumb.jpg

JPGRARMouse Lock | My website | Thanks so much for your help! ❤️

Link to comment
Share on other sites

Maybe you can GUICtrlSetImage and add a picture to the button.

The help file says

A Button control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage to specify the picture to use.

I kept pressing cancel on your picture and was wondering why it wouldn't close. :)
Link to comment
Share on other sites

I think those UAC shields are placed there by Windows Vista/7 automatically when it detects an action the requires elevation...not sure if this works with AutoIt though(Probably not)...

Anyway, you can use the actual UAC icon from imagres.dll like this:

$UACButton = GUICtrlCreateButton("OK", 0, 0, 75, -1, BitOr(-1, $BS_ICON))
If @OSVersion < "WIN_VISTA" Then
    GUICtrlSetImage(-1, "imageres.dll", 78, 0)
EndIf

Confirmed working on both Vista and 7...and the UAC logo won't appear on XP or lower.

Hope that's what you wanted :)

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

GUICreate("Title", 100, 100)
$Button = GUICtrlCreateButton("&Ok", 15, 38, 70, 24)
GUICtrlSendMsg($Button, $BCM_SETSHIELD, 0, 1)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $Button
            MsgBox(0x40, "Title", "Text")
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
    EndSwitch
WEnd

Link to comment
Share on other sites

  • Moderators

TurionAltec,

So make the window a little wider! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I think those UAC shields are placed there by Windows Vista/7 automatically when it detects an action the requires elevation...not sure if this works with AutoIt though(Probably not)...

Anyway, you can use the actual UAC icon from imagres.dll like this:

$UACButton = GUICtrlCreateButton("OK", 0, 0, 75, -1, BitOr(-1, $BS_ICON))
If @OSVersion < "WIN_VISTA" Then
    GUICtrlSetImage(-1, "imageres.dll", 78, 0)
EndIf

Confirmed working on both Vista and 7...and the UAC logo won't appear on XP or lower.

Hope that's what you wanted :)

The If statement is syntacticly incorrect and yes it will work, even without the If statement because the file imageres.dll is not available in XP and lower.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

hmm, coming back to the original question, i dont know if Crash did want to mean this, but i would like to know if AutoIT's scripts can get the imageres icon automatically and not be programmed

1) as mentioned above, avira and other few products get this - and i have a feeling it should be the OS which assigns the image and not the programmers.

2) if we program it to show the image it might give a wrong impression that it is compatible with vista UAC and it is the OS which assigned it (of course, its not an issue, but the programmer will have to double check all the requisites for that button to appear so that the user doesnt get misleaded...

for simple scripts it might be very easy solution to use the imageres.dll - i do like the solutions posted.. but my question is if AutoIT scripts can get the elevation assigned by Windows and not the programmer..

this is like with windows xp / above u have an update to be installed, u get an option with shutdwn button which indicates there is an update tbe installed before shutting down!!

post-44936-12581922938577_thumb.jpg

Link to comment
Share on other sites

Straight from the help file... An alternative... :)

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>

Opt("MustDeclareVars", 1)

Global $btn, $btn2

; Note the controlId from these buttons can NOT be read with GuiCtrlRead

_Main()

Func _Main()
 Local $hGUI

 $hGUI = GUICreate("Buttons", 400, 400)

 $btn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 90, 30)
 _GUICtrlButton_SetShield($btn)

 $btn2 = _GUICtrlButton_Create($hGUI, "Button2", 10, 60, 90, 30, $BS_SPLITBUTTON)
 _GUICtrlButton_SetShield($btn2)

 GUISetState()

 While 1
 Switch GUIGetMsg()
 Case $GUI_EVENT_CLOSE
 ExitLoop
 EndSwitch
 WEnd

 Exit

EndFunc ;==>_Main

P.S. I just tested it on XP SP3, and the button works perfect with no shield. ;)

If your wanting to verify that UAC is enabled before displaying the shield, then do something like this...

If RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLUA") > 0 Then
        GUICtrlSetImage($ButtonHandle, "imageres.dll", -2, 0)
    EndIf

1) as mentioned above, avira and other few products get this - and i have a feeling it should be the OS which assigns the image and not the programmers.

I believe this is incorrect. You must specify that the button being pressed is going to require permission elevation.

Developer assigned.

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

I believe this is incorrect. You must specify that the button being pressed is going to require permission elevation.

Developer assigned.

thanks for the clarification, i was under the impression it was OS assigned. if this was gonna be the case, i would have added the part you have just done (verify if UAC is turned on)

:);)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...