Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 19th, 2006, 10:00 AM   #1
zaracyn
Newbie
 
zaracyn's Avatar
 
Join Date: Jun 2006
Location: Michigan
Posts: 13
Rep Power: 0 zaracyn is on a distinguished road
Automating a map editor

Here's basically what I want to do:

I've got this map editor for a game (Space Empires IV) and I want to automate the creation of connections between objects on the map. It's kind of tedius to do by hand but it's all GUI based and I know the coordinates of where I want to place every thing.

To summerize what I'd like to do:
1.) automate certain aspects of map creation
2.) pull from database (such as Excel file or text file) coordinates of specific objects to place on map.

I'm familiar with programming, but a bit rusty, so I wouldn't say I'm a newbie, but any little help would be appreciated.

Thanks!
zaracyn is offline   Reply With Quote
Old Jun 19th, 2006, 1:47 PM   #2
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 242
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
Quote:
Originally Posted by zaracyn
Here's basically what I want to do:

I've got this map editor for a game (Space Empires IV) and I want to automate the creation of connections between objects on the map. It's kind of tedius to do by hand but it's all GUI based and I know the coordinates of where I want to place every thing.

To summerize what I'd like to do:
1.) automate certain aspects of map creation
2.) pull from database (such as Excel file or text file) coordinates of specific objects to place on map.

I'm familiar with programming, but a bit rusty, so I wouldn't say I'm a newbie, but any little help would be appreciated.

Thanks!


What do the map files this program generates look like?

I used to map in counter-strike and i know the map editor simply spits out a text file full of coordinates, texture sources, and whatnot. I know some professional map designers don't even use the UI but simply create much of their maps right in notepad lol.

Is this how your program work as well, I'd imagine it does?
If so you simply have to figure out how that text file is structured and insert the values you need at the correct lines. Maybe post a map file up here so we can take a look at the format.
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote
Old Jun 20th, 2006, 1:04 AM   #3
zaracyn
Newbie
 
zaracyn's Avatar
 
Join Date: Jun 2006
Location: Michigan
Posts: 13
Rep Power: 0 zaracyn is on a distinguished road
The map files have a *.MAP extension on them. Opening them up in a text file all you'll see is goblety-gook. When you you open it up in a C++ editor you see assembly/hex code.

Part of what makes the map creation so tedius is the linking of star systems with worm holes. You have to both starting and ending co-ordinates and system names for each hole. If this process itself could be automated in some fashion, it would cut down on map creation time.

My initial idea was for a script file of some sort to manipulate the GUI, but I'm not as familiar with scripts as I would like to be, so I don't know if they can handle GUI in the fashion I've described.
zaracyn is offline   Reply With Quote
Old Jun 20th, 2006, 1:13 PM   #4
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 242
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
Quote:
Originally Posted by zaracyn
My initial idea was for a script file of some sort to manipulate the GUI, but I'm not as familiar with scripts as I would like to be, so I don't know if they can handle GUI in the fashion I've described.
I've done stuff like this before, here is a good program that can do stuff like this (simulate keystrokes, mouse movements, etc), its pretty neat if you wanted to go that route.

http://www.autoitscript.com/autoit3/
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote
Old Jun 23rd, 2006, 4:00 PM   #5
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
The garbage you see in your text editor and hex you see in your code editor imply that the file is binary rather than ASCII text. Unless you want to really spend a lot of time hacking, mostly fruitlessly, you're not going to be able to manipulate the files directly (ah, unless you can find some documentation of the format online, which I wouldn't entirely rule out though it's unlikely). I would definitely go with the GUI manipulation option.

I've not tried that 'autoitscript' thing, though I've brushed with it and it doesn't look all that hard to learn. I've occasionally written windows programs using VB, VBScript and JScript that manipulated other programs by faking keystrokes, though I'm not aware of a way to fake mouse input programmatically in these languages. You can use the same method in anything that can instantiate and use COM objects I believe. You create a WScript.Shell object and then use its AppActivate and SendKeys methods. In JScript, it looks like this:

var sh = WScript.createObject("WScript.Shell");
sh.appActivate("notepad");
sh.sendKeys("Hello notepad!{ENTER}");

