guinness Posted January 13, 2013 Share Posted January 13, 2013 Didn't think of that KaFu, thanks. UDF List: _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 Link to comment Share on other sites More sharing options...
Docfxit Posted January 17, 2013 Author Share Posted January 17, 2013 #include <array.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> $aHwnds_Firefox = WinList("[CLASS:MozillaWindowClass]") _ArrayDisplay($aHwnds_Firefox) $hWnd = WinGetHandle('[CLASS:MozillaWindowClass]') $hWnd_RootOwner = _WinAPI_GetAncestor($hWnd, $GA_ROOTOWNER) WinActivate($hWnd_RootOwner) That totally solved the problem. This is great. Thank you very very much. I've been working on this for a long time. This fixed it. Thank you, Docfxit Link to comment Share on other sites More sharing options...
guinness Posted January 17, 2013 Share Posted January 17, 2013 Great. Next time I will remember to ask the OP if they've checked the root owner. Firefox is strange. UDF List: _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 Link to comment Share on other sites More sharing options...
KaFu Posted January 17, 2013 Share Posted January 17, 2013 You're welcome, always a pleasure . OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
rossnixon Posted January 12, 2014 Share Posted January 12, 2014 That totally solved the problem. This is great. Thank you very very much. I've been working on this for a long time. This fixed it. Thank you, Docfxit I've just tried the same thing, using KaFu's code. But it doesn't bring Firefox to the front. I just get an array that appears to be a list of Firefox tabs, i think. Link to comment Share on other sites More sharing options...
KaFu Posted January 12, 2014 Share Posted January 12, 2014 (edited) I've added the _ArrayDisplay() only to demonstrate that Firefox has several windows and you need to identify the right one you want to bring to the front... strangely enough, this code does not work for me now too, I've used it successfully on Win7, now on Win8 it does not bring FF to the front ... but this one does. $aHwnds_Firefox = WinList("[CLASS:MozillaWindowClass]") For $i = 1 to $aHwnds_Firefox[0][0] if $aHwnds_Firefox[$i][1] then WinActivate($aHwnds_Firefox[$i][0]) Next Edited January 12, 2014 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
VAN0 Posted May 18, 2014 Share Posted May 18, 2014 (edited) The problem with using [CLASS:MozillaWindowClass], is that Firefox is not the only program that has this class. Anything Mozilla made could be affected http://www.mozilla.org/about/mozilla-based/ At least Thunderbird does. Edited May 18, 2014 by VAN0 Link to comment Share on other sites More sharing options...
johnmcloud Posted May 18, 2014 Share Posted May 18, 2014 (edited) Just check the title: ; Johnmcloud - 2014 If Not ProcessExists("firefox.exe") Then Exit $hFirefox = WinGetHandle("[REGEXPTITLE:(?i)(.* - Mozilla Firefox);CLASS:MozillaWindowClass]") ConsoleWrite("HANDLE: " & $hFirefox & @CRLF) WinActivate($hFirefox) Or if you want to use the KaFu version: WinList("[REGEXPTITLE:(?i)(.* - Mozilla Firefox);CLASS:MozillaWindowClass]") Edited May 18, 2014 by johnmcloud Link to comment Share on other sites More sharing options...
BrewManNH Posted May 18, 2014 Share Posted May 18, 2014 The problem with using [CLASS:MozillaWindowClass], is that Firefox is not the only program that has this class. Anything Mozilla made could be affected http://www.mozilla.org/about/mozilla-based/ At least Thunderbird does. That's a normal "problem" with any window that you're accessing by the class. Just because there are sometimes going to be numerous windows sharing the same class doesn't mean it's not the right way to do it. Supposing you were trying to access a notepad window, occasionally you're going to have more than one open at a time. Your code needs to make sure you're talking to the right one. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
VAN0 Posted May 18, 2014 Share Posted May 18, 2014 Just check the title:; Johnmcloud - 2014 If Not ProcessExists("firefox.exe") Then Exit $hFirefox = WinGetHandle("[REGEXPTITLE:(?i)(.* - Mozilla Firefox);CLASS:MozillaWindowClass]") ConsoleWrite("HANDLE: " & $hFirefox & @CRLF) WinActivate($hFirefox)Or if you want to use the KaFu version:WinList("[REGEXPTITLE:(?i)(.* - Mozilla Firefox);CLASS:MozillaWindowClass]")When it comes to Firefox this method is also not 100% proof. For example I don't have anything that says it's Firefox in my Firefox' title. I use extension that allows me to change it. That's a normal "problem" with any window that you're accessing by the class. Just because there are sometimes going to be numerous windows sharing the same class doesn't mean it's not the right way to do it. Supposing you were trying to access a notepad window, occasionally you're going to have more than one open at a time. Your code needs to make sure you're talking to the right one.By no means I meant to sound like this was a wrong way to do it. I just pointed out, that in case of Firefox this method is not 100% working...If I have a full path to firefox.exe how would get list of all processes or threads or windows this process has? Perhaps we could go from this direction. Link to comment Share on other sites More sharing options...
johnmcloud Posted May 19, 2014 Share Posted May 19, 2014 (edited) Like this? ; Johnmcloud - 2014 Local $PID Local $aFirefox = ProcessList("firefox.exe") For $i = 1 To $aFirefox[0][0] $PID = $aFirefox[$i][1] ExitLoop Next ;~ Original post by Kafu Local $aHwnds_Firefox = WinList("[CLASS:MozillaWindowClass]") For $i = 1 To $aHwnds_Firefox[0][0] If $aHwnds_Firefox[$i][0] <> "" Then ConsoleWrite("TITLE: " & $aHwnds_Firefox[$i][0] & @CRLF) ConsoleWrite("HANDLE: " & $aHwnds_Firefox[$i][1] & @CRLF) If $aHwnds_Firefox[$i][1] And WinGetProcess($aHwnds_Firefox[$i][1]) = $PID Then WinActivate($aHwnds_Firefox[$i][0]) EndIf EndIf Next Obv is there are more then one process with different PIDs you need to create an array of PIDs and check that array in loop with WinGetProcess Edited May 19, 2014 by johnmcloud Link to comment Share on other sites More sharing options...
VAN0 Posted May 19, 2014 Share Posted May 19, 2014 (edited) That works much better, doesn't conflict with Thunderbird. Thanks.But what if you don't know the class, if you only have PID and/or HWND, path to .exe? Just use empty WinList() ? Edited May 19, 2014 by VAN0 Link to comment Share on other sites More sharing options...
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