Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Script for the game Lastchaos


  • Please log in to reply
14 replies to this topic
Alexey81
  • Members
  • 10 posts
  • Last active: Sep 10 2014 05:20 AM
  • Joined: 24 May 2014

Advice me please why the sript is not working in the game, but when i tried it in Windows 8 its ok and works properly

 

 
#NoEnv
#Persistent
#SingleInstance force
#HotkeyInterval 0
#InstallKeybdHook
#InstallMouseHook
#UseHook On
#MaxThreads 1
#MaxThreadsPerHotkey 1
SetBatchLines, -1


SetTitleMatchMode, 2 
DetectHiddenWindows, On



~s::
  Loop
  {
	Send {TAB Down}
	Sleep,20
	Send, {TAB Up}
	Sleep, 10


Send, {1 Down}
Sleep,20
Send, {1 Up}
Sleep, 3000
    
	Send, {5 Down}
	Sleep,20
	Send, {5 Up}
	Sleep, 3000


  }
return



Alexey81
  • Members
  • 10 posts
  • Last active: Sep 10 2014 05:20 AM
  • Joined: 24 May 2014

Really nobody knows where a mistake in this script?



Ruevil2
  • Members
  • 226 posts
  • Last active: Dec 04 2015 11:05 PM
  • Joined: 27 Mar 2012

Use search. This is probably one of the most often asked questions in this forum and has been answered many, many times. More than likely the problem isn't with your code at all.


If I helped you out and you would like to show appreciation, feel free to buy me a beer.  grin.png   btn_donateCC_LG.gif


Alexey81
  • Members
  • 10 posts
  • Last active: Sep 10 2014 05:20 AM
  • Joined: 24 May 2014

I have used the search for two days and tried different varients, however it doesn't work. I would like to ask the experienced specialist why the script works under WindowsXP, but doesn't work in Windows8. 

 

Can you pls look through - this script works in WindowsXP

#NoEnv
#Persistent
#SingleInstance force
#HotkeyInterval 0
#InstallKeybdHook
#InstallMouseHook
#UseHook On
#MaxThreads 1
#MaxThreadsPerHotkey 1
SetBatchLines, -1
SetKeyDelay, 30, -1
SetTitleMatchMode, 2 
DetectHiddenWindows, On

TAB::

  Loop
  {
    Send {TAB}
    Send 1
    Sleep 3000
    Send 2
    Sleep 3000
    Send 3
 }
 

return

I wrote the new one based on information from internet search :



Sandpiper
  • Members
  • 79 posts
  • Last active: Nov 21 2014 11:21 AM
  • Joined: 28 May 2014

could be several different reasons from administrator privilege to OS compatibility. You never said what indication you get that it's not working. You could try putting message stops at spots in your code to see if the script is executing up to that point (Divide and conquer)  Also i noticed that you are  using Tab as the hotkey and sending the Tab key inside the hotkey code. you could be getting a hotkey recall error. try using a diff hotkey instead of TAB for the name of the routine (it's hotkey)



Alexey81
  • Members
  • 10 posts
  • Last active: Sep 10 2014 05:20 AM
  • Joined: 24 May 2014

Starting from the TAB the script is not working in the game, i have changed the TAB for anothey key without success. I already tried seven different scripts, as you can see the script starts with key "S" and its not working



Sandpiper
  • Members
  • 79 posts
  • Last active: Nov 21 2014 11:21 AM
  • Joined: 28 May 2014

I tried this code in notepad with windows 7 and it works flawlessly.?

#NoEnv
#singleInstance, Force
#MaxThreadsPerHotkey, 2
#Persistent
SetBatchLines, -1
DetectHiddenWindows, On
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
SetTitleMatchMode, 2
SetKeyDelay, 30,50
SetMouseDelay 10
SendMode Event
#UseHook, On

return

~s::
  Loop
  {
	Send {TAB Down}
	Sleep,20
	Send, {TAB Up}
	Sleep, 10
	Send, {1 Down}
	Sleep, 20
	Send, {1 Up}
	Sleep, 3000
	Send, {5 Down}
	Sleep, 20
	Send, {5 Up}
	Sleep, 3000
  }
return

esc:: exitapp


Sandpiper
  • Members
  • 79 posts
  • Last active: Nov 21 2014 11:21 AM
  • Joined: 28 May 2014

According to what I'm seeing from the game site you should be able to use your script in-game  Just make sure you are not in FullScreen mode (use windowed mode if possible) and make sure the game window has focus before using or activating your script. I'll try to download this later and see if my generic game fight controller script will do the job for me.



