Jump to content

Windows' "update delay"


Fastor
 Share

Recommended Posts

Hi all,

This is my first day using AIT (is that an accepted short-hand for AutoIt ?) and I'm having a whole lot of fun, trying various things.

I'm working on a small script that's supposed to do the following :

- launch the notepad and the file explorer : no problem there

- get the explorer to open a specific folder and show its contents : no problem

- get the number of items in that folder, by reading the explorer's status bar : works like a charm

- for each item, write a line in the notepad with the item's name and some basic info found in its properties dialog : I'm stuck there.

Using Send() I'm able to select each file one by one with the {HOME} and then {DOWN} keys (barbaric, but it works) and then {APPSKEY}{UP}{ENTER} successfully opens the properties dialog box.

I wanted to first check that I could close it with {ESCAPE}, and that's where I'm stuck : the script doesn't do it, though when it ends the dialog box is the active window and if I manually press escape, it closes just fine.

I figured I was going too fast in my script, sending the escape before the window was there, so I decided to try and wait for it to activate. Since I couldn't know its handle I used WinList("").

Oddly, it returned only one window name : the file explorer's. That's not right, because there were a dozen windows on my screen at the time.

I've also tried a different approach : since the "up/down" keys worked and I could read the explorer's status bar, I tried to read it for every file.

It didn't work : instead of getting each file's info (the type, date modified and size) I got the information about the folder's contents (number of items) and then several empty strings.

I can't see what I'm doing wrong, but I assume it has something to do with how fast Window's GUI reacts compared to how fast AIT works.

Can you give me any pointers ?

Thank you !

Jean

Link to comment
Share on other sites

Welcome Fastor, to the fantastic world of AutoIt scripting :)

What you seek to accomplish, it seems, can be done using a far simpler method. Take a look at the functions _FileListToArray, FileWrite, FileGetSize, FileGetTime in the help file. Play around with these functions, and if you run into difficulty, feel free to post here.

Link to comment
Share on other sites

Welcome Fastor, to the fantastic world of AutoIt scripting :idiot:

Thanks, it really is fantastic, I'm having a lot of fun already. AIT has given me lots of ideas. I'm certain one day I'll wonder how I ever lived without it.

What you seek to accomplish, it seems, can be done using a far simpler method.

The story of my life :)

Seriously now, I wasn't trying to do it the easiest way (I've known for years how to do that in C++) it's just a "custom" of mine to test many different approaches to solving a problem when I learn a new language.

There's also an ulterior motive : I came to AIT looking for a solution to a tough problem. For my (paying) job I need to find a way to control a PC-based lab instrument that has its own control software and is not intended for automation (no scripting, no command line arguments, no nothing)

Since the instrument is expensive and I don't want to break it, I'm trying everything I want to do to it on other applications, like Excel, the notepad and file explorer.

I did notice some behaviors I couldn't understand, so I hope someone takes the time to tell me the obvious.

This "update delay" is one, and here's another :

I was controlling the file explorer and as you know, when you go to a different directory, the window's title changes to the name of that directory. Yet when I did WinList(), the explorer always appeared as (and responded to) "My Documents".

Perhaps it's once again an update delay of some sort, or maybe there's something I'm not doing, like sending some sort of "refresh" command. Did anyone come across this kind of "problem" ?

Right now I'm solving it simply by using handles instead of window titles.

I also would really like to know why WinList() only returned the one window I was controlling.

Thank you guys ;)

Jean

Link to comment
Share on other sites

I was controlling the file explorer and as you know, when you go to a different directory, the window's title changes to the name of that directory. Yet when I did WinList(), the explorer always appeared as (and responded to) "My Documents".

:)...
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...