Properly working AHK Script

Last night, I got the AutoHotKey script to work with the Pentax K10D.

Very slick and I can see how I might be able to script things like Maxim.

Here is the properly working code for reference.


#SingleInstance force
CoordMode, mouse, screen



; Get target time in a format we can:
;  - compare (with "<")
; < comparison should be safe as long as both are in the *exact* same format.
; time is 2305 format
; ====================================
; the values listed below are for the eclipse BE SURE TO UNCOMMENT
;filter1timeS = %A_YYYY%%A_MM%%A_DD%090643 ; 9:06:43 am
;filter1timeE = %A_YYYY%%A_MM%%A_DD%101830 ; 10:18:30 am 50 seconds to remove filters
;beads1timeS  = %A_YYYY%%A_MM%%A_DD%101920 ; 10:19:20 am 13 seconds to spam for beads
;beads1timeE  = %A_YYYY%%A_MM%%A_DD%101933 ; 10:19:33 am
;brackettimeS = %A_YYYY%%A_MM%%A_DD%101934 ; 10:19:34 am
;brackettimeE = %A_YYYY%%A_MM%%A_DD%102125 ; 10:21:25 am
;beads2timeS  = %A_YYYY%%A_MM%%A_DD%102135 ; 10:21:35 am 10 seconds to spam for beads
;beads2timeE  = %A_YYYY%%A_MM%%A_DD%102145 ; 10:21:45 am
;filter2timeS = %A_YYYY%%A_MM%%A_DD%102200 ; 10:22:15 am 30 seconds to apply filters
;filter2timeE = %A_YYYY%%A_MM%%A_DD%114102 ; 11:41:02 am

; ====================================
; the values listed below are for testing
filter1timeS = %A_YYYY%%A_MM%%A_DD%222000 ; 
filter1timeE = %A_YYYY%%A_MM%%A_DD%223000 ; 
beads1timeS  = %A_YYYY%%A_MM%%A_DD%223100 ; 
beads1timeE  = %A_YYYY%%A_MM%%A_DD%223115 ; 
brackettimeS = %A_YYYY%%A_MM%%A_DD%223120 ; 
brackettimeE = %A_YYYY%%A_MM%%A_DD%223420 ; 
beads2timeS  = %A_YYYY%%A_MM%%A_DD%223425 ; 
beads2timeE  = %A_YYYY%%A_MM%%A_DD%223435 ; 
filter2timeS = %A_YYYY%%A_MM%%A_DD%223510 ; 
filter2timeE = %A_YYYY%%A_MM%%A_DD%224000 ; 

; ====================================

; send filtersettings ; set single frame shooting with appropriate fstop and shutter speed 
Click 1452, 491 ; set bracket mode off
	SendInput {PgUp}
	SendInput {Enter}
click 1472, 452 ; set single shot
	SendInput {Down}
	SendInput {Enter}
click 1222, 485 ; set shutter speed to 4000 then down to 500 
	sendInput {PgUp}
	sendInput {Down 9}
	sendInput {Enter}
click 1222, 518 ; set f stop to max then to F5.6
	sendInput {PgUp}
	sendInput {Down 12}
	sendInput {Enter}
Click 1501, 14 ; click on shutter control window bar to make active
MouseMove 1565, 363 ; position mouse over shutter button

gosub, filter1

; remove filters audio warning


; send beadsettings ; set continuous shooting speed to Low with appropriate fstop and shutter speedset beads
Click 1452, 491 ; set bracket mode off
	SendInput {PgUp}
	SendInput {Enter}
click 1472, 452 ; set continuous
	SendInput {Down 2}
	SendInput {Enter}
click 1222, 485 ; set shutter speed to 4000
	sendInput {PgUp}
	sendInput {Enter}
Click 1501, 14 ; click on shutter control window bar to make active
MouseMove 1565, 363 ; position mouse over shutter button

gosub, beads1

; send bracketsettings
click 1472, 452 ; set single shot
	SendInput {Down}
	SendInput {Enter}
click 1222, 485 ; set shutter speed to 1/8 from 4000
	sendInput {Down 27}
	sendInput {Enter}
Click 1452, 491 ; set bracket mode on with 5 shots
	SendInput {Down 2}
	SendInput {Enter}
