Set up software environment
A typical use for WinTask is to set up software environment automatically : for example, on all your PCs, you want to force a specific Folder option, or you want to change video settings, or to increase paging file, ...
We give here a couple of examples for setting up such options.
In Folder options, script which checks Show hidden files and folders checkbox:
'Launch Explorer
Shell("explorer",1)
'Use menu shortcuts to select Tools menu and then Folder Options
' The window name below varies depending your Windows version - this window name applies for Windows Vista
UseWindow("EXPLORER.EXE|ToolbarWindow32|Documents|1")SendKeys("<Alt T>")
Pause 5 ticks
SendKeys("O")
UseWindow("EXPLORER.EXE|#32770|Folder Options",1)
Click(Tab,"View")
UseWindow("EXPLORER.EXE|#32770|View",1)
ChooseItem(TreeView, "1", "Show hidden files and folders", single, left )
UseWindow("EXPLORER.EXE|#32770|Folder Options",1)
Click(Button,"&Apply")
'Close Explorer - the window name below is the one in Windows Vista
CloseWindow("EXPLORER.EXE|CabinetWClass|Documents",1)
You can write directly in Registry:
a=1
WriteReg("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\SuperHidden",4,a)
Script changing video settings (the menu options used in this example are under Windows XP, but the same way works under Vista/Windows 7).
function definition()
local i, a$, pos, exit
UseWindow("RUNDLL32.EXE|#32770|Settings ")
pause 10 ticks
'go to screen resolution field
sendkeys("<Tab><Tab><Tab><Tab><Tab><Tab><Tab>",Noactivate)
pause 10 ticks
'move the cursor to the beginning
sendkeys("<Home>",Noactivate)
pause 10 ticks
'go to the resolution that you want (repeat the loop until it reaches the definition you want)
i=0
repeat
sendkeys("<Right>", NoActivate)
pause 10 ticks
i=i+1
until i = 2
UseWindow("RUNDLL32.EXE|#32770|Display Properties",1)
Click(Button,"&Apply")
'The settings are always changed, so you will have always to click Yes
'on the screen Monitor settings.
'We have to change #UseExact to 1 because the previous UseWindow has the same name for the first characters.
#UseExact=1
UseWindow("RUNDLL32.EXE|#32770|Monitor Settings",1)
Click(Button,"&Yes")
pause 1
#UseExact=0
Click(Button,"OK")
EndFunction
'**********************************************************************
'MAIN Program
'**********************************************************************
'call Display in Control Panel.
lgncmde$="control.exe DESK.CPL"
shell(lgncmde$)
'Click Settings Tab
UseWindow("RUNDLL32.EXE|#32770|Display Properties",1)
Click(Tab,"Settings ")
'Call the proc
definition()
Script changing power options:
'Launch directly the Power - NEVER use the Start button - Use always Shell
lgncmde$="control.exe POWERCFG.CPL"
shell(lgncmde$)
'Under Vista, select Power saver scheme
UseWindow("EXPLORER.EXE|CtrlNotifySink|power Options|12",1)
Chick(Radio,"Power saver")
CloseWindow("EXPLORER.EXE|CabinetWClass|Power Options",1)
Script changing paging file size (this example applies to XP - under Vista, the UAC dialog box prompts preventing the automatization unless you deactivate UAC).
'PAGING FILE VARIABLES initialization
init_size$="60"
max_size$="60"
'run system control - never use Start/Settings/Control Panel
lgncmde$="control sysdm.cpl"
shell(lgncmde$)
'choice advanced
UseWindow("RUNDLL32.EXE|#32770|System Properties",1)
Click(Tab,"Advanced")
pause 1
'choice performance options
UseWindow("RUNDLL32.EXE|#32770|Advanced",1)
Click(Button,"&Performance Options...")
pause 1
'button change
UseWindow("RUNDLL32.EXE|#32770|Performance Options",1)
Click(Button,"&Change...")
pause 1
'initial size
UseWindow("RUNDLL32.EXE|#32770|Virtual Memory",1)
WriteEdit("1",init_size$)
pause 1
'Max size
WriteEdit("2",max_size$)
pause 1
'button define and OK
UseWindow("RUNDLL32.EXE|#32770|Virtual Memory",1)
Click(Button,"&Set")
pause 1
Click(Button,"OK")
pause 1
'if window asking for reboot is there
Pause 10 secs until
WinStatus(Exists, Exact)
InWindow("RUNDLL32.EXE|#32770|System Control Panel Applet")
PauseOK
UseWindow("RUNDLL32.EXE|#32770|System Control Panel Applet",1)
Click(Button,"OK")
EndPause
'close window performance options
UseWindow("RUNDLL32.EXE|#32770|Performance Options",1)
Click(Button,"OK")
pause 1
'close system properties window
UseWindow("RUNDLL32.EXE|#32770|System Properties",1)
Click(Button,"OK")
pause 1
'if window asking for reboot is displayed, click No button
Pause 10 secs until
WinStatus(Exists, Exact)
InWindow("RUNDLL32.EXE|#32770|System Settings Change")
PauseOk
UseWindow("RUNDLL32.EXE|#32770|System Settings Change",1)
Click(Button,"&No")
EndPause