So, does it work for anyone?
And as another tip, for those who haven't had programming training, once you get the hang of the easy stuff like that it is time to transition to creating methods for everything instead of like the code in the Corp Bookmarking Miners example. Methods make it so that you don't have to recode the same things over and over again. In fact, once you become good at it the majority of your code will be debugging, error trapping, and making it work under more various scenarios. (Check out how I can show you two of my core methods without revealing anything useful at all about how the rest of my code works.)
Warning: Spoiler!
; Locks and selects the line by default. confirmLocked is bool on whether to wait to confirm it is locked and select it.
LockLine(lineNum="", confirmLocked=True){
dbgLocal := True , dbgPopUp := False , dbgWindowFunction := " " GetChildParentChain(this) "-LockLine. " , dbgInputs := " Inputs: lineNum=" lineNum
dbgTxt := dbgWindowFunction " Starting. " dbgInputs
Debugger(False, dbgTxt, dbgPopUp, dbgLocal)
; Get if line locked
If(lineNum != ""){
If(this.IsLineTargeted(lineNum) = True){
dbgTxt := dbgWindowFunction "-- Line " lineNum " was already locked."
Debugger(False, dbgTxt, dbgPopUp, dbgLocal)
Return True
}
If(this.ClickLine(lineNum) = False){
dbgTxt := dbgWindowFunction "-- Line " lineNum " could not be clicked."
Debugger(True, dbgTxt, dbgPopUp, dbgLocal)
Return False
}
}
If(this.SelectedItemWindow.Find() = False){
dbgTxt := dbgWindowFunction "-- Error. Could not find SelectedItemWindow. Failed."
Debugger(True, dbgTxt, dbgPopUp, dbgLocal)
Return False
}
If(ClickObj(this.SelectedItemWindow.ButtonLockTarget) = False){
dbgTxt := dbgWindowFunction "-- Line was already locked."
Debugger(False, dbgTxt, dbgPopUp, dbgLocal)
Return True
}
If(confirmLocked = False Or lineNum != ""){
dbgTxt := dbgWindowFunction "-- Success, probably. Returning True without confirmation of lock because lineNum not provided or did not want to confirmLocked."
Debugger(False, dbgTxt, dbgPopUp, dbgLocal)
Return True
}
isLineTargeted := False
; Put mouse back over overview so that lines stay locked in position and keep it moving so it stays locked
; Wait for the line to be locked
targetingStart := A_TickCount
While((A_TickCount - targetingStart) / 1000 < 5 And isLineTargeted = False){
IF(this.IsLineTargeted(lineNum) = True){
isLineTargeted := True
Break
}
this.MoveToLine(lineNum)
Sleep 100
}
If(isLineTargeted = False){
dbgTxt := dbgWindowFunction "-- Line " lineNum " still unlocked after 35 seconds."
Debugger(True, dbgTxt, dbgPopUp, dbgLocal)
Return False
}
Else{
Click
dbgTxt := dbgWindowFunction "-- Line " lineNum " locked after " (A_TickCount - targetingStart) / 1000 " seconds."
Debugger(False, dbgTxt, dbgPopUp, dbgLocal)
Return True
}
}
IsLineTargeted(lineNum){
isLineTargeted := False
aryLinesTargeted := this.GetLinesWithImage("Targeted_Focussed_Selected.png",130,0xB5E61D,1,1)
For i, value in aryLinesTargeted
{
If(value = lineNum){
isLineTargeted := True
Break
}
}
Return isLineTargeted
}