rcmaehl Posted March 13, 2012 Posted March 13, 2012 Okay, basically I've been trying to make a hotfix for when this happens: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.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF
Moderators JLogan3o13 Posted March 13, 2012 Moderators Posted March 13, 2012 Why not just use #RequireAdmin at the beginning of your script? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
rcmaehl Posted March 13, 2012 Author Posted March 13, 2012 (edited) On 3/13/2012 at 8:03 PM, 'JLogan3o13 said: 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 March 13, 2012 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.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF
KaFu Posted March 13, 2012 Posted March 13, 2012 Not really beautiful, but works as a last resort... expandcollapse popup#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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
rcmaehl Posted March 14, 2012 Author Posted March 14, 2012 On 3/13/2012 at 10:48 PM, 'KaFu said: Not really beautiful, but works as a last resort... expandcollapse popup#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.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF
guinness Posted March 14, 2012 Posted March 14, 2012 On 3/14/2012 at 11:40 AM, 'rcmaehl said: Not pretty...Heard of the term don't look a gift horse in the mouth? If not look it up! UDF List: Reveal hidden contents _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
rcmaehl Posted March 14, 2012 Author Posted March 14, 2012 On 3/14/2012 at 11:49 AM, 'guinness said: 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.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF
ProgAndy Posted March 14, 2012 Posted March 14, 2012 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
KaFu Posted March 15, 2012 Posted March 15, 2012 (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 ...#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 March 15, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
rcmaehl Posted March 16, 2012 Author Posted March 16, 2012 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.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now