Jump to content
Sign in to follow this  
b0ris

List running excel files

Recommended Posts

b0ris

Hello there,

I just can't figure out how to list all the running excel files.

I tried the following, but I just can't get it to work.

#include <Array.au3>

Dim $window=WinList()
dim $wTitle[1][1]
dim $title[1]

$title = _ArrayFindAll($window, "Microsoft Excel -",0,0,0,1)
_ArrayDisplay($title)
For $x = 0 To UBound($title)-1
    _ArrayAdd($wTitle, $title[$x])
;~  _ArrayDelete($wTitle, 0)
Next
_ArrayDisplay($wTitle)

Is there anyone who can help me with this?

Thanks in advance!

b0ris

Share this post


Link to post
Share on other sites
Melba23

b0ris,

According to that ever-useful Help file, WinList() returns a 2D array with titles in the [0] dimension and handles in the [1] dimension. So you need to specify 2 dimensions when you try and read the array. You also need to read the correct array - at the moment you are trying to _ArrayAdd from $title which lists the indices returned from the search for "Microsoft Excel" and not $window which lists the titles of the windows. Try this:

#include <Array.au3>

Dim $window=WinList()
dim $wTitle[1][1]
dim $title[1]

$title = _ArrayFindAll($window, "Microsoft Excel -",0,0,0,1)
_ArrayDisplay($title)
For $x = 0 To UBound($title)-1
    _ArrayAdd($wTitle, $window[$title[$x]][0])
Next
_ArrayDisplay($wTitle)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
b0ris

b0ris,

According to that ever-useful Help file, WinList() returns a 2D array with titles in the [0] dimension and handles in the [1] dimension. So you need to specify 2 dimensions when you try and read the array. You also need to read the correct array - at the moment you are trying to _ArrayAdd from $title which lists the indices returned from the search for "Microsoft Excel" and not $window which lists the titles of the windows. Try this:

#include <Array.au3>

Dim $window=WinList()
dim $wTitle[1][1]
dim $title[1]

$title = _ArrayFindAll($window, "Microsoft Excel -",0,0,0,1)
_ArrayDisplay($title)
For $x = 0 To UBound($title)-1
    _ArrayAdd($wTitle, $window[$title[$x]][0])
Next
_ArrayDisplay($wTitle)

M23

Unfortunately the code you've pasted above does not work. I do know that WinList() returns a 2D array, which as you can see, I can search, but can't just get the values out of the desired array element. I'm still trying different things, but no luck yet, so in case you'll figure out something, I'll be more than happy to try it.

Share this post


Link to post
Share on other sites
Melba23

b0ris,

My fault. I had several versions open and copied the wrong one.

What I posted is failing because $wTitle is created with 2 dimensions and the code is only asking for one. The solution depends on what you want to do. If you want a single dimension array with just the names:

#include <Array.au3>

Dim $window=WinList()
dim $wTitle[1]
dim $title[1]

$title = _ArrayFindAll($window, "Microsoft Excel -",0,0,0,1)
_ArrayDisplay($title)
For $x = 0 To UBound($title)-1
    _ArrayAdd($wTitle, $window[$title[$x]][0])
Next
_ArrayDisplay($wTitle)

If you want a 2D array with names and handles (which as you had created $wTitle as a 2D array I think is more likely:

#include <Array.au3>

Dim $window=WinList()
dim $title[1]

$title = _ArrayFindAll($window, "Microsoft Excel -",0,0,0,1)
_ArrayDisplay($title)

dim $wTitle[UBound($title)][2]

For $x = 0 To UBound($title)-1
    $wTitle[$x][0] = $window[$title[$x]][0]
    $wTitle[$x][1] = $window[$title[$x]][1]
Next
_ArrayDisplay($wTitle)

Apologies again - it is age you know.... ;-)

M23

Edit: Speeling

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
b0ris

b0ris,

My fault. I had several versions open and copied the wrong one.

What I posted is failing because $wTitle is created with 2 dimensions and the code is only asking for one. The solution depends on what you want to do. If you want a single dimension array with just the names:

#include <Array.au3>

Dim $window=WinList()
dim $wTitle[1]
dim $title[1]

$title = _ArrayFindAll($window, "Microsoft Excel -",0,0,0,1)
_ArrayDisplay($title)
For $x = 0 To UBound($title)-1
    _ArrayAdd($wTitle, $window[$title[$x]][0])
Next
_ArrayDisplay($wTitle)

