Sign in to follow this  
Followers 0
soonyee91

Send text to specific window control

3 posts in this topic

After few search on the internet, I still cannot figure this out. Any tips on doing it? Is it the way i declare the window object wrong?

Below is my code:

#include <Excel.au3>
#include <File.au3>

Global $szDrive, $szDir, $szFName, $szExt ,$filelocation="C:\Users\SoonYee\Desktop\test.xls"
Global $oExcel = ObjCreate("Excel.Application")
        $oExcel.Visible = 1
        $oExcel.Application.ScreenUpdating = True
        $oExcel.Application.DisplayAlerts = False
        $oExcel.WorkBooks.Open($filelocation,2 )
        Dim $view=_PathSplit($filelocation, $szDrive, $szDir, $szFName, $szExt)
         Local $arr[3] = ["Graph", "Rawdata", "Data_t50"]
        $oExcel.Sheets($arr).Printout
        WinWaitActive("Save As")
        WinActivate ( "")
ControlSend ( "[CLASS:#32770", "", "Edit1", "Testing purpose")

The code run fines up to open the file. For controlsend part, it is not working. Where is the problem actually?? 

Share this post


Link to post
Share on other sites



After a few tries, I am able to automate the "Save As" Dialog If I open the excel separately without using the above code.

ControlSetText("Save As","",1001,"Testing")

Above code works If I do not use together with the 1st post's code.

Any idea why I am unable to send text to the control?? if I put this code on my 1st post's code. For example:

#include <Excel.au3>
#include <File.au3>

Global $szDrive, $szDir, $szFName, $szExt ,$filelocation="C:\Users\SoonYee\Desktop\test.xls"
Global $oExcel = ObjCreate("Excel.Application")
        $oExcel.Visible = 1
        $oExcel.Application.ScreenUpdating = True
        $oExcel.Application.DisplayAlerts = False
        $oExcel.WorkBooks.Open($filelocation,2 )
        Dim $view=_PathSplit($filelocation, $szDrive, $szDir, $szFName, $szExt)
         Local $arr[3] = ["Graph", "Rawdata", "Data_t50"]
        $oExcel.Sheets($arr).Printout
ControlSetText("Save As","",1001,"Testing")

Any reason why the code is not performing??

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Haha, looks like the respond is good... :sweating:

I manage to figure out...

Instead of using this vba line "expression.Printout". I change it to "expression.Select".

After this I choose to use either send/controlsend function for automate the task.

To avoid user input from disturbing the operation. I implement "Blockinput()".

That's all for this problem. Solved! :thumbsup:

Edited by soonyee91

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
Sign in to follow this  
Followers 0