 			GuiControl, -readonly, CustomFormula
 		else
 			GuiControl, +readonly, CustomFormula
+	return
+	
+	ButtonSetupScript:
+		if (InitialMode = False)
+			PGScript := RegExReplace(PGScript, "InitialMode := False `; Init", "InitialMode := True  `; Init", , 1)	
+		FileRead, PGScript, Parent2Gem.ahk
+		FileDelete, Parent2Gem.ahk
+		MsgBox Place your mouse over the top-left corner of the 12*3 craftingfield and press ENTER 
+			MouseGetPos, TLCX, TLCY
+			PGScript := RegExReplace(PGScript, "TopLeftCornerX := [0-9]+", "TopLeftCornerX := " TLCX, , 1)  
+			PGScript := RegExReplace(PGScript, "TopLeftCornerY := [0-9]+", "TopLeftCornerY := " TLCY, , 1)  	
+		MsgBox Place your mouse over the bottom-right corner of the 12*3 craftingfield and press ENTER
+			MouseGetPos, BRCX, BRCY
+			PGScript := RegExReplace(PGScript, "BottomRightCornerX := [0-9]+", "BottomRightCornerX := "BRCX, , 1)  
+			PGScript := RegExReplace(PGScript, "BottomRightCornerY := [0-9]+", "BottomRightCornerY := "BRCY, , 1)
+				
+		FileAppend, %PGScript%, Parent2Gem.ahk
+		
+		TopLeftCornerX := TLCX
+		TopLeftCornerY := TLCY
+		BottomRightCornerX := BRCX
+		BottomRightCornerY := BRCY
+		MsgBox The Script has been adapted to your screen-resolution. `nRemember to do this whenever your screen-resolution changes!
+	
 	return
 	
 	ButtonOk:

		LastDDLTemp = LastDDL := %LastDDL%
		PGScript := RegExReplace(PGScript, "LastDDL := [0-9]*", LastDDLTemp, , 1)	
		
		if ((ChosenIniMode = 0) and (InitialMode = True))
			PGScript := RegExReplace(PGScript, "InitialMode := True  `; Init", "InitialMode := False `; Init", , 1)
		if ((ChosenIniMode = 1) and (InitialMode = False))
			PGScript := RegExReplace(PGScript, "InitialMode := False `; Init", "InitialMode := True  `; Init", , 1)	
	
		FileAppend, %PGScript%, Parent2Gem.ahk		
		Gui, Destroy
	Reload
}
!C::


CombineMode := True
LastGemPos := 1

TopLeftCornerX := 1590 				;  ####### ENTER THE COORDINATES OF THE 3*12 CRAFTINGFIELD ON YOUR SCREEN #########
TopLeftCornerY := 338				;	###### If you don't know how to obtain those values, you'd better  ########
BottomRightCornerX := 1436			;    ##### ask somebody. They don't have to be really precise.     #######
BottomRightCornerY := 686			;	  #### AND THAT'S IT! The script should work for you now!  ######

if (InitialMode = True) {
	FileRead, PGScript, Parent2Gem.ahk
	FileDelete, Parent2Gem.ahk
	MsgBox Place your mouse over the top-left corner of the 12*3 craftingfield and press ENTER 
		MouseGetPos, TLCX, TLCY
		PGScript := RegExReplace(PGScript, "TopLeftCornerX := [0-9]+", "TopLeftCornerX := " TLCX, , 1)  
		PGScript := RegExReplace(PGScript, "TopLeftCornerY := [0-9]+", "TopLeftCornerY := " TLCY, , 1)  	
	MsgBox Place your mouse over the bottom-right corner of the 12*3 craftingfield and press ENTER
		MouseGetPos, BRCX, BRCY
		PGScript := RegExReplace(PGScript, "BottomRightCornerX := [0-9]+", "BottomRightCornerX := "BRCX, , 1)  
		PGScript := RegExReplace(PGScript, "BottomRightCornerY := [0-9]+", "BottomRightCornerY := "BRCY, , 1)
		PGScript := RegExReplace(PGScript, "InitialMode := True  `; Init", "InitialMode := False `; Init", , 1)
	FileAppend, %PGScript%, Parent2Gem.ahk
	
	MsgBox The Script has been initialised and will be reloaded!
	
	Reload
}
	else {
	FieldWidth := (BottomRightCornerX - TopLeftCornerX) / 3
	FieldHeight := (BottomRightCornerY - TopLeftCornerY) / 12
	CraftingField := [BottomRightCornerX -(FieldWidth / 2), BottomRightCornerY -(FieldHeight / 2)]

;
;                     #####         Parent2Gem.ahk - Version 2       #####
; 

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
