Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with script please

Status
Not open for further replies.

AlastairP

Technical User
Feb 8, 2011
286
AU
I am attempting to change the windows theme when my app starts and revert back when app closes (Uses custom messagebox sizes and scroll bar sizes)

I can do this quite easily with a couple of batch files, but the themes control panel displays
I would like to do this silently and prefer all in VFP

I found a script in VB. Can anyone help me convert to VFP?

Code:
'SCRIPT CONTENTS:
'Define Variables : 

    Set ShellApp = CreateObject("Shell.Application")
    Set WsShell = CreateObject("Wscript.Shell")


'
'Define path for your file theme (put it on a network share and don't forget to apply "read and execute" ACL for your Users)

    Theme = "typeyoursharepath\typeyourtheme.theme"
    Theme = """" + Theme + """"


'Open Display Properties Windows, Select your theme and apply with keep focus on Windows

    ShellApp.ControlPanelItem cstr("desk.cpl desk,@Themes /Action:OpenTheme /file:" & Theme)
    Wscript.Sleep 100
    WsShell.SendKeys "{ENTER}"
    While WsShell.AppActivate ("Display Properties") = TRUE
        WsShell.AppActivate "Display Properties"
    Wend

This is as far as I got. I can't get it to work and don't know how to finish this off:
Code:
&& Change theme in Windows XP or Windows 7 (silently)

&& Object: Automate without command prompt the application of a Windows Theme by a script

ShellApp = CreateObject("Shell.Application")
oControlPanel = shellApp.Namespace('cstr')
WsShell = CreateObject("Wscript.Shell")

Theme = "%windir%\Resources\Ease of Access Themes\classic.theme" 

&& Open Display Properties Windows, Select your theme and apply with keep focus on Windows

ShellApp.oControlPanel("desk.cpl desk,@Themes /Action:OpenTheme /file:" & Theme)

Wscript.Sleep 100
WsShell.SendKeys "{ENTER}"
DO While WsShell.AppActivate ("Display Properties") = .t.
    WsShell.AppActivate "Display Properties"
ENDDO

 
1. In the line beginning ShellApp.oControlPanel, change the & to +

2. Where you have a function or method call followed by a space followed by a parameter, wrap the parameter in parentheses. For example:

Code:
        Wscript.Sleep 100 => Wscript.Sleep[b]([/b]100[b])[/b]
WsShell.SendKeys "{ENTER}" => WsShell.SendKeys[b]([/b]"{ENTER}"[b])[/b]

As far as I can see, that's all you need to do.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 

The following code fails with error: OLE error code 0x800200006: Unknown name

Code:
ShellApp = CreateObject("Shell.Application")
oControlPanel = shellApp.Namespace('cstr')

Theme = "%windir%\Resources\Ease of Access Themes\classic.theme" 
ShellApp.oControlPanel("desk.cpl desk,@Themes /Action:OpenTheme /file:" + Theme)

 
This is a console app where nothing else ever runs on that computer, I hope.

If an application changed my Windows theme without my permission, no matter how temporarily, it would immediately be uninstalled and I'd be asking for a refund.
 
Alastair, I was waiting for someone to make the point that Dan has just made.

It's a valid point, but before we enter into a discussion about it, could you let us know if the last bit of code I gave you worked. I have run the modified code myself, and it works for me. What result did you get?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Nothing else of consequence runs on the computer: its a touch screen application for our technicians out on the road.
The changes I make to the theme provides larger scroll bars and other features to make operation easier.
When the application starts I need to ensure this by enabling a custom theme

The modified code did not cause an error, but the themes did not change either.
I just go home from work, so I will check in to it and report back.

Alastair
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top