Click 1501, 14 ; click on shutter control window bar to make active
MouseMove 1565, 363 ; position mouse over shutter button

gosub, totality

; beads2
; set beads ; set continuous shooting speed to Low with appropriate fstop and shutter speed
Click 1452, 491 ; set bracket mode off
	SendInput {Up 2}
	SendInput {Enter}
click 1472, 452 ; set continuous
	SendInput {Down 2}
	SendInput {Enter}
click 1222, 485 ; reset shutter speed to 4000 max
	sendInput {PgUp}
	sendInput {Enter}
click 1222, 518 ; set f stop to max then to F5.6
	sendInput {PgUp}
	sendInput {Down 12}
	sendInput {Enter}
Click 1501, 14 ; click on shutter control window bar to make active
MouseMove 1565, 363 ; position mouse over shutter button

gosub, beads2

; apply filters audio warning

;set final filter settings
Click 1452, 491 ; set bracket mode off
	SendInput {PgUp}
	SendInput {Enter}
click 1472, 452 ; set single shot
	SendInput {Down}
	SendInput {Enter}
click 1222, 485 ; set shutter speed to 500 from earlier 4000
	sendInput {down 9}
	sendInput {Enter}
Click 1501, 14 ; click on shutter control window bar to make active
MouseMove 1565, 363 ; position mouse over shutter button
gosub, filter2

goto, terminate

; ====================================

; subroutines

; ====================================

filter1:
; this is first to second contact
; send a picture click once a minute


if (A_Now >= filter1timeS)  
	{ 
	Loop
		{ 
			MouseClick, left, 1565, 363, 1, 10  ; click slowly to ensure shutter register
			sleep 60000 ; wait a minute
			if (A_Now >= filter1timeE)
				break 
			if (A_Now < filter1timeE)
				continue
		}}
	else
		{ 
			Sleep 60000 ; wait a minute
			goto filter1 ; go back to the start of the subroutine
		}
	
return

; ====================================

beads1:
; this is the beads1 subroutine

; press and hold shutter button while beads active
if (A_Now > beads1timeS)
	{
	Loop
		{
			MouseClick, left, 1565, 363, 1, 10, D ; Press and hold shutter button
			if (A_Now >= beads1timeE)
				{
				MouseClick, left, 1563, 363, 1, 10, U ; release shutter button
				Break 
				}
			if (A_Now < beads1timeE)
				sleep 1000 ; wait a second
				continue
		}}
	else
		{ 
			Sleep 1000 ; wait a second
			goto beads1 ; go back to the start of the subroutine
		}
	
return
	
; ====================================

totality:
; this is the subroutine for totality with bracketing

	
if (A_Now > brackettimeS)
	{
	Loop
		{
			MouseClick, left, 1565, 363, 1, 10
			Sleep 3000  ; click every 3 seconds
			if (A_Now >= brackettimeE)
				Break 
			If (A_Now < brackettimeE)
				continue
		}}
	else
				{ 
			Sleep 1000 ; wait a second
			goto totality ; go back to the start of the subroutine
		}
	
return

; ====================================	
	
beads2:
; this is the second beads routine


if (A_Now > beads2timeS)
	{
	Loop
		{
			MouseClick, left, 1565, 363, 1, 10, D ; Press and hold shutter button
			if (A_Now >= beads2timeE)
				{
				MouseClick, left, 1563, 363, 1, 10, U ; release shutter button
				Break 
				}
			if (A_Now < beads2timeE)
				sleep 1000 ; wait a second
				continue
		}}
	else
		{ 
			Sleep 1000 ; wait a second
			goto beads2 ; go back to the start of the subroutine
		}
	
return

; ====================================
			
filter2:
; this is from 3rd to 4th contact


if (A_Now >= filter2timeS)  
	{ 
	Loop
		{ 
			MouseClick, left, 1565, 363, 1, 10  ; click slowly to ensure shutter register
			sleep 60000 ; wait a minute
			if (A_Now >= filter2timeE)
				break 
			if (A_Now < filter2timeE)
				continue
		}}
	else
		{ 
			Sleep 1000 ; wait a second
			goto filter2 ; go back to the start of the subroutine
		}
	
return

; ====================================




terminate:
	exit
	
Esc::ExitApp	

Comments