MichaelCrawley Posted May 14, 2024 Posted May 14, 2024 How to set excel be on top 10 seconds then my browser to be on top 10 second - Kind of Swap focus - I am not sure how to go about this. I looked in the Libary there is a show hide... I am kind of look to see what function I would use the make this happens. I am not a programmer So I apogize in advance for any coding errors. Point me in the right direction would be very helpful. expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <Excel.au3> #include <WinAPISysWin.au3> Global $exitChrome Global $oExcel Global $openScreen Global $bigExcel Global $openExcel AdlibRegister("", 3000) ; Creates the GUI Global $hGUI = GUICreate("QCDM GUI", 245, 70) GUISetBkColor(0xC0DCC0) ; Button to open the QCDM pages Global $idButton_QCDM = GUICtrlCreateButton("Display", 90, 5, 70, 25) GUICtrlSetBkColor(-1, 0x99B4D1) ; Button the open excel Global $idButton_Excel = GUICtrlCreateButton("Hourly Only", 10, 5, 70, 25) GUICtrlSetBkColor(-1, 0x99B4D1) ; Button to exit chrome Global $idButton_Exit = GUICtrlCreateButton("EXIT", 170, 25, 70, 25) GUICtrlSetColor(-1, 0xC0C0C0) GUICtrlSetBkColor(-1, 0xFF0000) ; Button to close QCDM pages Global $idButton_CLOSEQCDM = GUICtrlCreateButton("Close Display", 90, 40, 70, 25) GUICtrlSetBkColor(-1, 0x99B4D1) ;Button name "Close Excel" Global $idButton_closeExcel = GUICtrlCreateButton("Close Hourly", 10, 40, 70, 25) GUICtrlSetBkColor(-1, 0x99B4D1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Func Toggle() ;==>Toggle between web pages ConsoleWrite('@@ (8) :(' & @MIN & ':' & @SEC & ') Toggle()' & @CR) ;### Trace Function Static $bFirst = True WinActivate(@SW_MAXIMIZE) If $bFirst Then Send("^1") Else Send("^2") EndIf $bFirst = Not $bFirst EndFunc ; Loop until the user exits. $closeApp = True While 1 Switch GUIGetMsg() ;cases for QCDM Case $idButton_QCDM ;Calls webpage webPage() ;class toggling Toggle() Sleep(1000) openScreen() ;opens excel Case $idButton_Excel ;Calls Open excel script checkOrOpenExcel() sleep(4000) ;Closes Chrome Case $idButton_CLOSEQCDM ;Closes Chrome WinClose("chrome.exe","") exitChrome() ;closes excel Case $idButton_closeExcel ;closes excel by heading WinClose("thisfile.xlsx - Excel") ;oExcel() ;exits application Case $idButton_Exit Terminate() EndSwitch WEnd While True Sleep(500) WEnd ;terminates script Func Terminate () Exit EndFunc ;function to open webpage Func webPage() Run ('"C:\Program Files\Google\Chrome\Application\chrome.exe" www.google.com') Sleep(5000) EndFunc ;==> open webpages ;function to open excel Func openExcel() Run('"C:\Program Files (x86)\Microsoft Office\Office16\excel.exe" "c:\Everyone\test\thisfile.xlsx"') Sleep (5000) EndFunc ;==>openExcel ;Makes the function fullscreen Func openScreen() ;max size of window @sw_maxmimize WinSetState("Chrome_WidgetWin_1", "", @SW_MAXIMIZE) EndFunc ;makes excell full screen Func bigExcel() ;max size of window @sw_maxmimize WinSetState("thisfile.xlsx","",@SW_MAXIMIZE) EndFunc Func oExcel() $run = Run("TASKKILL /F /IM excel.exe /T", "", @SW_HIDE) EndFunc Func exitChrome() $runString = StringFormat("TASKKILL /F /IM chrome.exe /T") $run = Run($runString, "", @SW_HIDE) EndFunc ;Function to check to see if excel is open Func checkOrOpenExcel() ;looks for the process excel.exe if it is open then prompt file is alreday open If ProcessExists ("excel.exe") Then msgbox($MB_SYSTEMMODAL, "", "File is Already Open") else ;If is is not open it will open the fuction for excel Run('"C:\Program Files (x86)\Microsoft Office\Office16\excel.exe" "c:\Everyone\test\thisfile.xlsx"') EndIf EndFunc
MichaelCrawley Posted May 14, 2024 Author Posted May 14, 2024 So would this be the function I would use? #include <Array.au3> _ArraySwap ( ByRef $aArray, $iIndex_1, $iIndex_2 [, $bCol = False [, $iStart = -1 [, $iEnd = -1]]] )
Andreik Posted May 14, 2024 Posted May 14, 2024 What is the link between _ArraySwap() and setting a specific window on top? Check in help file WinSetOnTop().
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