That {ENTER} actually sends the key Enter. You can use curly braces to send a variety of keys, most of which are quite obvious, like {UP}, {DOWN}, {HOME}, and many others. You also need to put the braces around certain characters that mean something special, like + (which 'holds shift' and presses whatever's to the right of it; e.g. "+s" gives you shift-s (i.e. a capital S)), % (Alt; e.g. exit the foreground application with "%{F4}") and ^ (control; like "^x" for control-x).

To put a few of those together:

sh.sendKeys("{HOME}+{END}^x{UP}{END} ^v");

This takes, in most text editing and word processing type programs, the whole of the line the cursor is on at the start (home, then hold shift and press end), cuts it to the clipboard (control x), goes up one line and to the end and adds a space then pastes the line in. Of course it assumes that sh is a WScript.Shell object and that the current foreground application is the word processing or text editing software in question.

There's a nice little guide online to using WScript.Shell to control other applications using sendKeys at http://www.freeweb.hu/wsh2/ch13d.html - this is quite well written and complete without being too wordy and includes quick reference tables for the special characters and some code examples.

Using WScript.Shell from other languages to send keystrokes works in a very similar way; a quick VBScript example:

Dim objSh
Set objSh = CreateObject("WScript.Shell")
objSh.AppActivate "notepad"
objSh.SendKeys "Hello notepad!{ENTER}"

Hope this helps!
__________________
"I'm not a genius. Why do I have to suffer?"

Last edited by mackenga; Jun 23rd, 2006 at 4:03 PM. Reason: Thinko - corrected some JScriptiness in my VBScript
mackenga is offline   Reply With Quote
Old Jun 27th, 2006, 10:40 PM   #6
zaracyn
Newbie
 
zaracyn's Avatar
 
Join Date: Jun 2006
Location: Michigan
Posts: 13
Rep Power: 0 zaracyn is on a distinguished road
Thanks! To both of you! I'll try them out see how far I can get



----------------------------------------------------------
"No blame, no shame, just get back in the game!" - Unknown
zaracyn is offline   Reply With Quote
Old Aug 3rd, 2006, 10:58 PM   #7
zaracyn
Newbie
 
zaracyn's Avatar
 
Join Date: Jun 2006
Location: Michigan
Posts: 13
Rep Power: 0 zaracyn is on a distinguished road
OK, I'm making some progress. I've got some scripts that do what I want but now I need to figure out how to launch them in a VB program.

Basically just need some help on specific syntax:

Private Sub Command1_Click()
.
.
.
<insert magic code activating MyScript.js>
.
.
.
End Sub

Thanks in advance for any tips on finding a solution to this!
zaracyn is offline   Reply With Quote
Old Aug 4th, 2006, 12:05 PM   #8
zaracyn
Newbie
 
zaracyn's Avatar
 
Join Date: Jun 2006
Location: Michigan
Posts: 13
Rep Power: 0 zaracyn is on a distinguished road
Never mind, I got it to work on my own :banana:


Option Explicit

'============================================
' API declaration
'============================================
Private Declare Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Private Sub Command1_Click()
Dim sFile As String
Dim sCommand As String
Dim sWorkDir As String

sFile = "C:\MyScript.js" 'The file to execute
sCommand = vbNullString 'Command line parameters
sWorkDir = "C:\" 'The working directory

ShellExecute hwnd, "open", sFile, sCommand, sWorkDir, 1
' Obviously, the file must exist at that location for this to work. :o
End Sub


Last edited by zaracyn; Aug 4th, 2006 at 12:22 PM.
zaracyn is offline   Reply With Quote
Old Aug 27th, 2006, 10:09 PM   #9
zaracyn
Newbie
 
zaracyn's Avatar
 
Join Date: Jun 2006
Location: Michigan
Posts: 13
Rep Power: 0 zaracyn is on a distinguished road
I hit a snag...

I want to paste a system name into a drop down list, but every time I do it I end up in the "v" section of the drop down list.

I know WHY it's happening...the paste function is being interpreted as a selection in the drop down list, I thus end up in the "v" section. This will happen even I'm not using sendkeys and just trying to paste.

What I want is a way around this problem. I suppose if I could figure a way to simply parse the pasted selection I could then enter it into the drop down menu until it matched the selection. Is there a way I can do this?
zaracyn is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:12 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC