Sign in to follow this  
Followers 0

UAC Prompt Help

10 posts in this topic

#1 ·  Posted

Okay, basically I've been trying to make a hotfix for when this happens:

Posted Image

I've looked through the documentation, however I can't figure out how to activate it and title matching doesn't seem to want to work. Anyone know how to activate the prompt?


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

Current Projects:

IRC UDF, for IRC activities

[u]SafeExecute[/u], for picking and choosing what commands you want Execute to be able to run.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Why not just use #RequireAdmin at the beginning of your script?

Because it's not my script that is using causing the UAC prompt. It's a different program Secondily, I'm not trying to automate launching a program as admin. I'm trying to activate a window.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

Current Projects:

IRC UDF, for IRC activities

[u]SafeExecute[/u], for picking and choosing what commands you want Execute to be able to run.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Not really beautiful, but works as a last resort...

#include <winapi.au3>

While 1
    Sleep(250)
    If ProcessExists("consent.exe") Then
        $aWinList = _WinGetAltTabWinList()
        For $i = 0 To $aWinList[0][0]
            If Not ProcessExists("consent.exe") Then ExitLoop
            Send("{ALTDOWN}")
            Send("{TAB " & $i + 1 & "}")
            Send("{ALTUP}")
        Next
    EndIf
WEnd

; http://www.autoitscript.com/forum/topic/90282-wingetalttabwinlist/
; ===============================================================================================================================
; Func _WinGetAltTabWinList($sTitle="",$sText="",$bGetClassName=False)
;
; Returns list of visible Alt-Tab-able windows.
;
; $sTitle = (optional) Title of window, or window handle to send to initial WinList() call
; $sText = (optional) Visible text in window, same as WinList() call
; $bGetClassName = If True, a 3rd column will be created in the array containing the Window's class name
;
; Returns:
;    Success: An array of Windows in the same style as WinList, with an optional 3rd column (depending on $bGetClassName):
;        [0][0]  = Count of Windows
;        [$i][0] = Window Title
;        [$i][1] = Window Handle
;      And optionally (if $bGetClassName=True):
;        [$i][2] = Window Class Name
;    Failure: A 1-element array same as WinList, with [0][0] = 0, and @error set
;        @error = 0 = WinList returned matches, but nothing matched Alt-Tab-able windows
;        @error = 1 = WinList return no matches
;
; Author: Ascend4nt (based on code by Authenticity)
; ===============================================================================================================================

Func _WinGetAltTabWinList($sTitle = "", $sText = "", $bGetClassName = False)
    Local $aWinList, $i2ndDim = 2, $iCount = 0, $iExStyle

    ; Since passing an empty string or 'Default' keyword for 1st parameter
    ;  causes WinList to return incorrect results, we test first
    If $sTitle <> "" Then
        $aWinList = WinList($sTitle, $sText)
    Else
        $aWinList = WinList()
    EndIf

    ; Does the caller want the Class name also?
    If $bGetClassName Then $i2ndDim += 1

    ; Set initial dimensions to match WinList's, + any extra column(s)
    Dim $aAltTabList[$aWinList[0][0] + 1][$i2ndDim]
    $aAltTabList[0][0] = 0 ; zero count out for possible error returns

    ; Check to see if any Windows matched, given the parameters. If not, return empty list
    If $aWinList[0][0] = 0 Then Return SetError(1, 0, $aAltTabList)

    For $i = 1 To $aWinList[0][0]
        If BitAND(WinGetState($aWinList[$i][1]), 2) Then ; Is it Visible?
            $iExStyle = _WinAPI_GetWindowLong($aWinList[$i][1], -20) ; Get Extended Style bits
            ; Extended Style bits WS_EX_NOACTIVATE (0x08000000) and WS_EX_TOOLWINDOW (0x80) indicate non-Alt-Tab windows,
            ;    but if bit WS_EX_APPWINDOW (0x040000) is set, then it is still Alt-Tab-able
            If BitAND($iExStyle, 0x08000080) = 0 Or BitAND($iExStyle, 0x040000) Then
                $iCount += 1
                $aAltTabList[$iCount][0] = $aWinList[$i][0]
                $aAltTabList[$iCount][1] = $aWinList[$i][1]
                If $bGetClassName Then $aAltTabList[$iCount][2] = _WinAPI_GetClassName($aWinList[$i][1])
            EndIf
        EndIf
    Next

    ; Redimension array to results size
    ReDim $aAltTabList[$iCount + 1][$i2ndDim]
    $aAltTabList[0][0] = $iCount

    Return $aAltTabList
EndFunc   ;==>_WinGetAltTabWinList

Share this post


Link to post
Share on other sites

#5 ·  Posted

Not really beautiful, but works as a last resort...

#include <winapi.au3>

While 1
    Sleep(250)
    If ProcessExists("consent.exe") Then
        $aWinList = _WinGetAltTabWinList()
        For $i = 0 To $aWinList[0][0]
            If Not ProcessExists("consent.exe") Then ExitLoop
            Send("{ALTDOWN}")
            Send("{TAB " & $i + 1 & "}")
            Send("{ALTUP}")
        Next
    EndIf
WEnd

