From: beginner on 7 Nov 2007 07:51 In article <fgn7ij$9kf(a)aton.abo.fi>, beginner <not.this(a)address.spam.no> wrote: >Could someone show me how I could write a little code >to open 'A.bmp' in Paint, and save it from Paint in 16 >colours by using SendKeys or some better way? Thanks >very much. Surely this can't be impossible or a very stupid question. I have seen that I can start programs with Shell and it is possible to use SendKeys to operate that program, but I am not sure how to open and save files with different options. Can someone help? Is there a good Internet site where I can read about it? Thanks very much.
From: mayayana on 7 Nov 2007 09:10 It's probably possible, but it's fairly awkward. That's probably why you haven't got an answer so far. I think that Sendkeys has been blocked in Vista, too, though I'm not certain of the details about that. What you probably want is VBScript. You can use the WScript.Shell object, which has a Run method, to open Paint. The same object has the Sendkeys method. See here for some sample code for that object: http://www.jsware.net/jsware/scripts.php3#shell The download has samples of both the Run and Sendkeys methods. You can also post to the VBS group for help: microsoft.public.scripting.vbscript And it would be well worth downloading the Windows Script Host help file, which includes VBS help. It should be at the link below, but Microsoft's site is a mess with things regularly being moved around and forwarding links missing. If you don't find the download try a search for script56.chm. WSH v. 5.6 help: http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1- 8A76-1C4099D7BBB9 You can control *some* programs through code. If you're interested in that you might want to look up "automation". Automation is Microsoft's term for making software accessible from the outside. For instance, you can create an instance of Internet Explorer or MS Word from script or VB and make them do pretty much anything through code. But automation has to be built into a program, and it's pretty much limited to IE and MS Office. > >Could someone show me how I could write a little code > >to open 'A.bmp' in Paint, and save it from Paint in 16 > >colours by using SendKeys or some better way? Thanks > >very much. > > Surely this can't be impossible or a very stupid question. I have seen > that I can start programs with Shell and it is possible to use SendKeys > to operate that program, but I am not sure how to open and save files > with different options. Can someone help? Is there a good Internet site > where I can read about it? Thanks very much. >
From: Mike Williams on 7 Nov 2007 14:01 On 7 Nov, 12:51, not.t...(a)address.spam.no (beginner) wrote: >> Could someone show me how I could write a >> little code to open 'A.bmp' in Paint, and >> save it from Paint in 16 colours by using >> SendKeys or some better way? > > Surely this can't be impossible or a very > stupid question. Don't call me Shirley! [just kiddin'] Why are you using the word "surely"? It may be both of those things, or it may be neither, but since you don't know how to do it yourself then you can't be "sure" about the answer to that question :-) Perhaps the help and support contract you purchased has expired? But seriously, the people who answer questions here do it voluntarily in their own free time and they do not earn a penny for their troubles. If you want their help then perhaps you should have a bit of patience. You only posted your question a couple of days ago, and this group does not get the traffic that it once did. 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? 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. 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? 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). 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 ;-) 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? 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? 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? 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. 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" 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
From: mayayana on 7 Nov 2007 14:34 Another note, in addition to the two answers you have so far: If you don't want to get into VB using Windows API (which is quite involved and difficult to follow if you're not familiar with it) you can also use IrfanView via command line. It has a full set of command line options, including a BPP switch that will change the color depth. It's all in the IrfanView help. That would be a lot less messy than trying to use Sendkeys with Paint.
From: beginner on 8 Nov 2007 10:34 In article <13j44s7fjkogp81(a)corp.supernews.com>, mayayana <mayaXXyana1a(a)mindXXspring.com> wrote: > Another note, in addition to the two answers you >have so far: If you don't want to get into VB using >Windows API (which is quite involved and difficult to >follow if you're not familiar with it) you can also >use IrfanView via command line. It has a full set of >command line options, including a BPP switch that >will change the color depth. It's all in the IrfanView >help. That would be a lot less messy than trying to >use Sendkeys with Paint. > Thanks to both of you who have responded. I would like to be able to learn a little bit about SendKeys as well as solve my real problem - creating too many image files in bmp which have little information in the colour, so 16 colours are enough. But now I realise that these are not quite for beginners (my level). I took your advice and besides looking at the site you mentioned, started looking for "automation" of programs in Windows on Google but could not find good pages. I will appreciate if you could suggest me an Internet site where I can read about automation. I would like to learn VBScript when I have several hours of more or less continuous time, may be after Christmas. It is presumably very similar to VB 6 and VBA. IrfanView is not a small program. If it were, I would look at it in a different way. I would like to manage with minimal extra code, and preferably without using third party stuff - the second party being Microsoft. Thanks again. Mike did not succeed in frightening me, but thanks to him also. I don't believe things are as difficult as he makes it sound like.
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: User Defined Data Type --- Please HELP!!!! Next: Multiple icons in exe |