Sandpiper
  • Members
  • 79 posts
  • Last active: Nov 21 2014 11:21 AM
  • Joined: 28 May 2014

Update: downloaded the game created a new character and levelled her up to level 3. While doing so i set my game window to 1024x768 windowed and moved the window to the upper left corner of my screen. All game startup, login, window movement and sizing was done using autohotkey. Ran the tutorial section and put my character into autofight with continuous streaming of fight skill and pickup loot. Everything works perfectly. So I know the game can respond to AutoHotkey commands

 

BUT and this is important, Nothing worked properly UNTIL i went into windowed mode NOT fullscreen. Upshot is windowed mode works well with autohotkey and even autospamming fight keys works perfectly. 



Alexey81
  • Members
  • 10 posts
  • Last active: Sep 10 2014 05:20 AM
  • Joined: 24 May 2014

Thank you very much, Sandpiper , for detailed info. Could you please explain how to make game startup, login, window movement and sizing using autohotkey.



Sandpiper
  • Members
  • 79 posts
  • Last active: Nov 21 2014 11:21 AM
  • Joined: 28 May 2014

The keys to doing logins and startup stuff is to be able to recognize and use the different parts of an AutoHotkey program and to set up individual subroutines for doing the stuff you want to do. At the beginning of any script is a section called the AutoRun or AutoStart section. It does everything that needs to be done to set up the initialization commands, common variables and constants and runs various setup routines to login etc. A second major concept that you will need to master is the idea that the info that you need for your game characters and the info you need for running your script are different things. I put all the information that is changeable for different games I play into a separate file called an INI file that the main script reads when it starts up. The following code is liberally commented but i warn you it's the result of a long development process and may not be easy to understand. 

; Setup stuff
#NoEnv
#singleInstance, Force
#MaxThreadsPerHotkey, 2
#Persistent
SetBatchLines, -1
DetectHiddenWindows, On
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
SetTitleMatchMode, 2
SetKeyDelay, 30,50
SetMouseDelay 10
SendMode Event
#UseHook, On

;--------------------------------------------------------------------
; the main script and all game ini files are in the same directory
SplitPath, A_ScriptFullPath, ofname, ofdir, ofext, ofnamene, odrv
SetWorkingDir, %ofdir%

;--------------------------------------------------------------------
; select the game ini file that contains the login information and the
; character data for the game you want to play
FileSelectFile, gameini, 3, %ofdir%\%ofnamene%.ini, %onamene% , %onamene% *.ini
IniRead,LastPlayed,%gameini%,Setup,LastPlayed,Proto
Run, Notepad %gameini%

;passback = Passback.ini ;<-- interprocess communication file

blank =