; http://www.autoitscript.com/forum/topic/90282-wingetalttabwinlist/
; ===============================================================================================================================
; Func _WinGetAltTabWinList($sTitle="",$sText="",$bGetClassName=False)
;
; Returns list of visible Alt-Tab-able windows.
;
; $sTitle = (optional) Title of window, or window handle to send to initial WinList() call
; $sText = (optional) Visible text in window, same as WinList() call
; $bGetClassName = If True, a 3rd column will be created in the array containing the Window's class name
;
; Returns:
;   Success: An array of Windows in the same style as WinList, with an optional 3rd column (depending on $bGetClassName):
;       [0][0]  = Count of Windows
;       [$i][0] = Window Title
;       [$i][1] = Window Handle
;     And optionally (if $bGetClassName=True):
;       [$i][2] = Window Class Name
;   Failure: A 1-element array same as WinList, with [0][0] = 0, and @error set
;       @error = 0 = WinList returned matches, but nothing matched Alt-Tab-able windows
;       @error = 1 = WinList return no matches
;
; Author: Ascend4nt (based on code by Authenticity)
; ===============================================================================================================================

Func _WinGetAltTabWinList($sTitle = "", $sText = "", $bGetClassName = False)
    Local $aWinList, $i2ndDim = 2, $iCount = 0, $iExStyle

    ; Since passing an empty string or 'Default' keyword for 1st parameter
    ;  causes WinList to return incorrect results, we test first
    If $sTitle <> "" Then
        $aWinList = WinList($sTitle, $sText)
    Else
        $aWinList = WinList()
    EndIf

    ; Does the caller want the Class name also?
    If $bGetClassName Then $i2ndDim += 1

    ; Set initial dimensions to match WinList's, + any extra column(s)
    Dim $aAltTabList[$aWinList[0][0] + 1][$i2ndDim]
    $aAltTabList[0][0] = 0 ; zero count out for possible error returns

    ; Check to see if any Windows matched, given the parameters. If not, return empty list
    If $aWinList[0][0] = 0 Then Return SetError(1, 0, $aAltTabList)

    For $i = 1 To $aWinList[0][0]
        If BitAND(WinGetState($aWinList[$i][1]), 2) Then ; Is it Visible?
            $iExStyle = _WinAPI_GetWindowLong($aWinList[$i][1], -20) ; Get Extended Style bits
            ; Extended Style bits WS_EX_NOACTIVATE (0x08000000) and WS_EX_TOOLWINDOW (0x80) indicate non-Alt-Tab windows,
            ;   but if bit WS_EX_APPWINDOW (0x040000) is set, then it is still Alt-Tab-able
            If BitAND($iExStyle, 0x08000080) = 0 Or BitAND($iExStyle, 0x040000) Then
                $iCount += 1
                $aAltTabList[$iCount][0] = $aWinList[$i][0]
                $aAltTabList[$iCount][1] = $aWinList[$i][1]
                If $bGetClassName Then $aAltTabList[$iCount][2] = _WinAPI_GetClassName($aWinList[$i][1])
            EndIf
        EndIf
    Next

    ; Redimension array to results size
    ReDim $aAltTabList[$iCount + 1][$i2ndDim]
    $aAltTabList[0][0] = $iCount

    Return $aAltTabList
EndFunc   ;==>_WinGetAltTabWinList

Not pretty, it works, however is there any other ways other than this. I'll use this for now until I find a better way.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

Current Projects:

IRC UDF, for IRC activities

[u]SafeExecute[/u], for picking and choosing what commands you want Execute to be able to run.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Not pretty...

Heard of the term don't look a gift horse in the mouth? If not look it up!

UDF List:

 

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

 

 

Updated: 02/04/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted

Heard of the term don't look a gift horse in the mouth? If not look it up!

Just did. Interesting.


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

Current Projects:

IRC UDF, for IRC activities

[u]SafeExecute[/u], for picking and choosing what commands you want Execute to be able to run.

Share this post


Link to post
Share on other sites

#8 ·  Posted

What about something like this?

#include "_ProcessGetWin.au3" ; http://www.autoitscript.com/forum/topic/115243-processgetwin/
While 1
    Sleep(200)
    $iConsent = ProcessExists("consent.exe")
    If $iConsent Then
        $aWins = _ProcessGetWin($iConsent)
        $hTheWindow = ... ; find the correct window in $aWins
        WinActivate($hTheWindow)
        WinWaitNotActive($hTheWindow)
    EndIf
WEnd

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hm, the _ProcessGetWin function did not find the UAC window for me. Additionally it seems not possible to activate a found UAC window with a plain WinActivate.

But during my research I've found this nice article on stackoverflow.com :oops:...

#include <winapi.au3>

HotKeySet("{ESC}", "_Exit")

While 1
    Sleep(250)
    $hWnd_UAC = WinGetHandle("[REGEXPCLASS:$$$Secure UAP]")
    If $hWnd_UAC Then _WinAPI_SwitchToThisWindow($hWnd_UAC, True)
WEnd

Func _WinAPI_SwitchToThisWindow($hWnd, $bAltTab = False)
    DllCall("user32.dll", "int", "SwitchToThisWindow", "hwnd", $hWnd, "bool", $bAltTab)
EndFunc   ;==>_WinAPI_SwitchToThisWindow

Func _Exit()
    Exit
EndFunc   ;==>_Exit
Edited by KaFu

Share this post


Link to post
Share on other sites

#10 ·  Posted

I actually made a fix for this myself. Took a few hours to get right, but I basically did a pixel search on the task bar for a small square that would contain the same colors as the center of the UAC icon and then mouse click in the middle of that square on the task bar when consent.exe exists, however it seems your fix works better and faster.


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

Current Projects:

IRC UDF, for IRC activities

[u]SafeExecute[/u], for picking and choosing what commands you want Execute to be able to run.

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