Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


What language is best for my goal?

 
Logged in as: Guest
arrSession:exec spGetSession 2,7,26375
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> What language is best for my goal?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 What language is best for my goal? - 9/26/2005 10:33:52 PM   
  OLELukoE

 

Posts: 9
Score: 0
Joined: 9/26/2005
Status: offline
Hi everyone, I am a scripting virgin. I need to write a script of what I believe to be medium complexity. I just read a little about  VBS, WSH, Kixtart, Autoit, etc. I am wondering what are their relative advantages/drawbacks in general and for my specific task.

The script I need to write has to do the following: analyze the graphics displayed by a specific program and based on this click on various buttons in that program, then analyze the graphics again, etc.

Any thougths on which language to use would be greatly appreciated. Also, would it be completely insane to not use any of the scripting languages, but C++ instead? Since I've never written any scripts I don't know how much easier the scripting languages make it compared to C++.
 
 
Post #: 1
 
 RE: What language is best for my goal? - 9/26/2005 11:44:53 PM   
  mbouchard


Posts: 1804
Score: 12
Joined: 5/15/2003
From: USA
Status: online
As scripting languages go, you might want to look at AutoIT for this.  Not only, IMO, is the sendkeys better but you can also send mouse clicks and use a function called controlclick, at least that is what I think it is called.  They also have the ability to get screen location fairly easily with AutoIT spy.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to OLELukoE)
 
 
Post #: 2
 
 RE: What language is best for my goal? - 9/27/2005 6:22:47 AM   
  OLELukoE

 

Posts: 9
Score: 0
Joined: 9/26/2005
Status: offline
Thanks! I'm still wondering how much harder (say in terms of required time) the task would be if I were to do in on C++ rather than on one of the scripting languages. My thinking is that if C++ also has commands to move the mouse and simulate mouse clicks and key strokes, wouldn't there be almost no difference if I used C++ or a scripting language?

(in reply to mbouchard)
 
 
Post #: 3
 
 RE: What language is best for my goal? - 9/27/2005 6:30:25 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Some languages are designed to support programming in the large, some are designed to facilitate rapid development of small. Some are for writing device drivers, some are for research and some are for games.  If you have complex structures that you wish to model, it's a good idea to pick a language that models them well.

Prototype classes (JScript) are quite different from inheritance classes (C / C++), which in turn are different from simple record classes (VBScript).

Hope this helps..

Snipah

< Message edited by Snipah -- 9/27/2005 6:31:36 AM >


_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to OLELukoE)
 
 
Post #: 4
 
 RE: What language is best for my goal? - 9/27/2005 12:53:18 PM   
  OLELukoE

 

Posts: 9
Score: 0
Joined: 9/26/2005
Status: offline
I don't yet know much about the scripting languages and in particular what each of them is best for, so I'm looking for specific advice on what language to use and why. I'll be more concrete about what the script does, what I meant by "analyze the graphics" was: Suppose the program in question shows me one of 5 little pictures: say, parrot, dog, dolphin, elephant, and frog. I know exactly where in the program's window these pictures are displayed and there are only 5 possible pictures. My script needs to determine which animal is being shown (by, for example, taking the color of N pixels, with N around 5, i.e. large enough so that the colors uniquely determine the picture) and depending on the result click on one of several buttons in the program's window. Then the whole process repeats. Are all the required commands easily found in one or more of the scripting languages and/or C++?

Also, as the next step, in actuality my script won't be able to decide which button to click on its own, but I have a program (call it Decider to distinguish it from the original program that i'm trying to control) that determines the button to click once it knows what animal is shown, so I want my script to determine the animal, then tell it to Decider, after which Decider would tell the script which button to click. So somehow the script needs to pass small amounts of information to the Decider and back (maybe through the clipboard, though I'm sure there's a better solution). At this level of complexity, are all the required commands readily available in one or more of the scripting languages and/or C++? Which one would you use and how would you pass the info back and forth between the script and Decider?

