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

Bring Firefox to front


  • Please log in to reply
31 replies to this topic

#1 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 07 January 2013 - 05:40 PM

I would like to bring the Firefox window to the front and make it active. What I am trying to make work is:

$title = "MozillaWindowClass" $exe = "Firefox.exe" $toggle = 0 If WinActive($title) And $toggle Then   Else     If WinExists($title) Then         WinActivate($title)     Else         Run($exe)     EndIf     WinActivate($title) EndIf


What shows in the Info is:

Plain Text         
>>>> Window <<<< Title: Posting New Topic - AutoIt Forums - Mozilla Firefox Class: MozillaWindowClass Position: 3, 8 Size: 1166, 735 Style: 0x16CF0000 ExStyle: 0x00000100 Handle: 0x00000000002103BC >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 215, 23 Cursor ID: 0 Color: 0x219FD8 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<<


The information is pointing to the tab in firefox. I would like to bring to focus Firefox regargles of what tab is open.

Thanks,

Docfxit

Edited by docfxit, 07 January 2013 - 05:44 PM.








#2 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,929 posts

Posted 07 January 2013 - 05:43 PM

WinActivate('[CLASS:MozillaWindowClass]')

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()_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()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: 30/07/2014


#3 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 07 January 2013 - 05:52 PM

Thank you for the quick response...

I changed it to:

$title = "MozillaWindowClass" $exe = "Firefox.exe" $toggle = 0 If WinActive('[CLASS:MozillaWindowClass]') And $toggle Then     If WinExists($title) Then         WinActivate('[CLASS:MozillaWindowClass]')     Else         Run($exe)     EndIf     WinActivate('[CLASS:MozillaWindowClass]') EndIf


And it doesn't work.
What am I doing wrong?

Thanks,

Docfxit

Edited by docfxit, 07 January 2013 - 05:53 PM.


#4 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 07 January 2013 - 06:11 PM

I have been able to get this to work:

$exe = "C:\Programs\FireFox\firefox.exe" $appName = "[CLASS:MozillaWindowClass]" $appHandle = WinGetHandle($appName, "") ;If WinActive("Firefox")  Then     If WinExists($appName) Then         WinActivate($appHandle)     Else         Run($exe)     EndIf     WinActivate($appHandle) ;EndIf ;EndIf


That does bring FireFox to the front. I haven't been able to get the If statement to work.

Docfxit

Edited by docfxit, 07 January 2013 - 06:12 PM.


#5 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,929 posts

Posted 07 January 2013 - 06:13 PM

Well it's the structure of your code and the title string. What does this return?
MsgBox(4096, '', WinExists('[CLASS:MozillaWindowClass]'))


Edit: Seems you changed the layout of your code. Why not use ProcessExists instead?

Edited by guinness, 07 January 2013 - 06:17 PM.

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()_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()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: 30/07/2014


#6 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,044 posts

Posted 07 January 2013 - 06:23 PM

I have been able to get this to work:

 


That does bring FireFox to the front. I haven't been able to get the If statement to work.

Docfxit

You can't use the If statement the way you have it. That will only run the code inside of it if Firefox is already the active window. If it's not active, the code gets skipped. In your first code example, it would never run ever because you set $toggle to 0 and then the If statement is only run if both $toggle is True (1), AND Firefox is the currently active window. Since $toggle will never be True, it will never run.

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 an XP machine, 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 Gude

 

How to ask questions the smart way!

 

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

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.


#7 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 07 January 2013 - 06:23 PM

Thanks for the reply...

I tried Processexist It doen's seem to work

I just relized I don't need the if statement at all.

This is what I ended up with:

$exe = "C:\Programs\FireFox\firefox.exe" $appName = "[CLASS:MozillaWindowClass]" $appHandle = WinGetHandle($appName, "")     If WinExists($appName) Then         WinActivate($appHandle)     Else         Run($exe)     EndIf     WinActivate($appHandle)


Thanks a bunch,

Docfxit

#8 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,929 posts

Posted 07 January 2013 - 06:26 PM

Depends how you used it, but glad you got it working. As I said it was your logic with the code.

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()_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()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: 30/07/2014


#9 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 07 January 2013 - 06:32 PM

Thanks to you I got the $appName
so I could figure out the rest.

Thanks to BrewManNH for pointing out my logic was wrong. I did find that out just before you posted. Thanks for the post anyway.

It's working great now.

Docfxit

#10 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 10 January 2013 - 12:11 AM

When I use the code to bring Firefox to the front in a script it didn't work.

This is the entire script:

AutoIt         
#include "File.au3" ; Autoit code to instll extensions and themes into firefox AutoItSetOption("TrayIconDebug", 1) ;0-off ; Set so that tray displays current line number If _OSVersion() = "Win7" Or "Win7X64" Then     $ProgramFiles = "C:\Programs" Else     $ProgramFiles = "C:\Program Files" EndIf ;Declare Variables $FireFoxDir = $ProgramFiles & '\FireFox\' $FireFoxExe = $FireFoxDir & 'FireFox.exe' $ScriptDir = "C:\Dnload\9xAddons" $AddonsDir = @ScriptDir & '\FireFox Extensions\' $AddonsFiles = _FileListToArray($AddonsDir) For $i = 1 To $AddonsFiles[0]     $AddonsFiles[$i] = "'" & $AddonsDir & $AddonsFiles[$i] & "'" Next $appName = "[CLASS:MozillaWindowClass]" $appHandle = WinGetHandle($appName, "") If WinExists($appName) Then     WinActivate($appHandle)     MsgBox(48, "Firefox", "Is Active")     WinSetOnTop($appName, "", 1) Else     MsgBox(48, "Firefox", "Is Not Active")     Run($FireFoxExe) EndIf WinActivate($appHandle) WinSetOnTop($appName, "", 1) MsgBox(48, "Firefox", "Should be Active") For $i = 1 To $AddonsFiles[0]     Switch StringRight($AddonsFiles[$i], 3)         Case 'xpi'             ;MsgBox(48, "File Number", $i)             Send("{CTRLDOWN}o{CTRLUP}")             WinWait("Open File", "Namespace Tree Contr")             If Not WinActive("Open File", "Namespace Tree Contr") Then WinActivate("Open File", "Namespace Tree Contr")             WinWaitActive("Open File", "Namespace Tree Contr")             MsgBox(48, "File Nname", $AddonsFiles[$i])             Send($AddonsFiles[$i], 1)             Send("{ALTDOWN}o{ALTUP}")             WinWait("Software Installation", "")             If Not WinActive("Software Installation", "") Then WinActivate("Software Installation", "")             WinWaitActive("Software Installation", "")             ;            Sleep(2500)         Case 'jar'             ; This is not working             ;RunWait($FireFoxExe & ' -install-global-theme "' & $AddonsFiles[$i] & '"', $FireFoxDir)         Case Else             Sleep(0)     EndSwitch     ;close firefox doesn't work     ProcessClose('FireFox.exe *32') Next Exit Func _OSVersion()     Local $OS_Version, $servicepack_version     $OS_Version = StringStripWS(StringRegExpReplace(@OSVersion, "(WIN_)|(Microsoft )|(Windows )|(\(TM\))|( Ultimate)", ""), 8)     $OS_Version = StringRegExpReplace(StringRegExpReplace($OS_Version, '2008', 'Win7'), 'VISTA', 'Vista')     If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", 'CurrentBuildNumber') > 7000 Then $OS_Version = 'Win7'     $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP")     If @error = -1 Then $servicepack_version = ""     ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF)     Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') EndFunc   ;==>_OSVersion


Please help me find some code that works to bring Firefox to the front.

Thanks,

Docfxit

#11 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,044 posts

Posted 10 January 2013 - 12:18 AM

There's a macro, @OSVersion that would a lot simpler than your _OSVersion function.

BTW, other than not ,making FF the active window, what error checking have you done and where is it failing?

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 an XP machine, 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 Gude

 

How to ask questions the smart way!

 

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

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.


#12 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,929 posts

Posted 10 January 2013 - 12:30 AM

There's a macro, @OSVersion that would a lot simpler than your _OSVersion function.

BTW, other than not ,making FF the active window, what error checking have you done and where is it failing?

