What I see is that the script completes a Repeat> loop and a few lines later ends a subroutine. At the end of the subroutine for some unknown reason the script jumps back up to the Repeat> loop Then cycles forever. I know why it cycles forever, I don't understand why it jumps back to the Repeat> loop.
To see this script anomaly:
- Open the script in the editor
- Select any jpg or bmp image file (Preferably something small)
- Hold the CTRL key and pick anywhere on the displayed image.
At this point the script should hit the **BREAKPOINT**. Press F8 to step through the next few lines 'til the end of the subroutine. The next line after the end of the subroutine will be the Repeat> line. Why?
I'm running Macro Scheduler version 11.1.19 on Windows XP SP3
Can anyone confirm this behavior?
Update:
I changed the select Subroutine so that instead of a Repeat> function it uses a label> and a goto> and now when the script reaches the end of the subroutine, it jumps back up to the label. I'm still confused.
Code: Select all
SRT>Select
If>SelectFlag=1
GetCursorPos>CurX,CurY
GetPixelColor>CurX,CurY,TransColor0
GoSub>ConvertColor,TransColor0
Let>NewC=0
Label>Repeat_NewC
Add>NewC,1
Add>red,1
RGB>Red,Grn,Blu,cValue
Let>TransColor%NewC%=cValue
If>%NewC%=%range%
Else
Goto>Repeat_NewC
EndIf
**BREAKPOINT**
SetDialogObjectColor>Dialog9,,TransColor
Let>dialog9.mslabel1=%TransColor%
ResetDialogAction>Dialog9
Let>SelectFlag=2
EndIf
END>Select
Code: Select all
//One time only acquire title bar size
Dialog>TitleBarSizeCalculation
Button=1,0,0,75,25,0
EndDialog>TitleBarSizeCalculation
Let>WIN_USEHANDLE=1
GetWindowPos>TitleBarSizeCalculation.msButton1.handle,OffSetX,OffSetY
Let>WIN_USEHANDLE=0
Let>msg_xpos=800
Let>msg_ypos=0
Let>Xpos=CENTER
Let>Ypos=0
Let>range=30
//VK1 = Mouse pick button
OnEvent>Key_Down,VK1,2,Select
//VK27 = Esc
OnEvent>Key_Down,VK27,8,Quit
//VK192 = ~
OnEvent>Key_Down,VK192,8,EndProcessing
SRT>Quit
Exit>0
END>Quit
SRT>EndProcessing
Let>ChangeKK=%range%
END>EndProcessing
SRT>Select
If>SelectFlag=1
GetCursorPos>CurX,CurY
GetPixelColor>CurX,CurY,TransColor0
GoSub>ConvertColor,TransColor0
Let>NewC=0
Repeat>NewC
Add>NewC,1
Add>red,1
RGB>Red,Grn,Blu,cValue
Let>TransColor%NewC%=cValue
Until>NewC,%range%
**BREAKPOINT**
SetDialogObjectColor>Dialog9,,TransColor
Let>dialog9.mslabel1=%TransColor%
ResetDialogAction>Dialog9
Let>SelectFlag=2
EndIf
END>Select
Input>image,Select a jpg or bmp file to display then recolor
If>image=
Exit>0
EndIf
//Thank you twardega for this script that captures image size.
VBSTART
Function ImgDimensions (ImgFile)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
If fs.fileExists(ImgFile) Then
Set myImg = Loadpicture(ImgFile)
iWidth = round(myImg.width / 26.4583)
iHeight = round(myImg.height / 26.4583)
Set myImg = nothing
ImgDimensions = iWidth & "X" & iHeight
End If
End Function
VBEND
VBEval>ImgDimensions("%Image%"),Size
Separate>size,X,size
Let>Wide={%size_1%+%OffSetX%+%OffSetX%}
Let>Tall={%size_2%+%OffSetY%+%OffSetX%}
Dialog>Dialog5
Caption=Image
Width=%Wide%
Height=%Tall%
Top=%Ypos%
Left=%Xpos%
Image=%image%,0,0,%size_1%,%size_2%,changed,0
EndDialog>Dialog5
Dialog>Dialog9
Caption=Dialog9
Width=360
Height=67
Top=0
Left=500
Edit=msEdit1,120,15,150,%range%
Label= ,10,20,true
EndDialog>Dialog9
Show>Dialog9
Show>Dialog5
Label>Loop
Let>SelectFlag=0
If>selectFlag=0
GoSub>Process
EndIf
Wait>0.01
Goto>Loop
SRT>Process
GetDialogAction>Dialog9,res9
Let>Range=%dialog9.msedit1%
ResetDialogAction>dialog9
Let>SelectFlag=1
Let>WIN_USEHANDLE=1
SetFocus>Dialog1.handle
Let>dialog3.mslabel1=%Dialog1.handle%
Let>WIN_USEHANDLE=0
Message>Select old color
//GoSub>Select
Label>Select1
Wait>0.01
If>SelectFlag=1,Select1
Message>Select new color
//GoSub>Select
Label>Select2
Wait>0.01
If>SelectFlag=2,Select2
ResetDialogAction>dialog3
CloseDialog>Dialog1
CloseDialog>Dialog3
END>Process
SRT>ConvertColor
//Thank you me_again for
//this code that converts a
//color number to RGB values
Let>px=ConvertColor_var_1
Let>px2={%px% MOD 16}
Let>px3={(%px%-%px2%)/16}
Let>px4={%px3% MOD 16}
Let>red={%px2%+(%px4%*16)}
Let>px5={(%px3%-%px4%)/16}
Let>px6={%px5% MOD 16}
Let>px7={(%px5%-%px6%)/16}
Let>px8={%px7% MOD 16}
Let>grn={%px6%+(%px8%*16)}
Let>px9={(%px7%-%px8%)/16}
Let>px10={%px9% MOD 16}
Let>px11={(%px9%-%px10%)/16}
Let>px12={%px11% MOD 16}
Let>blu={%px10%+(%px12%*16)}
////////////////////////////
END>ConvertColor