;standard x-y locations for tooltips and messages
centerx := (A_ScreenWidth // 2)
centery := (A_ScreenHeight // 2)
craftingy := (centery - 100)
ttx = 300
tty1 := 0	
tty2 := 30	
tty3 := 60
tty4 := 90
tty5 := 120

; For target bar checks
NO_TARGET = 0
COMBAT_TARGET = 1
HARVEST_TARGET = 2

; toolkit session timer
;tkfnSessionTimerSet(1,0,0)

IgnoreTgt := 0 ; 1= do not stop fighting after target dies
;ResetKeys := 0
ResetCoolFlags = 1 ; reset cooldow flags for skills
AutoHealFlag = 0
AutoTarget = 0 ;used with continuous fight mode and programmed autotargeting
UseCooldown = 0

; turn of game window check timer
SetTimer, CKWindowExist, Off

;--------------------------------------------------------------------
;Supplemental programs
;--------------------------------------------------------------------
; Do Preloads like timers, wiki sites voice chat clients, etc
Loop,5
{ 	IniRead Preload%A_Index%,%gameini%,Setup,Preload%A_Index%,None
	x := Preload%A_Index%
	If (x = "None")
		break
	Run, %x%
	Sleep,3000
	MsgBox,0,,%x% preloaded`n Continue...
}
	
;--------------------------------------------------------------------
; game setup
;--------------------------------------------------------------------
gosub, LoginStuff ; do the login for account name, email, password
Gosub, WinSetupStuff ; do the window positioning and rezizing
gosub, CharSelectStuff ; do character selection and loading

; turn on game window check timer to clean up on game exit
If (!Debug)
	Settimer, CKWindowExist, 60000

Return ; end of autorun section

And this is an example of what i used for the ini file for logging into LastChaos

[Setup]
Notes=None

;-- preloads
Preload1="C:\Program Files (x86)\FreeStopwatch\FreeStopwatch.exe"
;Preload2="http://www.aeriagames.com/wiki/?game=lastchaos"
;Preload3="C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe"
;
;-- game name and login
GameName=LastChaos
GameDir=C:\GAMIGO\LastChaosUSA
GameLoader=LC.exe
Email=myEmailAddy
Name=myloginName
Password=myLoginPassword
GameWinLoc=None
GameWinResize=0
;
;--last character played
LastChar=myTestChar
;
;-- common data
TgtBarA=None
TgtBarB=None
TgtBarFrame=None
DeadBar=None
DebugIsOn=0
UseCooldown=0
;
;================================================
; Character Data
;------------------------------------------------
;
[myTestChar]
Note=Character Prototype
Created=2014May29
Deleted=None
server=serverPlayedOn
Level=human female Mage L1
Home=None
keyslist=1,2
castlist=500,500
coollist=3000,0
; alternate form for key definitions
; key,cast,cool|key,cast,cool|...
; can be used switch hotbars within the rotation
keysRotation1=1,500,3000|2,500,0
keysRotation2=None
keysRotation3=None
keysRotation4=None
keysRotation5=None
keysRotation6=none
Prefight=None
finisher=None
Postfight=None
healthbar=None
guilded=None
IsHealer=0
;

my login routine looks like this

 

;====================================================================
;login stuff
;====================================================================
LoginStuff:
MsgBox,0x4,, Bypass Login?
IfMsgBox, No
{ IniRead, GameDir, %gameini%, setup, GameDir, None
IniRead, GameLoader, %gameini%, setup, GameLoader, None
IniRead, Debug, %gameini%, setup, DebugVar, 0

OldWorkingDir =
SetWorkingDir, %GameDir%
Run, %GameLoader%
gosub AcctPwd
}
Return

;--------------------------------------------------------------------
^!a:: ;<-- account name and password 
AcctPwd:
SetWorkingDir, %ofdir%
IniRead, email, %gameini%, Setup, Email, None
IniRead, name, %gameini%, Setup, name, None
IniRead, pswd, %gameini%, Setup, password, None
IniRead, gamename, %gameini%, Setup, GameName, None

;----------------------------------------------------------------
; General purpose login for Wildstar
Suspend On

While (!GetKeyState("MButton","P"))
{ ToolTip, Left Click on the beginning of the account/name field and press MButton to send the account name.
}
KeyWait, Mbutton
;loop, 40
;{ Send,{Del} ;<-- delete any displayed name
;}
Send, %name%{Tab}
Sleep 1000

; password

While (!GetKeyState("MButton","P"))
{ ToolTip, Left Click on the password field and press MButton to send the password.
}
KeyWait, MButton
Send, %pswd%{Tab}
sleep 1000
Suspend, Off
return

 



Alexey81
  • Members
  • 10 posts
  • Last active: Sep 10 2014 05:20 AM
  • Joined: 24 May 2014

Thanks for the answer.

I create game.ini(use your script)+you login routine script.

When i load script , script asks me: Bypass login? If i click NO.

I don't understand why I can't attach the picture, writing errors:

 

line#

006: IfMsgBox, No

007: {

007: IniRead, GameDir, %gameini%, setup, GameDir, None

008: IniRead, GameLoader, %gameini%, setup, GameLoader, None

009: IniRead, Debug, %gameini%, setup, DebugVar, 0
011: OldWorkingDir =
012: SetWorkingDir, %GameDir%
013: Run, %GameLoader%
014: gosub AcctPwd
015: }
016: Return
019: Return (i don't see return 019)
021: SetWorkingDir, %ofdir%
022: IniRead, email, %gameini%, Setup, Email, None
023: IniRead, name, %gameini%, Setup, name, None
 
game.ini + main.ahk(you login routine script) to be in the game folder 


Sandpiper
  • Members
  • 79 posts
  • Last active: Nov 21 2014 11:21 AM
  • Joined: 28 May 2014

In my script, way down in the code I have a routine that allows me to reload the entire script again while the game is running. In this case i don't want to reload the game and go through the login a second time. That's what the message box and If statement are used for. If you aren't going to dynamically reload your script this way then you don't need those command. you can use the code shown below

;====================================================================
;login stuff
;====================================================================
LoginStuff:
	;MsgBox,0x4,, Bypass Login?
	;IfMsgBox, No
	{	IniRead, GameDir, %gameini%, setup, GameDir, None
		IniRead, GameLoader, %gameini%, setup, GameLoader, None
		IniRead, Debug, %gameini%, setup, DebugVar, 0
		
		OldWorkingDir =
		SetWorkingDir, %GameDir%
		Run, %GameLoader%
		gosub AcctPwd
	}
	Return

;--------------------------------------------------------------------
^!a:: ;<-- account name and password 
AcctPwd:
	SetWorkingDir, %ofdir%
	IniRead, email, %gameini%, Setup, Email, None
	IniRead, name, %gameini%, Setup, name, None
	IniRead, pswd, %gameini%, Setup, password, None
	IniRead, gamename, %gameini%, Setup, GameName, None
		
	;----------------------------------------------------------------
	; General purpose login for Wildstar
	Suspend On
	
	While (!GetKeyState("MButton","P"))
	{	ToolTip, Left Click on the beginning of the account/name field and press MButton to send the account name.
	}
	KeyWait, Mbutton
	Send, %name%{Tab}
	Sleep 1000
	
	; password
	While (!GetKeyState("MButton","P"))
	{	ToolTip, Left Click on the password field and press MButton to send the password.
	}
	KeyWait, MButton
	Send, %pswd%{Tab}
	sleep 1000
	Suspend, Off
	return	

Remember it's important for you to set the game's directory and the game's launcher names in the ini file. That's how the script knows where to look for the game and what to use to start it up.

[Setup]
Notes=None

;-- preloads
Preload1=None
;
;-- game name and login
GameName=LastChaos
GameDir=C:\GAMIGO\LastChaosUSA
GameLoader=LC.exe
Email=the email address you used to register with the game goes here
Name=your game user name goes here
Password=your password goes here
GameWinLoc=None
GameWinResize=0
;

And don't forget to name the INI file as LastChaos.ini and put it in the same directory as your script so you can see it when the script opens the listing of the inifiles for your different games. I use this same script for logging into Rift, EverQuest2, Wildstar, LastChaos, Age of Conan, Tera. Each game has it's own setup INI file.. The only stuff that changes is the info in each of those separate INI files that the script uses to log into the game I'm playing. One is called Rift.ini one is called EQ2.ini. Wildstar.ini and so on. But the script stays the same.



Alexey81
  • Members
  • 10 posts
  • Last active: Sep 10 2014 05:20 AM
  • Joined: 24 May 2014

I created new file main.ahk and copied your script, created file lastchous.ini . Unfortunatelly, i have the following errors when i try to run the script

 

007: {

007: IniRead, GameDir, %gameini%, setup, GameDir, None

008: IniRead, GameLoader, %gameini%, setup, GameLoader, None

009: IniRead, Debug, %gameini%, setup, DebugVar, 0
011: OldWorkingDir =
012: SetWorkingDir, %GameDir%
013: Run, %GameLoader%
014: gosub AcctPwd
015: }
016: Return
019: Return 
021: SetWorkingDir, %ofdir%
022: IniRead, email, %gameini%, Setup, Email, None
023: IniRead, name, %gameini%, Setup, name, None


Sandpiper
  • Members
  • 79 posts
  • Last active: Nov 21 2014 11:21 AM
  • Joined: 28 May 2014

If you don't have the following code at the bottom of your script add it in and you will be able to use Alt-F10 to see the variables your version of the script is trying to use... Just keep in mind that the script is not a simple piece of code. It may take you a while to understand what it's doing and how it's using the ini file to set up the stuff it needs. Also you want to put in the correct locations where your script lives on your hard drive and where the game's main directory is as well. I used my setup as an example. It might be incorrect for the way your game is installed. 

 

You will want to see the help file on the IniRead command too. Knowing how to use Ini files is crucial to making this script work.

;---------------------------------------
; Hotkeys used for debugging your scripts
;---------------------------------------
^!z:: ;<-- Task manager debugging for screwy lockups
	Run, Taskmgr.exe
	Return

!F5::Suspend
!F6:: ;<--show files
ShowFile:
	FileSelectFile, infile, , , , (*.txt;*.ini)
	Run, Notepad %infile%
	Return
!F7::KeyHistory
!F8::ListHotkeys
pause::pause
!F9::Pause, Toggle
!F10::ListVars
!F11::ListLines
!F12::Reload