![]() |
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! |
Quote:
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. |
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. |
Quote:
http://www.autoitscript.com/autoit3/ |
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");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 objShHope this helps! |
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 |
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! |
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. :rolleyes: :o End Sub :cool: |
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? |
| All times are GMT -5. The time now is 7:58 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC