Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

UAC Prompt Help


  • Please log in to reply
9 replies to this topic

#1 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 13 March 2012 - 07:56 PM

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?

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

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








#2 JLogan3o13

JLogan3o13

    115 and holding

  • MVPs
  • 3,887 posts

Posted 13 March 2012 - 08:03 PM

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

Programming is like sex...one mistake and you have to support it for a lifetime.

My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, Windows Firewall UDF


#3 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 13 March 2012 - 08:05 PM

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, 13 March 2012 - 08:06 PM.

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

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


#4 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,382 posts

Posted 13 March 2012 - 10:48 PM

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

AutoIt         
#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 ; <a href='http://www.autoitscript.com/forum/topic/90282-wingetalttabwinlist/' class='bbc_url' title=''>http://www.autoitscript.com/forum/topic/90282-wingetalttabwinlist/</a> ; =============================================================================================================================== ; 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


#5 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 14 March 2012 - 11:40 AM

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

AutoIt         
#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 ; <a href='http://www.autoitscript.com/forum/topic/90282-wingetalttabwinlist/' class='bbc_url' title=''>http://www.autoitscript.com/forum/topic/90282-wingetalttabwinlist/</a> ; =============================================================================================================================== ; 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.

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

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


#6 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,860 posts

Posted 14 March 2012 - 11:49 AM

Not pretty...

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

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 20/07/2014


#7 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 14 March 2012 - 11:54 AM

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


Just did. Interesting.

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

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


#8 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 14 March 2012 - 02:57 PM

What about something like this?
#include "_ProcessGetWin.au3" ; <a href='http://www.autoitscript.com/forum/topic/115243-processgetwin/' class='bbc_url' title=''>http://www.autoitscript.com/forum/topic/115243-processgetwin/</a> 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* Posted Image [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

#9 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,382 posts

Posted 15 March 2012 - 05:46 PM

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, 15 March 2012 - 05:47 PM.


#10 rcmaehl

rcmaehl

    No where near a noob nor a pro coder.

  • Active Members
  • PipPipPipPipPipPip
  • 672 posts

Posted 16 March 2012 - 11:55 AM

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.

Making dumb decisions and posting without thinking since August 7, 2011. Jury-rigging AutoIt to work how I want successfully since a while.

 

Current Projects:

IRC UDF, for IRC activities

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users