THEgame32

Can't get excel file to come to front

14 posts in this topic

Dim $input

;Loop until they hit cancel.
While @error <> 1

;Get input from the scanner
$input = InputBox("Andy's Amazing Oven Logger Robot", "Scan Work Order Here:","","",300,130,0,0)
;If we actually scanned something, then proceed.
   If $input Then


         If Not ProcessExists("WatchMe.exe") Then Run ("WatchMe.exe")
            Sleep(1500)





         ;Activate Keyed import window
         WinActivate("Microsoft Excel - Oven Log Test")
         WinWaitActive("Microsoft Excel - Oven Log Test")

         ;Navigate to top of Work Order column
         Send("{F5}")
         Sleep(200)
         Send("B1")
         Sleep(200)
         Send("{ENTER}")

         ;Navigate to bottom of Work Order Column
         Send("{CTRLDOWN}{DOWN}{CTRLUP}{DOWN}")


         ;Input the WorkOrder in Excel
         Send($input)
         Sleep(1000)
         Send("{TAB}")
         Sleep(1000)




      EndIf


   WEnd

 

 

That's my current code.  It doesn't matter what I put where at the end of the code, I can't get anything other than my inputbox to be in the frontground.  I want my open excel file to jump to the front after all that code runs.

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

AutoIt comes with an UDF (User Defined Functions) to work with Excel. To add data to Excel i suggest to use function _Excel_RangeWrite.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

My script works fine, I just want the excel document to remain in the forefront. 

Share this post


Link to post
Share on other sites

The Send statement sends data to an active window. As your script works so Excel is the active window until the script ends.
Is there another statement that takes the focus?
Did you post the whole script?
 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I posted the entire thing... I assure you, Excel is not active at the end.  After I send the Tab and sleep for 1000, the InputBox becomes active again.

Share this post


Link to post
Share on other sites

The Inputbox I generated sits on top once my script is done.  It's never REALLY done, that box should always be there until I hit cancel... it's just that it always gets put back on time.

Share this post


Link to post
Share on other sites

on top*

Share this post


Link to post
Share on other sites

Then we need more information:
Which version of Windows do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Another question:
What does WatchMe.exe do? Could you try without calling this exe?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Same results.  WatchMe.exe is just a stand-alone countdown timer.

 

I use Windows 7 Pro

Share this post


Link to post
Share on other sites

haha, how can you say I'm not answering you?  I've included ALL of the code for the script.  I've tried everything that's been suggested so far.  Not sure how to make that any more clear for you.

Everything suggested has resulted in the same thing: When the script finishes, my inputbox gui is still on top, EVEN THOUGH IT'S NOT THE LAST THING TOUCHED.  I want the excel file to be on top until somebody clicks on my input box again.

Share this post


Link to post
Share on other sites

When you enter some data into your InputBox and click OK the Inputbox is closed. You then transfer the data to Excel (means Excel is the active window). Then the loop starts again and the InputBox gets created again (means it becomes the active window).
To sum it up: WAD

You can only solve this problem by creating a GUI.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now