Sign in to follow this  
Followers 0
qwert

"Object" method to toggle desktop?

5 posts in this topic

MSDN prescribes the following as a VB script to toggle the desktop:

dim objShell  
  set objShell = CreateObject("shell.application")
      objShell.ToggleDesktop
  set objShell = nothing

I'd like to replicate this in Au3 ... but don't see things beyond the obvious first step:

Global $objShell = ObjCreate("Shell.Application")

Beyond seeing them in a few example scripts, I have no experience with objects ... and haven't been able to garner anything from the two examples in Help.  Would someone mind showing me how to fashion this into a callable function?

Thanks for any help.

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Global $objShell = ObjCreate("Shell.Application")
       $objShell.ToggleDesktop

 

the last line in your example just sets the variable back to nothing, which is unnecessary

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Thanks very much.  That does work.

Are there other considerations to be aware of? ... like when calling it a few dozen times in the script?  Can the create be done once at the beginning?

 

Share this post


Link to post
Share on other sites

I have partly answered my own questions.  I happened upon the section in the help file on the introduction to COM extensions ... "objects".

On the first line we create a new object called "shell.application". This is an internal Windows object, defined in shell32.dll. The pointer to this new object is assigned to the variable $oShell. $oShell is from now on an Object variable.

It seems to be "create once, use many".  I'll test that in my script.  It also says "no need to delete an object ... Au3 does so upon exit".

 

Share this post


Link to post
Share on other sites

The only consideration I can think of would be not throwing it in a never ending while loop.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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