[Other] Desktop Shortcuts & Various Timesavers

Status
Not open for further replies.

Cheesy

Gold Member
Joined
Jun 1, 2012
Messages
2,101
Likes
157
IG Name
Brian Johnsson
#1
This is outdated. Refer to this instead: viewtopic.php?p=1312234 (For scripts, view the second page)



Forewords

This guide includes multiple tweaks and changes that yourself can do to save time and make it easier. Some sections can be skipped, if they can - I'll made it clear. While it mainly focuses on desktop shortcuts using batch files, there's also a couple more tweaks and changed included. Without any wait, let's start off.
Note: This is written and based on a Windows 7 machine, if you use Linux or Mac, I can not help you. There's still a high chance this works similarly if you use Windows 8 or Windows XP. (If you use Windows Vista, stop reading this, go buy Windows 7 or 8, install it then come back. Trust me, you don't want Vista.) If there's something you can't figure out, drop a reply or pm me, my laptop is running Windows 8, so I or someone else might be able to help you. :)


To start off
The first step into making a short cut to instantly join the RCRP server is to create a desktop short cut to San Andreas Multiplayer executable. You most likely already got one. However most likely you use AutoHotkey. If you do not know what AutoHotkey is, I advise you to look at this guide. As I will not cover AHK here. (Click "This" to go to it.)
I also understand that all does not use this, and as it's pretty simple without AHK I'll include this too. (It's still simple to do it with AHK, don't worry. ;))



Step 1.
Without AutoHotkey
Now, I do advise you to get AHK if you haven't, but if you insist on not using it or don't feel you have a use of it, this is the section you'll want to look at. If you use AutoHotkey, please scroll down to the next step. (For those nuts: It's Step 2!)

1.
Now, let's get to work!
Make sure you got a short cut to "samp.exe" on your desktop. (For backup purposes, please make a copy of this, as every time you click this, you'll directly go to the server, leaving no time to join another server if you so wish.) If you fancy a clean desktop, and have added it to e.g. steam, this will not work. (If using steam, it's possible you can Right click> Properties> Set Launch Options and add the lines below in there. (Someone please try and confirm.))

If you for some reason do not got a short cut to it, navigate to whichever folder Grand Theft Auto San Andreas is installed to.
(For most it's probably: "C:\Program Files (x86)\Rockstar Games\GTA San Andreas\", for 32 bit OS: "C:\Program Files\Rockstar Games\GTA San Andreas\")
Right click samp.exe, hold over "Send to" and select and click "Desktop (Create short cut)".

2.
Right click your samp.exe short cut and click on "Properties". This should open up a small window. Look for "Target:", next to it should be a box with the directory your samp.exe is in.
At the end of this line (Behind the quotation mark.) make a space and add "77.95.226.58:7277". (Or whichever server you want to connect to. This should be in a "IP-ADDRESS:pORT" format.)
Apply and close the properties window. Next, double click the short cut and see how it directly connects you to the server. Job done. :dancer:




Step 2.
With AutoHotkey
So you're like me? A badass with AutoHotkey? Well then you're in the right place! This section of the guide will cover how to run a short cut to not only instantly connect to the server, but also how to start up any AHK scripts while at it. As you might understand, this is a bit harder than without AHK. But follow the guide and it should be a breeze. For fun I will also explain what everything we'll write means. (As a bonus I will add a small tip to your AHK scripting, a script called "TrayTip".)

1.
So to do this we will need to use a so called batch file. You might recognize it's file extension, ".bat". To create a batch file, right click on your desktop> New> Text Document. Rename the text file to whatever you want. (Preferably something like "Red County Roleplay" and not "pr0n".)
"But this is a text file, not a batch file!". Hold on! We won't actually make it into a batch file until we've added the commands to start the program and script up.

2.
So I mentioned commands? Well how this is going to work is that this batch file will send some commands to the so called Command Prompt. (I myself is no expert at this, so if I happen to say something wrong please shout it right out, so I can correct it!)
On this blank piece of text file, we're going to start off by writing "@echo off". This is so it doesn't repeat, or echo the command. Now this will not really happen here, but for fun and to get used, add this.
Next up were going to define the directory our samp.exe is in. You see, the command prompt is a bit of a b#@&%, when it comes to detail and specifying everything. So we'll have to smack it in the face by adding the directory.
Your directory varies as always. The two most common cases as listed in Step 1 are: "C:\Program Files (x86)\Rockstar Games\GTA San Andreas\", or for 32 bit OS: "C:\Program Files\Rockstar Games\GTA San Andreas\".
So to add this type "cd", make a space and paste in your directory. (Without samp.exe at the end!)
Code:
cd C:\Program Files (x86)\Rockstar Games\GTA San Andreas\
Full example of a finished batch file at the end of the step!
As I said I will also explain what it means. Now, what we wrote (cd) is a command prompt command. You can directly type it in the command prompt if you for some reason wanted to. It means "Change Directory". So pretty much we're changing the directory the command prompt is messing around with, or if you like to see it in another way, which directory it's selected. (For a more in depth explanation, and what you can do with the command prompt, google it up, there's many guides out there.) The reason we do this will be made clear in the next line we're going to add.

3.
The next line we're going to add to our batch file is the start command. This will (Obviously) start up our program. As you might guess, it's one of the easiest commands the command prompt uses. BUT! We can't just type in "start" and expect the command prompt to do anything. It still doesn't know what in that directory, which we specified before, it should do. (Luckily it already knows how to handle it, and what to do with it once we've told it to run samp.exe.)
So simply add "start samp.exe".
Code:
@echo off
cd C:\Program Files (x86)\Rockstar Games\GTA San Andreas\
start samp.exe
Now, this will all nicely start up samp.exe if we ran it as a batch file now, but we wanted to directly connect to the server? Well, let's tell the command prompt to connect to it! (It also luckily knows what to do with the IP we're going to give it.)

3.
So get the current server IP (I'm going to try update the guide with the new one when it changes), make a space after samp.exe on the line we just wrote, and type in "77.95.226.58:7277". (To connect to another server, add that servers ip in a IP-ADRESS:pORT format. You can get the server ip in the info tab if you select a server in the SAMP launcher.)
Code:
@echo off
cd C:\Program Files (x86)\Rockstar Games\GTA San Andreas\
start samp.exe 77.95.226.58:7277
Now this will start samp the server directly if we were to run it as a batch file, so if you just wanted to start it with a batch rather than a exe short cut, you're done. Just save it as a batch (Look below) and run it.

4.
Now we've pretty much done all the hard work. What we're going to do next is to add any AHK script we got and have that run as well, so if we press our to-be desktop icon for Red County Roleplay, we'll have any scripts loaded up automatically. This is just a matter of repeating what we've done previously.
Just as before, make a new line and type "cd". Locate your directory the scripts are in and paste it in afterwards. Myself I got my RCRP script in a SAMP folder, which i've created in the SAMP user documents.
Code:
C:\Users\*My name*\Documents\GTA San Andreas User Files\SAMP
No, I won't give you my name, stalkers. ;l
Next up, get your scripts document name, make a new line and add "start <script name>". Make sure that it got the .ahk extension, or if you've compiled it, the .exe extension.
Now, the .ahk extension is usually not known by Windows but when we installed AutoHotkey, it pretty much told Windows what to do if we were to just run it the default way. As the default way of running an ahk. extension, is to run it as a script (Editing and compiling it are the two other side-options.) we can just run it like we would normally do with e.g. a executable.
Oh, and congratulations, we're done writing the batch file, now we just need to save it as a batch file, possibly make it look a bit nicer than the default cogwheels it's icon is and run it!
Code:
@echo off
cd C:\Program Files (x86)\Rockstar Games\GTA San Andreas\
start samp.exe 77.95.226.58:7277
cd C:\Users\*My name*\Documents\GTA San Andreas User Files\SAMP\
start RedCountyRoleplay.ahk

5.
Alrighty, this guide is coming to a close. One of the last things we're going to do is to save the text file as an batch file. To do this, hover over "Archive" (Might be different if you're using else than the default Windows 7 notepad, it should work the same however.) and select "Save As". Not "Save", this will save it as a .txt, which would work, as we could make it into a batch then, but for the sake of simplicity, click Save As. Now, select a name to your to-be short cut. (Again, preferably something like Red County Roleplay rather than pr0n.)
Next up, click where it says "Text Document (.txt)" and select "All Files" in the drop-down menu. *Important* At the end of your file name, add .bat without any spaces in between.
Select your desktop as save location and press save. Note that it placed a batch file on your desktop. If you don't mind how ugly it looks, you're done. Click it and voilá. You can also try to launch it to see if it works, if it doesn't, I have either screwed up badly, or you probably did a typo when writing the commands.

6.
This step is not required, but I recommend you to do it. (Because who doesn't want a fancy RCRP short cut with an icon on their desktop?)
Now, to add all this fanciness, let's start off by making our batch file into a short cut-of-our-batch-file so we can add an icon to it.
I recommend moving your batch file into e.g. your samp documents folder, I moved it into the folder I had my script in, like you saw earlier. (No, you can't delete it and then make a short cut of it. We can't tell Windows to run a short cut pointed to a file that doesn't exist.)
Right click your batch file from wherever you moved it to and hover over> Send to> Desktop (Create short cut).
Now we have our desktop icon that's linked to it, like all our other programs. Now we just need to add that icon to make it fancy.
So, first, let's get a short cut. You can pretty much use any image as long as it's relatively small and fits as a icon. (It doesn't have to be a .ico file, it works with common picture extensions as well.)
One icon you can use is the SAMP icon, it's located in your SAMP folder in your Grand Theft Auto San Andreas directory. The icon I use, is the RCRP icon this site uses.To get it click here. Once you see it, right click the icon, and save it.

Alternative, higher resolution icon. Provided by Christopher. (Click me!)

Next up, right click your desktop short cut and select "Properties". you should see a small box that says "Change icon". Press that. Now, it will tell you it can't find an icon. That's fine. We didn't want it to. Instead, click browse and locate to the folder you saved the icon you want to use. Make sure to select "All Files" in the drop-down menu to the right. Else it won't find your icon.
After selecting your icon, press "Open". Close the properties windows, and adore the fanciness.




Making scripts for multiple characters / Killing off scripts with a batch
Alright. To make a batch file kill off a specified other script(s), you first need to make your scripts into a EXE.

To do this, right click on your script > Compile. You should end up with this fancy AHK short cut, named the same as your script. (It's possible that you did not install the compile part of AHK, reinstall it with it incase you don't got it.) you can leave this in the same folder as your raw script. Now, make a new batch, or edit your exist one. This time, make it run scriptname.exe, instead of scriptname.ahk. At the end of the batch file, you'll have to add one more line, for every script you want to kill off. (Note, you need to compile every script you want to be able to kill off.)

This line is as following:
Code:
taskkill /im "scriptname.exe"
I won't bother explaining it too much, as it should be pretty straight forward. Else, consider it magic.

Example

Yes, I know it's confusing, so I will write a example, for starting and killing off three different scripts.

The three scripts:
Script1.ahk
Script2.ahk
Script3.ahk

First of all, we need to compile all of these scripts into exe's.

You should have the following files afterwards, discluding the raw script files:
Script1.exe
Script2.exe
Script3.exe

So, to the batch part.

Code:
@echo off
cd C:\Program Files (x86)\Rockstar Games\GTA San Andreas\
start samp.exe 77.95.226.58:7277
cd C:\Users\*My name*\Documents\GTA San Andreas User Files\SAMP\
start Script1.exe

taskkill /im "Script2.exe"
taskkill /im "Script3.exe"

Code:
@echo off
cd C:\Program Files (x86)\Rockstar Games\GTA San Andreas\
start samp.exe 77.95.226.58:7277
cd C:\Users\*My name*\Documents\GTA San Andreas User Files\SAMP\
start Script2.exe

taskkill /im "Script1.exe"
taskkill /im "Script3.exe"

Code:
@echo off
cd C:\Program Files (x86)\Rockstar Games\GTA San Andreas\
start samp.exe 77.95.226.58:7277
cd C:\Users\*My name*\Documents\GTA San Andreas User Files\SAMP\
start Script3.exe

taskkill /im "Script1.exe"
taskkill /im "Script2.exe"

"cd C:\Users\*My name*\Documents\GTA San Andreas User Files\SAMP\" should lead to the directory your scripts are in. It's just an example for where I keep mine.

After writing the batch, you can change the icons and such as normal.




AutoHotkey "TrayTip" script
So I talked about that bonus script. We'll, I stand by my word. AHK supports a script written as "TrayTip".
  • Why did I include it? Because just as the rest of the guide, this mainly works for convenience.
  • What it does? It displays a pop-up info box by your program tray in the bottom right. You've probably gotten similar pop-ups before.
  • Why...? Because it will display when the script starts, this way you can instantly see that your script is working and running without having to click and check in your program tray.
This is a very easy script and follows like:
Code:
TrayTip [, Title, Text, Seconds, Options]
If you want to, go to AutoHotkeys own documentation on it, http://www.autohotkey.com/docs/commands/TrayTip.htm, else you may continue reading. I cover everything in... pretty much the exact same way, except i give examples, and is possible less in depth.

So what does the variables mean?
  • Title: Title of the pop-up window. Stands above everything else in a bolder text.
    Red County Roleplay
  • Text: General text. Displays under the title in a less bold text.
    Red County Roleplay Script Started.
  • Time: Time as in seconds. How long the pop-up will stay before it fades away. Note that it takes time for it to fade away. Not too important as you probably won't have time to see it disappear.
    Myself I use 2 seconds.
  • Display Type: What the info box's icon will display as. They display different depending on what it's about normally. Not too important. 1=Info 2=Warning 3=Error 0=No icon.
    I use 1, the info icon.
Make sure to use ,'s to separate the variables.
Code:
TrayTip ,Red County Roleplay,Red County Roleplay Script Started.,2,1


Cheesy @ 2013-2014
 

Cheesy

Gold Member
Joined
Jun 1, 2012
Messages
2,101
Likes
157
IG Name
Brian Johnsson
#2
Re: [Guide] Desktop shortcut to RCRP & Start with AHK script

Reserved for updates. :rcrw:
Using this as a changelog for now.

09 - 12:23 Spelling & Grammar.
09 - 12:14 Grammar.
21:28 Added the so promised TrayTip AHK script. Replaced all new i's i wrote with I's.
21:08 Grammar: Replaced all i's with I's.
21:00 Mixed up the title, added signature. Various fixed.

2013-12-03 - 19:22 Edited a broken URL link.
2013-12-03 - 19:42 Added a link for if you want to terminate other scripts when running your batch.

2014-03-19 Updated for ease of read. Fixed some slight grammar mistakes.
2014-03-28 Large updates to the post, mainly to make it easier to read and easier to navigate. Grammar/spelling mistakes.
 

Christopher

Retired Admin
Joined
Nov 20, 2011
Messages
5,425
Likes
10
IG Name
Christopher Paul
#3
Re: Server & AutoHotkey script shortcuts in a Nutshell

Awesome guide, I used the non-AHK route and it seemed much easier. For the icon, you can use the RC pic from the Facebook group, then convert it to a .ico file ( http://www.convertico.com/ ) so it is not blurry.

Your icon will look like this:

 
Joined
Dec 4, 2010
Messages
19,251
Likes
1,052
IG Name
Robby Wilkinson
#4
Re: Server & AutoHotkey script shortcuts in a Nutshell

I have three AHK scripts, each for different characters.

Is there a way like.. when you click another AHK script, it will kill the previous script?
Example: To start, I open my Christopher_Paul batch file, so I assume it will start my Christopher_Paul script. 15 minutes later, I decided to /q and switch to my Alec_Rae character. So I open my Alec_Rae batch file and I assume it will open my Alec_Rae script. However, I know that when you press a bind, its output will fuck up because there's two AHK scripts running with the same keys.



EDIT:



Why.

Code:
@echo off
cd D:\Games\GTA San Andreas
start samp.exe 77.95.226.58:7277
cd C:\Users\Gigabitz\GTA San Andreas User Files\SAMP
start Haaaxxx.ahk
cd C:\Users\Gigabitz\Documents\AutoHotkey
start FrancisHeston.ahk


I have WinXP 32-bit btw.


Sorted this one.
 

Cheesy

Gold Member
Joined
Jun 1, 2012
Messages
2,101
Likes
157
IG Name
Brian Johnsson
#5
Re: Server & AutoHotkey script shortcuts in a Nutshell

Giga said:
I have three AHK scripts, each for different characters.

Is there a way like.. when you click another AHK script, it will kill the previous script?
Example: To start, I open my Christopher_Paul batch file, so I assume it will start my Christopher_Paul script. 15 minutes later, I decided to /q and switch to my Alec_Rae character. So I open my Alec_Rae batch file and I assume it will open my Alec_Rae script. However, I know that when you press a bind, its output will fuck up because there's two AHK scripts running with the same keys.



EDIT:



Why.

Code:
@echo off
cd D:\Games\GTA San Andreas
start samp.exe 77.95.226.58:7277
cd C:\Users\Gigabitz\GTA San Andreas User Files\SAMP
start Haaaxxx.ahk
cd C:\Users\Gigabitz\Documents\AutoHotkey
start FrancisHeston.ahk


I have WinXP 32-bit btw.


Sorted this one.
First, sorry for the late response. Second, well, there's multiple ways. The one I find sounds simplest, is to make the batch file itself, kill any other scripts. It can't do this out of nothing though, as it got no idea what a file with the .ahk extension is.
The way I would solve this, is to compile the .ahk files into a executable. Usually, it's for people who don't got AHk installed, or to run it directly, and to be used parallel with other files. Or, as for us, to make the command prompt able to terminate it. The only slight annoyance, is that if you want to edit your scripts, you have to recompile, replace the current script executable and make sure it got the same filename as before.

Note: You might be able to do this even simpler, by naming all the scripts the same, placing them in different folders, and using a "SingleInstance" line. This will get jerky though.

I will go and test this for you, before posting anything that might not be true.

Went ahead and tested. It appears like you can simply terminate the general AHK process, but it can screw you over if you only want to kill that single script, and not all you got running.
 

Cheesy

Gold Member
Joined
Jun 1, 2012
Messages
2,101
Likes
157
IG Name
Brian Johnsson
#6
Re: Server & AutoHotkey script shortcuts in a Nutshell

--snip--

Added to main post.
 

Cheesy

Gold Member
Joined
Jun 1, 2012
Messages
2,101
Likes
157
IG Name
Brian Johnsson
#7
Re: Server & AutoHotkey script shortcuts in a Nutshell

Christopher said:
Awesome guide, I used the non-AHK route and it seemed much easier. For the icon, you can use the RC pic from the Facebook group, then convert it to a .ico file ( http://www.convertico.com/ ) so it is not blurry.

Your icon will look like this:

Don't mind if I edit it into the post? Eh? :)
 

Christopher

Retired Admin
Joined
Nov 20, 2011
Messages
5,425
Likes
10
IG Name
Christopher Paul
#8
Re: Server & AutoHotkey script shortcuts in a Nutshell

Cheesy said:
Christopher said:
Awesome guide, I used the non-AHK route and it seemed much easier. For the icon, you can use the RC pic from the Facebook group, then convert it to a .ico file ( http://www.convertico.com/ ) so it is not blurry.

Your icon will look like this:

Don't mind if I edit it into the post? Eh? :)
Of course, anything to help out ;)
 

Cheesy

Gold Member
Joined
Jun 1, 2012
Messages
2,101
Likes
157
IG Name
Brian Johnsson
#9
Updated for ease of read. Feel free to ask if there's anything else you feel should included (Within the limits of the topic title). Planning a full rewrite to make it more fit and a lot shorter
 
Status
Not open for further replies.