Jump to content

How to detect / refer selected cells in Afx object


marvin
 Share

Recommended Posts

Hi there,

I am newbie with AutoIT script. My colleagues taught me a bit about AutoIT script and also the Window Info. But now I am stuck with some problems. The main problem is: how to tell the process to wait until something is ready. I will focus my problem in a more specific question later...

I often use the "WinWaitActive" to pause the process until a certain window become active. But I wonder why that the result is not always successful. However, something I want to focus on now is to pause the process that cannot be made with "WinWaitActive". Here is the story: I have a program, called Alp (Analysis of Laterally Loaded Piles), it's an internal program. To analyse the data, it has a table sheet (something like Ms Excel) to fill and a menu to choose to analyse the data.

And these are my expected actions:

- Open the table sheet module

- Copy and paste a table data from a Ms Excel's sheet to the Alp table sheet.

- Choose menu Analyse to do an analysis.

- Save the file

- Open the table sheet module again

- Select all cells on the sheet

- Delete the selected data on the sheet, so that the sheet is empty again.

- Open the next MS Excel's sheet

- Iterate to the first step until all Ms Excel's sheets are finished.

So far, to tell the process to wait until something is ready, I use the SLEEP command. My target now is to eliminate all the Sleep scripts because it appears that the time to pause the process can be various between computers, even sometimes it can be different in one computer under different situations. For example, when I run the same AutoIT script .EXE on different computers (with the Sleep commands), often after several iterations the process on other computer results an error in the pasting sections, when the process are about to paste the data to the Alp Sheet. It appears that the previous data on the Alp Sheet are still there, the delete section does not work properly. I need to make the Alp sheet empty first before pasting other data onto it, so it seems that the problem falls in 3 steps of mine.

So now, I will focus my question on these steps:

- Open the table sheet module again

- Select all cells on the sheet

- Delete the selected data on the sheet, so that the sheet is empty again.

These are my original code (of those 3 steps only) that works on my computer but results error after several iterations on some other computers:

   ;activate the table applied loads and soil displacements again by pressing F10 (open the menu) - D (Data) - A (Applied loads...)
   sleep(80)
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","{F10}")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","D")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","A")   
   While not WinActive(HWnd($AlpHandle),"Applied Loads and Soil Displacements")
      ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","{F10}")
      ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","D")
      ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","A")
   WEnd
   
   
   ;Select all data table by pressing F10 (open the menu) - E (Edit) - L (Select All)
   sleep(30)
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","{F10}")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","E")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","L")
   
   ;Delete the selected data by pressing F10 (open the menu) - E (Edit) - D (Delete) - OK (ok button confirmation)
   sleep(30)
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","{F10}")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","E")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","D")
   ControlClick("Alp","","[CLASS:Button; INSTANCE:1; TEXT:OK]")

Then I changed the Sleep time like this:

   ;activate the table applied loads and soil displacements again by pressing F10 (open the menu) - D (Data) - A (Applied loads...)
   sleep(100)
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","{F10}")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","D")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","A")   
   While not WinActive(HWnd($AlpHandle),"Applied Loads and Soil Displacements")
      ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","{F10}")
      ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","D")
      ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","A")
   WEnd
   
   
   ;Select all data table by pressing F10 (open the menu) - E (Edit) - L (Select All)
   sleep(130)
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","{F10}")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","E")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","L")
   
   ;Delete the selected data by pressing F10 (open the menu) - E (Edit) - D (Delete) - OK (ok button confirmation)
   sleep(130)
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","{F10}")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","E")
   ControlSend(HWnd($AlpHandle),"","[CLASS:MDIClient; INSTANCE:1]","D")
   ControlClick("Alp","","[CLASS:Button; INSTANCE:1; TEXT:OK]")

It works properly on more computers, on some computers that produced error previously.

So now what I want to know is how to detect whether all cells in Alp are selected already, so that after the script knows that all cells are selected, then the delete sections can then be run. 

 

The problem is that I cannot get the object of cells by the Window Info tool, even the table object will produce as: Afx:00270000:8:00010003:00000000:00010627 when I use the Window Info tool. I don't know how to use that. I tried several times but did not work. I attached the screenshot of the Afx object (post-83807-0-25847400-1386119458_thumb.p) and when all the cells are selected (post-83807-0-95711200-1386119454_thumb.p).

I hope someone have ideas on this. Thank you very much.

Marvin

 

 

Edited by marvin
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...