China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-08 01:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Sharing] Experiencing the cmd window in Notepad View 1,044 Replies 10
Original Poster Posted 2008-04-07 21:15 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
On a blank area of the desktop, right-click Properties --- Appearance --- Advanced --- Item (I) -- select Window from the drop-down menu:
Color (L), select black from the drop-down menu (I recommend green (80 240 88), it's easier on the eyes)
Color (R), select white from the drop-down menu
Then confirm, Apply, OK!

Actually I'm here to ask a question:
I want to use sendkey to do this, but I can't use the traditional method to select the color drop-down menu.
Just run this directly:
@echo off
::tested under xp
<%0 more +7>col.vbs
start rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2
start col.vbs
exit


wscript.sleep 2000
WScript.CreateObject("WScript.Shell").SendKeys "{tab 4}"
WScript.CreateObject("WScript.Shell").SendKeys "{d}"
WScript.CreateObject("WScript.Shell").SendKeys "{left 15}"
WScript.CreateObject("WScript.Shell").SendKeys "{tab}"
wscript.sleep 1500
msgbox "Could some expert please point this out: how do I send the color drop-down menu? Thanks!"
'WScript.CreateObject("WScript.Shell").SendKeys "{l}"

-------------------------------------------------------
Best answer: see post #10 (answered by zh159, slore, thanks here)

[ Last edited by plp626 on 2008-4-8 at 02:18 PM ]
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 2 Posted 2008-04-07 21:45 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
I only know that sending the space key here can open the color drop-down menu
Floor 3 Posted 2008-04-07 21:51 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
wscript.sleep 2000
Set WSHell = WScript.CreateObject("WScript.Shell")
WSHell.SendKeys "{tab 4}"
WSHell.SendKeys "{d}"
WSHell.SendKeys "{left 15}"
WScript.CreateObject("WScript.Shell").SendKeys "{tab}"
wscript.sleep 1500
MsgBox "Could some expert please point this out: how do I send the color drop-down menu? Thanks!"
'WSHell.SendKeys "{l}"

I suggest doing it this way...
to avoid too many . operations.

Because that one responds to the mouse...
it has nothing to do with key presses, so sendkeys is ineffective.

Two optional methods:
1. Move to Custom, then use sendkeys to select the color you want (key response works here).
2. Modify the registry directly...

I recommend the second method, it's accurate.


PS: sendkeys isn't very reliable, you'd better add delays in the middle of the sendkeys too... you should add a delay before your left, otherwise sometimes it doesn't execute at all.
Floor 4 Posted 2008-04-07 23:05 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
So space works after all. zh159, you really know a lot. I used shift+...., alt+..., tried N+N buttons, and how come I never tried space,

------------------------------
I know you're great at VBS, slore, but I don't understand the second method of modifying the registry.
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 5 Posted 2008-04-07 23:38 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
zh159, slore, a new question: how do I confirm it?

@echo off
<%0 more +6>col.vbs
start rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2
start col.vbs
exit



wscript.sleep 1500
Set WSHell = WScript.CreateObject("WScript.Shell")
WSHell.SendKeys "{tab 4}"
WSHell.SendKeys "{d}"
WSHell.SendKeys "{left 15}"
WScript.CreateObject("WScript.Shell").SendKeys "{tab}"
wscript.sleep 1000
WSHell.SendKeys " "
WSHell.SendKeys "{o}"
WSHell.SendKeys "{tab 4}"
WSHell.SendKeys "160"
WSHell.SendKeys "{tab}"
WSHell.SendKeys "0"
WSHell.SendKeys "{tab}"
WSHell.SendKeys "0"
wscript.sleep 1500
msgbox "Could some expert please point this out: how do I confirm it? Thanks!"


[ Last edited by plp626 on 2008-4-8 at 12:04 AM ]
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 6 Posted 2008-04-08 02:49 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
@echo off
<%0 more +6>col.vbs
start control desk.cpl,,2
start col.vbs
exit



wscript.sleep 1500
Set WSHell = WScript.CreateObject("WScript.Shell")
WSHell.SendKeys "%D"
wscript.sleep 1000
WSHell.SendKeys "{left 15}"
WSHell.SendKeys "%L"
WSHell.SendKeys " "
'wscript.sleep 500
WSHell.SendKeys "%O"
WSHell.SendKeys "{left 7}"
WSHell.SendKeys " "
WSHell.SendKeys "{Enter}"
WSHell.SendKeys "%R"
WSHell.SendKeys " "
'wscript.sleep 500
WSHell.SendKeys "%O"
WSHell.SendKeys "{right 7}"
WSHell.SendKeys " "
WSHell.SendKeys "{Enter}"

'WSHell.SendKeys "160"
'WSHell.SendKeys "{tab}"
'WSHell.SendKeys "0"
'WSHell.SendKeys "{tab}"
'WSHell.SendKeys "0"
'wscript.sleep 1500
'If you use custom colors, you already know how to fill them in, right?
'Send Alt+A to add it to Custom, then Tab to select it, same thing, use space to confirm.

Set WSHell = Nothing
Floor 7 Posted 2008-04-08 02:52 ·  中国 四川 成都 电信
初级用户
Credits 24
Posts 11
Joined 2008-04-06 23:17
18-year member
UID 115139
Gender Male
Status Offline
Supporting the OP a bit, I get it now!
Floor 8 Posted 2008-04-08 02:59 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Originally posted by plp626 at 2008-4-7 23:05:
I just don't understand the second method of modifying the registry.



Too lazy to look closely... just download regshot or some other registry comparison software and see for yourself
the changed values before and after the modification.

I don't know whether the registry refresh is simple or not... changing this place seems to take effect after a right-click refresh...
Anyway, logging off and rebooting definitely make it take effect, heh.
Floor 9 Posted 2008-04-08 10:59 ·  中国 广西 玉林 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Confirming it is very simple, just send an Enter key, because in most system settings interfaces, pressing Enter will by default click the "OK" button
Floor 10 Posted 2008-04-08 14:16 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
The colors below are very soft, everyone can give them a try.
Whoever understands VBS better, if possible, please simplify the code a bit with a for loop:

@echo off
::XP Notepad background color and font color settings.
<%0 more +7>%tmp%\col.vbs
start rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2
start %tmp%\col.vbs
exit
--------------------------
wscript.sleep 1000
Set WSHell = WScript.CreateObject("WScript.Shell")
WSHell.SendKeys "{tab 4}"
WSHell.SendKeys "{d}"
WSHell.SendKeys "{left 15}"
'background color
WSHell.SendKeys "{tab}"
WSHell.SendKeys " "
WSHell.SendKeys "{o}"
WSHell.SendKeys "{tab 4}"
WSHell.SendKeys "160"
WSHell.SendKeys "{tab}"
WSHell.SendKeys "0"
WSHell.SendKeys "{tab}"
WSHell.SendKeys "60"
WSHell.SendKeys "{enter}"
'font color
WSHell.SendKeys "{tab}"
WSHell.SendKeys " "
WSHell.SendKeys "{o}"
WSHell.SendKeys "{tab 4}"
WSHell.SendKeys "80"
WSHell.SendKeys "{tab}"
WSHell.SendKeys "240"
WSHell.SendKeys "{tab}"
WSHell.SendKeys "70"
'confirm, apply.
WSHell.SendKeys "{enter 2}"
WSHell.SendKeys "{a}"
wscript.sleep 2000
WSHell.SendKeys "{enter}"
wscript.sleep 500
msgbox "Color settings completed!"
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 11 Posted 2008-04-08 20:36 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
start rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2


WSHell.SendKeys "{tab 4}"
WSHell.SendKeys "{d}"

Take a look at how I wrote these two lines~ learn to use access keys...

As for simplifying it with a loop, that would just make it look a bit nicer... the pattern here isn't very strong,
and you'd still need to use an array to store each step... troublesome
Forum Jump: