Guide for beginner mac scripters interested in learning how to use Xcode! -
05-17-2007
Hey guys, well im a bit bored and, i know theres alot of anxious people waiting for more mac scripters to come out and make new stuff. So i decided i would make a small guide on how to link applescripts with Xcode for the new people to start developing their own programs!
so, here we go!
we're gonna be making a VERY simple spam bot for wow. This is gonna be in its simplist form and note, its not gonna be the best spam bot out there, this is for learning uses
so, first we need to start with making a Xcode project. and to do that, you need Xcode which can be downloaded here: [Only registered and activated users can see links. ]
after that, boot up Xcode and go up to file, and then New Project then go down to Application and Choose Applescript Application
lets name it Project1 and save it on the desktop.
now, time to make our spambot applescript.
the main script we're gonna use for this project is
Code:
repeat 5 times
tell application "System Events"
tell application "world of warcraft" to activate
key code 36
keystroke "spppaaammmm"
key code 36
delay 30
end tell
end repeat
now, for some explaining on what it means.
1.its pretty easy to understand, first things first,you of course have the repeat at the time showing how many times you want your program to repeat you need to put system events in there because thats what we're workin with, and it also opens up so you can compile the whole script better. ( cant think of a better way to explain this part xD)
2nd.
Code:
Tell application "world of warcraft" to activate
says exactly what it does...: activates world of warcraft, and links it to the following part of the script
Code:
key code 36
.
this will make wow enter key code 36 which is defined as "enter", which allows the bot to enter the spam you want.
3rd. we say
Code:
keystroke "sppaaamm"
this defines what you want to say in game,
and then again:
Code:
key code 36
to enter the text in game.
last: you then can enter a delay on how many seconds till the app is spammed again.
and then
Code:
end tell
at the end to end the script, and
Code:
end repeat
to fully end it.
--- so thats our main script, now to link it into your Xcode program and create your interface!---
in the main screen of your Xcode project, look under goup and files collum, and choose the top tab, in this case Project1
at the bottom of this tab you should see Project1.applescript this is where we are going to input the script we made above, as well as another part to define it to a button to execute into WoW.
so go ahead and open that up and your going to input the script we made with the following changes:
Code:
oon clicked theobject
repeat 5 times
tell application "System Events"
tell application "world of warcraft" to activate
key code 36
keystroke "spppaaammmm"
key code 36
delay 30
end tell
end repeat
end clicked
so, you can see the changes.
1. Onclicked the object. means activated by button.
so we say,
Code:
if theobject is "enter" then
right before the rest of the script, doing this defines this script to the button that we will create in the interface and name it "enter"
at the end of the script we then have to do end if to end the the
Code:
if theobject is "enter"
part of the script.
after you do all this, hit build and if it builds without any errors you can close this window.
NEXT STEP! CREATING INTERFACE!
again in your main Xcode project where you found Project1.applescript
you should see a file called Mainmenu.nib. this is where you build your interface
so click this and it should bring up a couple windows including: "window, Mainmenu.nib control panel, another control panel for putting interface objects in, and a header option.
first, click the window with all the interface objects, click the cocoa-controls tab, and then click and drag one of the buttons that say "button" over to the main window.
after you do that, double click your new button in the main window, and rename it to "enter". ( no quotations of course)
after that, make sure ur still clicked on the button "enter"
and head up to the top applebar where you will find Tools. after you see that, go to "Show Inspector"
this is how your going to link your button with your applescript! click the arrow, its default should be on Attributes, and go down to Applescript.
name it enter and make sure to click : Action, clicked. and at the very bottom Under script click Project1.applescript.
save your Mainmenu.nib and exit.
after that head back to your main Xcode project. and click build at the top of the Xcode window. after it builds search for "project1.app" and open it.
or you can choose build and go, which will build and then run your app.
and after you do that! your done!
click the button on your app "enter" and it should display spaaamm in game.
again, this is just a tutorial on how to link applescripts with Xcode, not for a good spambot :P this program we have made is kind of pointless as a spambot, but it could be used if you wanted, you can always go into project1.applescript and change your scripts.
one last note: if you want to have one or more applescripts in your program with buttons, you will need to define every button as following:
lets say if you want a simple display dialog script. you would do the following:
Code:
on clicked theobject
if theobject is "display dialog 1" then
display dialog "this is a test 1"
else if theobject is "display dialog 2" then
display dialog "this is a test 2"
end if
end clicked
and so on and so on use " else if" defining new buttons as you go along.
if you have any questions please ask and hope this was some help on getting you started off
and forgive me for typo's etc. Kinda late here
Macintosh WoWenhancer:[Only registered and activated users can see links. ]
Mac Scripting Guide: [Only registered and activated users can see links. ][color=red][b]
Last edited by Domminust; 05-19-2007 at 06:57 AM..
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 3
Reputation: 2
Posts: 45
Join Date: Nov 2006
Re: Guide for beginner mac scripters interested in learning how to use Xcode! -
05-17-2007
Nice can't wait to get started have to wait a few hours thugh to download :P +rep
Edit: I was looking through my software cds and I came upon my osx tiger instaltion cd I noticed on the cd that it said xcode 2.0 included. So i popped it in the drive and installed it. This saves a lot of hassle of downloading it from the website.
Last edited by wiredguy8333; 05-17-2007 at 08:38 PM..
Re: Guide for beginner mac scripters interested in learning how to use Xcode!
Re: Guide for beginner mac scripters interested in learning how to use Xcode! -
05-17-2007
Quote:
Originally Posted by Valmilu
Not bad kid you got some spunk
Thanks!
Macintosh WoWenhancer:[Only registered and activated users can see links. ]
Mac Scripting Guide: [Only registered and activated users can see links. ][color=red][b]
Re: Guide for beginner mac scripters interested in learning how to use Xcode!
Re: Guide for beginner mac scripters interested in learning how to use Xcode! -
05-22-2007
hey i was wondering so if i wanted to create a farm bot how would i tell it to turn to face the enemy or to move in the direction of it? if i could figure this out it would help alot for making a bot. and also how would i tell it to eat/drink when low on mana or health.
Re: Guide for beginner mac scripters interested in learning how to use Xcode!