(in reply to Snipah)
 
 
Post #: 5
 
 RE: What language is best for my goal? - 9/27/2005 8:21:13 PM   
  TNO


Posts: 1036
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Too much info for me I think...

So is this what you are generally trying to do?
  1. Show 1 of 5 pictures at a time (At random)
  2. determine which animal is being shown (Does it matter how this is determined?)
  3. depending on the result click on one of several buttons in the program's window  (click a button? or just send a result somewhere)
  4. Repeat

I believe any COM language able to use the DOM (Document Object Model) can accomplish the task.
I suggest for a beginner to use VBScript due to its intuitive ease of use. JavaScript is also a good choice (A personal favorite)

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to OLELukoE)
 
 
Post #: 6
 
 RE: What language is best for my goal? - 9/27/2005 8:28:36 PM   
  OLELukoE

 

Posts: 9
Score: 0
Joined: 9/26/2005
Status: offline
That's right. The way I was planning to determine which picture is shown is by sampling 5-10 pixels from the area where the picture is located and from the colors of these pixels determine which picture they must belong too (Luckily, in my case, the pictures always appear in the same place). So I need a function which returns the color of a pixels with specified coordinates.

In the simpler scenario, after it determines the picture, it must click on a certain button.

In the more complicated scenario, after it determiens the picture, it must tell it to Decider (a program I already wrote), Decider will then tell it which button to click.

(in reply to TNO)
 
 
Post #: 7
 
 RE: What language is best for my goal? - 9/27/2005 11:17:27 PM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Hiya,

Try this post (finished perfectly by TNO himself)

http://www.visualbasicscript.com/m_24614/tm.htm

This may be the basic groudn from what you need to know....

Snipah

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to OLELukoE)
 
 
Post #: 8
 
 RE: What language is best for my goal? - 9/27/2005 11:19:32 PM   
  TNO


Posts: 1036
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I'm having trouble trying to figure out WHY you need to get the color of some pixels.....You can determine a picture by ALOT simpler means. Do you NEED to know the color of the pixels?

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to OLELukoE)
 
 
Post #: 9
 
 RE: What language is best for my goal? - 9/28/2005 7:05:28 AM   
  OLELukoE

 

Posts: 9
Score: 0
Joined: 9/26/2005
Status: offline
I don't really NEED to know the color of pixels, but I thought this was the simplest way to distinguish  from  etc. (assuming of course there's a function that tells me these colors):

if colorat(56,123)=pink then picturetype=somewhat_annoying_elephant
else if colorat(60,117)=yellow then picturetype=somewhat_annoying_banana
else ....

[This is obviously written in a non-existing language, but you get the gist]

The pictures I have to deal with are static and always located in the same place in the program's window.

Is there a simpler way?

< Message edited by OLELukoE -- 9/28/2005 7:15:43 AM >

(in reply to TNO)
 
 
Post #: 10
 
 RE: What language is best for my goal? - 9/28/2005 8:06:59 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Could you make a decision after knowing the source of the image  e.g.   If imgRndNumb.src = "C:\img\somewhat_annoying_elephant.jpg" Then Decider.NukeIT()


  (got a little carried away, but you get the picture ... euhm point ... -lol-)

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to OLELukoE)
 
 
Post #: 11
 
 RE: What language is best for my goal? - 9/28/2005 9:09:36 AM   
  OLELukoE

 

Posts: 9
Score: 0
Joined: 9/26/2005
Status: offline
Good point! I am sure the program keeps these images in separate picture files somewhere. Though, being the object-oriented programming virgin that I am, I have but a vague idea how this would work in principle. To my understanding, the window contains a bunch of objects, corresponding to all the buttons, images, etc. it displays. So my script would have to get a list of all the objects, then search for the one corresponding to the displayed picture, then get its source. Am I on the right track?

