I've been languishing with my AHK script.
The earlier example that was posted assumed that I understood how time controls worked. I tested these ideas last night and found my knowledge lacking.
While I was able to get the coordinates and button clicks working with the Pentax K10D camera, I found that my "while" flow control was poorly managed.
Here's what I wrote:
As far as I can tell, none of the time controls worked. I will need to go back to the original target_time AHK examples and see where I went wrong.
The way the script runs now is that the mouse darts around, clicking buttons, changing settings, but the shutter is never fired because the "while" values are never true. What I'd like to see would be that the script waits until the "while" values are true, executes, then moves to the next step.
I see a few possibilities to solve this problem:
I think that the latter solution might be the easiest since I can test each step independently.
On review, I realize that the Task Scheduler won't stop a script at a certain time.
So I'm back to the flow control within AHK. I think that working with loops may be a better solution.
I'm going to try replacing the "while" with logic like this:
After playing with the loops, I see where the time controls failed - it was because of an extra "%" as this prevented the time values to be seen as a number. Still, I rewrote the flow control using if and else and put the bits into subroutines.
Here's how it looks now and I'll try it out tonight:
The earlier example that was posted assumed that I understood how time controls worked. I tested these ideas last night and found my knowledge lacking.
While I was able to get the coordinates and button clicks working with the Pentax K10D camera, I found that my "while" flow control was poorly managed.
Here's what I wrote:
#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.
; target_time is 2305 format
filter1timeS = %A_YYYY%%A_MM%%A_DD%%212500 ; 21:05 pm
filter1timeE = %A_YYYY%%A_MM%%A_DD%%213000 ; 21:10 pm
beads1timeS = %A_YYYY%%A_MM%%A_DD%%213100 ; 21:11 pm
beads1timeE = %A_YYYY%%A_MM%%A_DD%%213130 ; 21:1130 pm
brackettimeS = %A_YYYY%%A_MM%%A_DD%%213020 ; 21:1140 pm
brackettimeE = %A_YYYY%%A_MM%%A_DD%%213320 ; 21:1320 pm
beads2timeS = %A_YYYY%%A_MM%%A_DD%%213325 ; 21:1320 pm
beads2timeE = %A_YYYY%%A_MM%%A_DD%%213400 ; 21:14 pm
filter2timeS = %A_YYYY%%A_MM%%A_DD%%213410 ; 21:1410 pm
filter2timeE = %A_YYYY%%A_MM%%A_DD%%214000 ; 21:20 pm
; send filtersettings ; set single frame shooting with appropriate fstop and shutter speed
click 1472, 452 ; set single shot
SendInput {Down}
SendInput {Enter}
click 1222, 485 ; set shutter speed to 500 from default 125
sendInput {Up 6}
sendInput {Enter}
click 1222, 518 ; set f stop 5.6 from default 8
sendInput {Up 3}
sendInput {Enter}
MouseMove 1565, 363
Click 1501, 14
while ((A_Now >= filter1timeS) and (A_Now <= filter1timeE)) ; this is first to second contact
{ ; send a picture click once a minute
MouseClick, left, 1565, 363, 1, 10
SendInput {Space}
sleep 60000
}
; remove filters audio warning
; beads1
; send beadsettings ; set continuous shooting speed to Low with appropriate fstop and shutter speedset beads
click 1472, 452 ; set continuous
SendInput {Down 2}
SendInput {Enter}
click 1222, 485 ; set shutter speed to 4000 from 500
sendInput {Up 9}
sendInput {Enter}
MouseMove 1565, 363
Click 1501, 14
while ((A_Now >= beads1timeS) and (A_Now <= beads1timeE)) ; this is when first beads goes
{ ; spam beads
MouseClick, left, 1565, 363, 1, 100, D
SendInput {Space}
; at the start
; hold button until the end of beads time
}
MouseClick, left, 1563, 363, 1, 100, U
; click ; at the end, click again to stop the continuous shooting mode
; 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
SendInput {Down 2}
Click 1501, 14
MouseMove 1565, 363
while ((A_Now >= brackettimeS) and (A_Now <= brackettimeE)) ; this is totality
{ ; spam brackets
MouseClick, left, 1565, 363, 1, 100
Sleep 3000
; click every 3 seconds
}
; 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}
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
MouseMove 1565, 357
while ((A_Now >= beads2timeS) and (A_Now <= beads2timeE)) ; this is when second beads goes
{ ; spam beads
MouseClick, left, 1565, 363, 1, 100, D ; at the start
}
MouseClick, left, 1565, 363, 1, 100, U ; at the end, click again to stop the continuous shooting mode
; apply filters audio warning
;set final filter settings
click 1472, 452 ; set single shot
SendInput {Down}
SendInput {Enter}
click 1222, 485 ; set shutter speed to 500 from default 125
sendInput {down 9}
sendInput {Enter}
Click 1501, 14
MouseMove 1565, 357
while ((A_Now >= filter2timeS) and (A_Now <= filter2timeE)) ; this is 3rd to 4th contact
{ ; send a picture click once a minute
MouseClick, left, 1565, 363, 1, 100
sleep 60000
}
return
As far as I can tell, none of the time controls worked. I will need to go back to the original target_time AHK examples and see where I went wrong.
The way the script runs now is that the mouse darts around, clicking buttons, changing settings, but the shutter is never fired because the "while" values are never true. What I'd like to see would be that the script waits until the "while" values are true, executes, then moves to the next step.
I see a few possibilities to solve this problem:
- Build nested "if...then" flow to catch all variations and wrap it all in a loop that waits a minute to try again.
- Build a collection of separate AHK files and call them from the Windows Task Scheduler at the right times.
I think that the latter solution might be the easiest since I can test each step independently.
On review, I realize that the Task Scheduler won't stop a script at a certain time.
So I'm back to the flow control within AHK. I think that working with loops may be a better solution.
I'm going to try replacing the "while" with logic like this:
if (A_Now > filter1timeS)
{
Loop
{
MouseClick, left, 1565, 363, 1, 10
sleep 60000
if (A_Now >= filter1timeE)
break
if (A_Now < filter1timeE)
continue
}
}
After playing with the loops, I see where the time controls failed - it was because of an extra "%" as this prevented the time values to be seen as a number. Still, I rewrote the flow control using if and else and put the bits into subroutines.
Here's how it looks now and I'll try it out tonight:
#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%212000 ;
filter1timeE = %A_YYYY%%A_MM%%A_DD%213000 ;
beads1timeS = %A_YYYY%%A_MM%%A_DD%213100 ;
beads1timeE = %A_YYYY%%A_MM%%A_DD%213115 ;
brackettimeS = %A_YYYY%%A_MM%%A_DD%213120 ;
brackettimeE = %A_YYYY%%A_MM%%A_DD%213420 ;
beads2timeS = %A_YYYY%%A_MM%%A_DD%213425 ;
beads2timeE = %A_YYYY%%A_MM%%A_DD%213435 ;
filter2timeS = %A_YYYY%%A_MM%%A_DD%213510 ;
filter2timeE = %A_YYYY%%A_MM%%A_DD%214000 ;
; ====================================
; send filtersettings ; set single frame shooting with appropriate fstop and shutter speed
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}
gosub, filter1
; remove filters audio warning
; send beadsettings ; set continuous shooting speed to Low with appropriate fstop and shutter speedset beads
click 1472, 452 ; set continuous
SendInput {Down 2}
SendInput {Enter}
click 1222, 485 ; set shutter speed to 4000
sendInput {PgUp}
sendInput {Enter}
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}
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}
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}
gosub, beads2
; apply filters audio warning
;set final filter settings
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}
gosub, filter2
; ====================================
; subroutines
; ====================================
filter1:
; this is first to second contact
; send a picture click once a minute
Click 1501, 14 ; click on shutter control window bar to make active
MouseMove 1565, 363 ; position mouse over shutter button
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
gosub, filter1 ; go back to the start of the subroutine
}
}
return
; ====================================
beads1:
; this is the beads1 subroutine
Click 1501, 14 ; click on shutter control window bar to make active
MouseMove 1565, 363 ; position mouse over shutter button
; 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)
continue
}
else
{
Sleep 1000 ; wait a second
gosub, beads1 ; go back to the start of the subroutine
}
}
return
; ====================================
totality:
; this is the subroutine for totality with bracketing
Click 1501, 14
MouseMove 1565, 363
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
gosub, totality ; go back to the start of the subroutine
}
}
return
; ====================================
beads2:
; this is the second beads routine
Click 1501, 14
MouseMove 1565, 357
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)
continue
}
else
{
Sleep 1000 ; wait a second
gosub, beads2 ; go back to the start of the subroutine
}
}
return
; ====================================
filter2:
; this is from 3rd to 4th contact
Click 1501, 14
MouseMove 1565, 357
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
gosub, filter2 ; go back to the start of the subroutine
}
}
return
; ====================================
exit
Comments
Post a Comment