AutoHotkey script

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting. You may Image to help finance the hosting costs of this forum.
Post Reply
User avatar
ian_scho
High Lord
Posts: 2807
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

AutoHotkey script

Post by ian_scho »

Bored by clicking the Enter button to the dungeon at startup? Insane, but me too. After 3 hours of wasting my life in an attempt to save 3 seconds, here's the AutoHotkey script to do that for you ----> Read the 3 DSB Note comments:

Code: Select all

#SingleInstance Force

; DSB Note: - Profile specific variables so CHANGE v_DSBDirectory PLEASE
v_DSBTitle=dsb
v_DSBDirectory=C:\Documents and Settings\ian.schofield\Mis documentos\personal\dsb\DSB_0_35\
v_DSBApp=DSB.exe
v_DSBXEnterPos=502
v_DSBYEnterPos=146

; DSB Note: - I have added the following line in my dsb.ini file, autoselecting the dungeon:
; Dungeon=test_dungeon 
; DSB Note: - And I have updated dsb.ini to windowed mode (colour picking and mouse coordinates work)
; Windowed = 1

; If the app is already open, close it
IfWinExist, %v_DSBTitle%
{
	WinClose, %v_DSBTitle%
}

; Set Working directory - can't find the dsb 'Dungeon' value at startup otherwise
SetWorkingDir, %v_DSBDirectory%

; Run the beast
Run %v_DSBDirectory%%v_DSBApp%, , , newpid

; You need to wait a little for the window to initialize
winwait, ahk_pid %newpid%

; Coords are ALREADY Relative to the window but we're foobarred as we can run in both full or multiwindowed mode
;CoordMode,Pixel,Relative
;CoordMode,Mouse,Relative

; Wait for GREEEEEEN gem on the Enter Button to appear
Loop {
	; Snooze a while for the app to load
	sleep 1000
		
	; Test if we have the green found in the Enter button yet
	PixelGetColor, color, %v_DSBXEnterPos%, %v_DSBYEnterPos%, RGB ; Alt,Slow = Different methods to get a colour
	
	;MouseGetPos, xpos, ypos 
	;ToolTip XPos is %xpos% and YPos is %ypos% while colour is %color%
	
	If (color=0x00db00) 
		break
}

; Click Mouse Button to Enter
MouseClick, left, %v_DSBXEnterPos%, %v_DSBYEnterPos%

; End
return
User avatar
Sophia
Concise and Honest
Posts: 4307
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: AutoHotkey script

Post by Sophia »

You can do this from within DSB, too, you know. If the other script was a lot of trouble I wish you would have asked. :wink:

This Lua code will skip the "Dungeon Strikes Back" animation and automatically "Enter" instead of even showing you the front door. The dungeon will come up almost instantly.

Code: Select all

function sys_game_intro()
   return true
end

function sys_game_start(savegames)
   return nil
end
User avatar
ian_scho
High Lord
Posts: 2807
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

Re: AutoHotkey script

Post by ian_scho »

No way! That's sweet, ty.

I've learnt a little of AHK anyway, and I can now automagically login the two servers at work - while supping coffee.
Post Reply