They're using the macro already, but the logic is a little overcomplicated and @OSVersion doesn't return what they think it should.
MsgBox(4096, '', _OSVersion()) Func _OSVersion()     Local $sOSVersion = StringReplace(@OSVersion, 'WIN_', '')     $sOSVersion = StringReplace($sOSVersion, '2008', 'Win7')     $sOSVersion = StringReplace($sOSVersion, 'VISTA', 'Vista')     Return $sOSVersion & StringReplace(@OSServicePack, 'Service Pack ', 'SP') & StringReplace(@OSArch, '(X86)', '') EndFunc   ;==>_OSVersion

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()_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()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: 30/07/2014


#13 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 10 January 2013 - 12:35 AM

Right now I have a need to do two things.

1. Make FireFox the active window
2. Close FireFox

I have done way to much testing to post it here.

It's really very simple.

1. I have FireFox open
2. I have SciTE open
3. I run the script in SciTE with the F5 key.
4. I expect FireFox to become the active window so the included code will execute properly.

Thanks,

Docfxit

#14 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,929 posts

Posted 10 January 2013 - 12:50 AM

Just quickly looking at your code, the assumption with operator usage is incorrect, for example, checking if the PC is Windows 7 is wrong, I have SP1 installed so this will always return the second option.
Local $sVersion = _OSVersion() If $sVersion = 'Win7' Or $sVersion = 'Win7X64' Then     MsgBox(4096, '', 'Windows 7') EndIf

Also ProcessClose should be >>
ProcessClose('Firefox.exe')


Go back to basics, does the code in post #5 return 1? If yes then AutoIt is detecting Firefox.

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()_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()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: 30/07/2014


#15 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 10 January 2013 - 01:42 AM

Thank you for the reply...

Just quickly looking at your code, the assumption with operator usage is incorrect, for example, checking if the PC is Windows 7 is wrong, I have SP1 installed so this will always return the second option.

Local $sVersion = _OSVersion() If $sVersion = 'Win7' Or $sVersion = 'Win7X64' Then     MsgBox(4096, '', 'Windows 7') EndIf

Thank you for catching that. I haven't been using a 64bit win7 for a while. I tested it and fixed it in my code. I will fix it on this thread on my next post.

Also ProcessClose should be >>

ProcessClose('Firefox.exe')

I had it that way and it wasn't working. Probably because of something else. I switched it back and it works great now. Thanks.

Go back to basics, does the code in post #5 return 1? If yes then AutoIt is detecting Firefox.

Yes it does return a 1. Autoit is detecting Firefox. It just isn't bringing it to front for me. Why is the question.

Now if you could only figure out why it isn't making it the active window I will be all set.

Thank you very much,

Docfxit

#16 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,929 posts

Posted 10 January 2013 - 01:49 AM

Well WinActivate should do that, but something is obviously taking focus from Firefox. I don't use Firefox so this all the help I can provide.

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()_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()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: 30/07/2014


#17 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 10 January 2013 - 01:52 AM

Thanks for the help.

It would be nice if AutoIt had a way to show what program is currently taking focus.

Thanks,

Docfxit

#18 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 16,929 posts

Posted 10 January 2013 - 01:54 AM

Help file >> WinGetTitle('[ACTIVE]')

Sleep(5000) ; Time to change focus of window. MsgBox(4096, '', WinGetTitle('[ACTIVE]'))

Edited by guinness, 10 January 2013 - 01:57 AM.

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()_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()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: 30/07/2014


#19 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 299 posts

Posted 12 January 2013 - 05:45 PM

Help file >> WinGetTitle('[ACTIVE]')

Sleep(5000) ; Time to change focus of window. MsgBox(4096, '', WinGetTitle('[ACTIVE]'))

This will get the title of SciTE (that's the program I use to run this script) You are correct this answers the question as I worded it.

You are correct. It will show me the current active program. It won't show me why FireFox can't take over the current active program.

Thanks,

Docfxit

Now If I could just figure out why Firefox won't change to the current active program I'd be all set.

#20 KaFu

KaFu

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

  • MVPs
  • 3,386 posts

Posted 12 January 2013 - 11:33 PM

#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)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users