If you want a 2D array with names and handles (which as you had created $wTitle as a 2D array I think is more likely:

#include <Array.au3>

Dim $window=WinList()
dim $title[1]

$title = _ArrayFindAll($window, "Microsoft Excel -",0,0,0,1)
_ArrayDisplay($title)

dim $wTitle[UBound($title)][2]

For $x = 0 To UBound($title)-1
    $wTitle[$x][0] = $window[$title[$x]][0]
    $wTitle[$x][1] = $window[$title[$x]][1]
Next
_ArrayDisplay($wTitle)

Apologies again - it is age you know.... ;-)

M23

Edit: Speeling

Ok, thank you very much! By the way, do you know how to configure scythe to use the UDF's added later to the include folder, to use them as the built-in ones.

I hope you know what I mean, unfortunately I can't describe this better...

Share this post


Link to post
Share on other sites
Melba23

b0ris,

I assume by "scythe" you mean "SciTE" - the editor? If so, this is how you get new include files to offer CallTips and AutoComplete

Calltips first. Use the 'Tools - UserCallTip' menu item to get au3.usercall.tips.api onscreen. Then add a line to the page for each function you want to add:

_Function($param1, $param2, $param3) Explanation of function (Requires: #Include <UDF.au3>)

Of course you need to change the Function, $param and UDF words to the correct values for the UDF function you want to include.

Now the AutoComplete. If you use the newest version of SciTE, then create the file: "C:\Program Files\AutoIt3\SciTE\Properties\au3.userudfs.properties" (you may have adjust the path if you have installed SciTE elsewhere than the recommended option). Then file should read as follows:

au3.keywords.user.udfs=_function1 _function2 _function3 _function4 \
    _function5

Once you have created the file, you can access it via the 'Options - Open au3.UserUdfs.properties' menu item.

If you do not have the latest version of SciTE (and why not?) then use 'Options - Open au3.keywords.properties' to get the au3.keywords.properties on screen. Scroll down to the au3.keywords.keywords section (it will be about line 547) and add the function names to the section ABOVE. Put the function names in lowercase and do not forget to add the "\" if you have to start a new line - just like the example above.

Then save all files, close and restart SciTE. You will have AutoComplete when you start typing the UDF function name in a script and syntax CallTips as you enter the parameters!

I take it you know you can also set specific folders that Autoit will search for include files as well as the standard "C:\Program Files\AutoIt3\Include"? From the Help file:

"There is a special registry value that can be created at "HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt" called "Include". It should be a REG_SZ (string) value. The contents of this value are a semi-colon delimited list of directories that should be searched for files when resolving #include's in addition to the standard locations."

So now you will be able to get all your new includes into a folder away from "C:Program Files" - which will make Vista very happy if you use it!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
b0ris

b0ris,

I assume by "scythe" you mean "SciTE" - the editor? If so, this is how you get new include files to offer CallTips and AutoComplete

Calltips first. Use the 'Tools - UserCallTip' menu item to get au3.usercall.tips.api onscreen. Then add a line to the page for each function you want to add:

_Function($param1, $param2, $param3) Explanation of function (Requires: #Include <UDF.au3>)

Of course you need to change the Function, $param and UDF words to the correct values for the UDF function you want to include.

Now the AutoComplete. If you use the newest version of SciTE, then create the file: "C:\Program Files\AutoIt3\SciTE\Properties\au3.userudfs.properties" (you may have adjust the path if you have installed SciTE elsewhere than the recommended option). Then file should read as follows:

au3.keywords.user.udfs=_function1 _function2 _function3 _function4 \
    _function5

Once you have created the file, you can access it via the 'Options - Open au3.UserUdfs.properties' menu item.

If you do not have the latest version of SciTE (and why not?) then use 'Options - Open au3.keywords.properties' to get the au3.keywords.properties on screen. Scroll down to the au3.keywords.keywords section (it will be about line 547) and add the function names to the section ABOVE. Put the function names in lowercase and do not forget to add the "\" if you have to start a new line - just like the example above.

Then save all files, close and restart SciTE. You will have AutoComplete when you start typing the UDF function name in a script and syntax CallTips as you enter the parameters!

I take it you know you can also set specific folders that Autoit will search for include files as well as the standard "C:\Program Files\AutoIt3\Include"? From the Help file:

"There is a special registry value that can be created at "HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt" called "Include". It should be a REG_SZ (string) value. The contents of this value are a semi-colon delimited list of directories that should be searched for files when resolving #include's in addition to the standard locations."

So now you will be able to get all your new includes into a folder away from "C:Program Files" - which will make Vista very happy if you use it!

M23

Thank you, that was really helpful, and it works perfectly!

Tons of thanks mate!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.