I guess it still would be desirable to learn to get colors of pixels, in case, say, some of the images the program generates are not stored anywhere (like maybe it displays a letter of a specific font or something like that); or in case the program in question runs on a remote website. To that end, I've discovered that AutoIT has a function that gives me the color of the pixels. But I don't want to write the whole script on AutoIT, ideally I'd have Decider and Script as two parts of the same program, so ideally everything would be written in C++, but I'd make use of some functions from AutoIT and/or other scripting languages. Is that at all possible? To my understanding, if AutoIT has dll's, then a C++ program can use functions from these dll's. Is this right?

P.S. For some strange reason, the banana on my computer has stopped moving thus becoming less annoying, while the elephant is still going at it...

(in reply to Snipah)
 
 
Post #: 12
 
 RE: What language is best for my goal? - 9/28/2005 9:22:03 AM   
  TNO


Posts: 1036
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I'll see what I can figure out......

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to OLELukoE)
 
 
Post #: 13
 
 RE: What language is best for my goal? - 9/28/2005 4:54:17 PM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Look at some applications that are made for blind people, those are mostly object-oriented...

And they have to read alotta info from the screen aswell....


PS, moved his thread to a more appropiate place...Scripting Discussions

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to OLELukoE)
 
 
Post #: 14
 
 RE: What language is best for my goal? - 9/28/2005 9:23:31 PM   
  TNO


Posts: 1036
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I think we'll have to work through this step by step:

Step one click on a pic and find out what it is:


      

Next step, do what?

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to Snipah)
 
 
Post #: 15
 
 RE: What language is best for my goal? - 9/29/2005 9:06:00 PM   
  OLELukoE

 

Posts: 9
Score: 0
Joined: 9/26/2005
Status: offline
Ok, next step: a C++ (or another similar language) program has to be able to run the code that determines the animal, then run some algorithm (which I have) that determines which button to click.

After that: it should run a script that moves the mouse to the button's location and clicks it.

Alternatively: The script should run a C++ program which tells it which button to click, after which the script moves the mouse to the button's location and clicks it.

< Message edited by OLELukoE -- 9/29/2005 9:07:26 PM >

(in reply to TNO)
 
 
Post #: 16
 
 RE: What language is best for my goal? - 9/29/2005 9:14:17 PM   
  OLELukoE

 

Posts: 9
Score: 0
Joined: 9/26/2005
Status: offline
Also, the code you wrote displays the pictures. However, in my situation, there is a program (whose code I don't have) which displays a picture. The goal of my script is to find out what it is and then click on a certain button in that program's window. 

(in reply to OLELukoE)
 
 
Post #: 17
 
 RE: What language is best for my goal? - 9/29/2005 9:41:32 PM   
  TNO


Posts: 1036
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
when you click the button(s) what do they do?

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to OLELukoE)
 
 
Post #: 18
 
 RE: What language is best for my goal? - 9/29/2005 10:10:48 PM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
I habe found some C# .NET source code to get the color of the pixel:

Visual C#.NET Source Code

  {
   
       ImageFileName = System.Web.HttpContext.Current.Server.MapPath(ImageFileName); 
       oImage = new Bitmap(System.Drawing.Image.FromFile(ImageFileName));
       y = oImage.Height;
       x = oImage.Width;
       string[,] ImagePixels = new string[y,x];
       for(int h = 0; h < y; h++)
       {  
         for(int w = 0; w < x; w++)
         {
           pixelColor = oImage.GetPixel(h,w);    
           ImagePixels[h,w] = pixelColor.R.ToString() + "." + pixelColor.G.ToString() + "." + pixelColor.B.ToString();
         }
       }

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to TNO)
 
 
Post #: 19
 
 RE: What language is best for my goal? - 9/29/2005 10:50:10 PM   
  TNO


Posts: 1036
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Thanks but I don't see the point of evaluating pixels to determine a picture, nor do i see a reason to use the mouse to automate button clicking when a simple function/event could suffice.

_____________________________

Consolidated Script Component: The Acid Test

A universe of complexity...

(in reply to Snipah)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> What language is best for my goal? Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts