Re: Help with SendKeys



In article <1194462072.070301.115240@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Mike Williams <gagamomo@xxxxxxxxxxx> wrote:
On 7 Nov, 12:51, not.t...@xxxxxxxxxxxxxxx (beginner) wrote:

Judging by your newsgroup name you are a beginner in VB. Has it
occurred to you that perhaps the "little code" you have requested
would in fact be a great deal of code and not the simple job that you
appear to think it is?

I somehow can't think it could be so complicated.

MS Paint does not "open itself up to the
outside world" as do some other applications (as far as I know it does
not expose any methods) so everything you do would need to be done by
sending it the appropriate key messages. But what keystrokes do you
think you are going to send to MS Paint, even if we told you how to
send them? You could send Ctrl O to open a file and you could send it
the keystrokes representing the full path and name of the bmp file and
then you could send it Alt O to open the file. But what are you going
to do then? You can't send it Ctrl S to save because if you do that
then MS Paint will simply save the file in its current state and at
its current colour depth, so you are back where you started! Somehow
you are going to have to get it to perform a "Save As", but that
operation does not have a shortcut key (at least not in my version of
MS Paint) and so you are going to need to add lots of extra code to
find the File menu and then more code to move the mouse to that
position and click it.

How about ALT F A and then use TAB instead of fumbling with the mouse?

Then you're goping to have to find the "Save
As" submenu item and click that and then . . . it goes on and on, all
sorts of stuff, including dispensing with the message box that MS
Paint would pop up warning you about loss of colour quality. So, as
you should now be able to see, it is not a simple job using "a little
code". Not a simple job at all. Now can you understand why you have
not yet had any responses?

I thought you people had no problems with showing simple solutions to
difficult VB problems..


Having said all that, I personally don't think that messing about with
MS Paint is the best way to do this kind of thing. The Windows API has
all sorts of functions for creating bitmaps of all different sizes and
colour depths and it is possible to create a memory DC containing a
bitmap of the desired colour depth and to write some code to load your
original full colour (or whatever) bitmap and mess about with your
original pixel colours in such a way that the resultant reduced colour
depth colour bitmap is a reasonable representation of the original
full colour image (or at least as reasonable as it is possible to get
at the colour depth you require). But this kind of thing is hardly the
stuff of beginners (as you appear to be).

I am very much at a beginner level but am very inclined to learning new
things. So I will look up.

If you're interested in
trying that method then you might like to look at the VB Accelerator
code at the following link:

http://www.vbaccelerator.com/home/vb/code/vbMedia/Image_Processing/Colour_Depth_Reduction/article.asp

Otherwise, I'm sure there are various freeware libraries that can
perform these tasks for you and that can be controlled from your VB
program. In fact I know that there are. I don't know the name of any
of them offhand because I've never used them (although the name
FreeImage has just popped into my head?), but I'm sure others here
will post a link for you, if you have a bit of patience ;-)

I can consider that option also, but it would be good to learn small
new things incrementally.


By the way, as far as I understand your original question you are
after a way of converting a full colour 24 bit bmp into a 16 colour
bmp file. Is that what you actually want to do?

Yes, that is one part of the problem. The second is that I want to
learn how to run another program from my VB stuff.

If so then are you
aware that converting it instead to a jpeg can give you just as much a
reduction in file size (or more, of you require) while maintaining a
lot more of the original colour information in the file?

Yes, but the exact colours are not important; sharpness is. Lossless JPG
might be an alternative. Or RLE compression?


Or does your
original full colour bitmap contain no more than 16 individual colours
anyway, and you want to preserve all of them on a pixel by pixel
basis?

I would prefer to keep them on a pixel by pixel basis because I am not
playing with countryside pictures. I have multiple curves of calculated
results. The exact colours of each curve are not important as long as
I can keep them different. Since I never plot more than 10 curves and
one square on one chart, I can and have chosen the colours such that
reducing them to 16 colours still keeps all the colours intact. Colour
reduction algorithm is unnecessary.

If so then have you thought about converting to some other
format, such as a gif, which would give you a greater range of colours
than a 16 colour bitmap and yet achieve similar file size reduction?
There are all sorts of possibilities, but none of them are the "simple
little bit of code" that you appear to think they may be :-)

Incidentally, you haven't said which version of VB you are using.

I have VB 6 and VB 3 (and one thing in VB 4) in use. I even have the
VB 2 user's manual here on my shelf..

If
it is the "real" VB (Visual Basic 6 or previous versions) then that's
fine, but if it is the imposter (the thing with "net" attached to it
somewhere) then you are in the wrong newsgroup and you'll need to post
your question to a dotnet group. In fact, just to show that I don't
really have anything against dotnet (!) you should be "home and dry"

No, I don't like the .net and the fraud of calling a non-VB language
"VB.net". VB 6 should be safe for a few more years.

if you are using it because it gives you native access to the new GDI+
stuff, which should make your current specific task very easy.

Mike



Thanks.





























.



Relevant Pages

  • Re: How Can I Paint a Pixel?
    ... I made a "Paint" program, but I couldn't find a method to paint 1 ... How can I paint 1 pixel? ... So painting a single-pixel bitmap is about the only ... One more question - How can I save graphics that the user has drawn to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: glDrawPixels does not draw a bitmap correctly!
    ... and 98 pixels wide and 25 pixel high... ... But the bitmap still does not align properly. ... PAINt from 98 pixels to 96 pixels, ...
    (comp.graphics.api.opengl)
  • Re: Printed size of screen captures from MS Paint and from Paint Shop Pro.
    ... printed image is 6 inches wide. ... the paste the image into MS Paint or Paint Shop Pro, ... To simplify my explanation I'll stick to explaining what happens on most typical Windows machines which run at the standard 96 pixels per logical inch setting. ... if you perform some action that saves or copies that image as a bitmap then the default logical size of the bitmap depends on whether or not that bitmap contains information relating to its intended physical size. ...
    (microsoft.public.vb.general.discussion)
  • Re: How to stop MS Paint changing resolution of files to 96 dpi?
    ... And this situation is not unique to Paint. ... Some image formats have the DPI is saved in the header of the file, ... display pixel for pixel what the picture looks like. ...
    (microsoft.public.windowsxp.print_fax)
  • Re: Simulate Autoredraw
    ... I personally use the bitblt and it's ligntning ... I would think that an image has to be rendered during each paint ... I was able to figure out to create the graphics from the bitmap, ... and was able to draw to it, ...
    (microsoft.public.dotnet.languages.vb)