COMate - control COM objects via automation - OBSOLETE!

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

SFSxOI wrote:Kiffi;

It was a nice example, however, the first 'COMate' one worked fine, the second 'VBS' one doesn't work, at least not here. Just a blank window.
the same here, the second one doesn't work here.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

@SFSxOI & Thomas,

try to insert the following Repeat-Forever-Loop for waiting until the
webgadget is not busy anymore:

Code: Select all

[...]
WebGadget(0, 10, 10, 580, 280, "about:blank")

Repeat
 If GetGadgetAttribute(0, #PB_Web_Busy) = 0
  Break
 EndIf
 While WindowEvent(): Delay(1) : Wend
ForEver

SetGadgetItemText(0, #PB_Web_HtmlCode, ExecuteVbs())
[...]
Greetings ... Kiffi
Hygge
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Or simply add a While WindowEvent() : Wend directly after the WebGadget() command.
I may look like a mule, but I'm not a complete ass.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

srod wrote:Or simply add a While WindowEvent() : Wend directly after the WebGadget() command.
thanks for the hint! I have changed the code.

@SFSxOI & Thomas: Could you test again?

Greetings ... Kiffi
Hygge
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

> @SFSxOI & Thomas: Could you test again?
yesterday without problems :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

Yep, works here now :) Thanks


On a sort of related item for something else actually but related for me to this....

how do you set a parameter for a method that includes an 'and' that looks like this:

Code: Select all

updateSearcher.Search("IsInstalled=1 and Type='Software'")
where Search is the method

?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Surely it is just a single string parameter?

Perhaps...

Code: Select all

updateSearche\Invoke("Search('IsInstalled=1 and Type=$0027Software$0027'")
I may look like a mule, but I'm not a complete ass.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

SFSxOI wrote:where Search is the method
Search is a function, not a method.

Code: Select all

Set SearchResult = UpdateSearcher.Search("...
so you have to use GetObjectProperty()

Greetings ... Kiffi
Hygge
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

http://msdn.microsoft.com/en-us/library ... S.85).aspx

says its a method. Is it really a function? Would not be the first time the MSDN was misleading in some way or i've misunderstood it.

It says this for the Search ;

"With some restrictions, multiple criteria can be connected with the AND and OR operators. "

and

" A single criterion consists of "Name = Value" or "Name != Value", where "Name" is one of the supported criterion names, and "Value" is a string or an integer. The AND and OR operators can be used to connect multiple criteria. However, OR can be used only at the top level of the search criteria. Therefore, "(x=1 and y=1) or (z=1)" is valid, but "(x=1) and (y=1 or z=1)" is not valid."

and every example i can find for it has it formatted as "updateSearcher.Search("IsInstalled=1 and Type='Software'") " ( or...."updateSearcher.Search("IsInstalled=0 and Type='Software'") " ) with two criterion so I think that it has two criterion.

so, combining srod's example from above and what you presented it looks like this then?

Code: Select all

UpdateSearcher\GetObjectProperty("Search('IsInstalled=1 and Type=$0027Software$0027'")")

or this:

UpdateSearcher\Invoke("Search('IsInstalled=1 and Type=$0027Software$0027'")")
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

MSDN would suggest the GetObjectProperty().
I may look like a mule, but I'm not a complete ass.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

SFSxOI wrote:says its a method. Is it really a function? Would not be the first time the MSDN was incorrect or misleading in some way.
perhaps my english is to bad, but let me explain in this way:

this method has an out-Parameter, so in COMate you have to handle Search() like a function.
MSDN wrote:[out] ISearchResult **retval
the result of Search() must returned somewhere.
SFSxOI wrote:so, combining srod's example from above and what you presented it looks like this then?

Code: Select all

UpdateSearcher\GetObjectProperty("Search('IsInstalled=1 and Type=$0027Software$0027'")")
rather something like this:

Code: Select all

SearchResult.COMateObject = UpdateSearcher\GetObjectProperty("Search('IsInstalled=1 and Type=$0027Software$0027')")
Greetings ... Kiffi
Hygge
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

ahhh...OK. I see what you guys are saying now. Thank You :)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

When using COMate, any parameters listed as being an 'out' parameter are handled automatically. If you see an 'out' parameter listed in a method's parameter list then you should use one of COMate's Get...Property() calls and it will retrieve the aforementioned value.

You will not ordinarily need to worry about dealing with these 'out' parameters yourself - unless a method lists two or more such parameters! :wink:
I may look like a mule, but I'm not a complete ass.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

Thanks srod :)

anyway, what i'm working on is an automated update thing for a project we have comming up this summer. Each summer our company lends its personnel, time, and equipment, to the support of a summer camp for under privilaged children. Part of this camp experience for them includes an introduction to computers and their use. We supply approximately 150 computers each year, all state of the art, for the kids and the staff to use. We get the majority of these from coporation donations and they are brand new except most of them don't come with an operating system installed yet so we have to do that. Last year I used PureBasic to build some automated things that ran during the OS install for setting things up for networking and so on, it worked out great. But this year its a little different. Last year we were able to set up on site and network them all together and do everything at once across the network, this year we will not be able to do that in advanced for most of the machines due to some constraints so when they arrive on site they will have to be ready to plug in and use. One of the things that was missing though was updates to the operating system which meant that we had to visit each machine individually and start the updates. This year we plan to just be able to download and install the updates automatically via a setup in taskmanager to run an update utility which will get, download, and install updates from windows update without any human intervention, and thats what i'm working on now. So far i'm identifying the updates already on the machine (actually some get installed with the automated OS install sequence but the ones from windows update don't), so thats what this code is so far (this is just the windows update portion):

<code removed - it wasn't working - working version posted later in thread two posts from this one>

Still gotta check it out to make sure it works. I haven't started on the download, identifying which ones to install, and install routines yet. yeah, I know there are .vbs scripts to do this but i wanna do it in Purebasic like i did the past stuff.
Last edited by SFSxOI on Wed Mar 11, 2009 12:01 am, edited 4 times in total.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Interesting indeed. 8) I hope it all works out.
I may look like a mule, but I'm not a complete ass.
Post Reply