Click here to Skip to main content
15,884,040 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
VB
For Each p As Process In Process.GetProcessesByName("notepad")
    AppActivate(p.Id)
    My.Computer.Keyboard.SendKeys("%of", True)
    Me.BringToFront()
Next

I can open notpad font window using sendkeys.
But How to change values of notepad font box using sendkeys???
Posted
Comments
Sergey Alexandrovich Kryukov 25-Apr-13 0:53am    
Why doing so? This is a total abuse. It's millions times better to put a decent editor control in your application than using Notepad which is not designed to be controlled by your application.
—SA

1 solution

You have to send the keys to open the font dialog first. On my Swedish computer it's "Alt + t" to open the format menu, then "Alt + t" to open the font dialog. Then a third "Alt + t" to access the font name box, and then the font name to change it. (You need to check on your own computer what the combination is by holding down the Alt key and noticing what character that is underlined in the menus and controls)

Then of course you have to close the dialog afterwards (Enter, I think).

Of course, there's no guarantee that this is going to work all the time if the user or another program removes focus from Notepad.

Also, you might have to execute a sleep between each key combination to give the program time to react.

The only way is to experiment, but when that is said, I really don't understand what it is you're trying to achieve by this...

It will be all but impossible to create a solution that will work on all Windows languages.
 
Share this answer
 
v2
Comments
Rohit Ramachandaran 18-Apr-13 8:29am    
It works!!!
Thanks Buddy! :)

But how can i read a textbox from font dialog box???
Johnny J. 18-Apr-13 8:32am    
Hate to tell you, but I doubt very much that you can do that. MAYBE: if you send "CTRL + A" to select the text and "CTRL + C" to copy it to the clip board and then get it from there using ClipBoard.GetText()
Rohit Ramachandaran 18-Apr-13 9:03am    
Okkkk........
That Worked like a charm!!!

Now i am trying this on a more more more complex programme......
Rohit Ramachandaran 23-Apr-13 3:08am    
How to read a SysListView32 control??
Johnny J. 23-Apr-13 3:13am    
That is MUCH more difficult. You will have to find the handle of the control (hWnd) and use windows messaging to get/set the contents. I used to do that many years ago (before .NET), but to be honest, I can't remember exactly how it's done. All I remember is that it was difficult.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900