I have a script looking in an imaginary box where I say the x and y start positions might be 0,0 their end positions might be 100,100. This will create a box for various functions. Is there a way to light that same square up? Perhaps, I could just tell a picture (colored box) to show up in the given area. Or, maybe there is some way in JAVA? not sure, hoping that perhaps macro 12 has this ability...if so, I can't find a topic to illustrate line drawing or anything. Thanks in advance.
One more thing .... I have thought about just having the mouse move around the perimeter. This would at least illustrate where the box was for user feedback, but a semi-lucent box that would fade in and out would be so much more pleasing to the eyes.
Draw / display a box
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You can use the Windows GDI functions. You can easily draw a rectangle on the screen. For inspiration take a look at the DrawLine subroutine in this post:
http://www.mjtnet.com/forum/viewtopic.php?t=6030
http://www.mjtnet.com/forum/viewtopic.php?t=6030
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Sounds to me like you want the windows API drawing functions. You access these using Macro Scheduler's LibFunc> function. I've posted several sample scripts over the past couple of years but if you don't know what to search for you're not likely to find them.
Here's a couple of subroutines I've created to do drawing. I don't have time to make you a working sample right now and I don't have these commented for you but you can probably figure out how to use them. You can find some of the samples I've already posted by searching the forum for "GetDC". I really need to get these (and others) commented with simple samples and posted in Scripts and Tips.
Hopefully I can get a simpler sample put together later today unless someone else does it first....
Here's a couple of subroutines I've created to do drawing. I don't have time to make you a working sample right now and I don't have these commented for you but you can probably figure out how to use them. You can find some of the samples I've already posted by searching the forum for "GetDC". I really need to get these (and others) commented with simple samples and posted in Scripts and Tips.
Hopefully I can get a simpler sample put together later today unless someone else does it first....
Code: Select all
//DrawLine Usage:
//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd
SRT>DrawLine
LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine
Code: Select all
//DrawRectangle Usage:
//GoSub>DrawRectangle,WindowHandle,PenSize,PenColor,SolidColor,ULXLocation,ULYLocation,LRXLocation,LRYLocation
SRT>DrawRectangle
LibFunc>user32,GetDC,HDC,%DrawRectangle_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawRectangle_var_2%,%DrawRectangle_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
LibFunc>gdi32,CreateSolidBrush,SBres,%DrawRectangle_var_4%
LibFunc>gdi32,SelectObject,SOres,hdc,sbres
LibFunc>gdi32,Rectangle,recres,hdc,%DrawRectangle_var_5%,%DrawRectangle_var_6%,%DrawRectangle_var_7%,%DrawRectangle_var_8%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>gdi32,DeleteObject,DOres,sbres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawRectangle
-
- Macro Veteran
- Posts: 252
- Joined: Fri Apr 15, 2005 8:32 am
Re: Draw / display a box
I could never get MS to draw a rectangle. Is there any sample script I could look at to see what values might follow the GoSub> command? TIA!
Re: Draw / display a box
Wow. It took 11 years to post a sample. I feel bad.
See the comments.
Note that rectangles are filled. If you want a border that is empty in the middle, you'll want to draw four lines.
See the comments.
Code: Select all
//Dialog to put a rectangle in
Dialog>Dialog1
object Dialog1: TForm
BorderIcons = [biSystemMenu, biMinimize]
Caption = 'Rectangle Example'
ClientHeight = 211
ClientWidth = 476
Position = poScreenCenter
end
EndDialog>Dialog1
//handler to exit when the dialog is closed
AddDialogHandler>Dialog1,,OnClose,Quit
Show>Dialog1
SRT>Quit
Exit>0
END>Quit
//draw a red rectangle in dialog1 with a 5 pixel wide border
//a white center and drawn from position 40,40 to 160,160
GoSub>DrawRectangle,Dialog1.handle,5,255,16777215,40,40,160,160
Wait>1
//We loop to keep the rectangle active. If the dialog is minimised
//or goes off the desktop the rectangle goes away. They are not
//automatically redrawn. If you want it to stay visible, it must
//be redrawn continuously
Label>Loop
Wait>0.01
//Draw a green rectangle in dialog1 with an 8 pixel wide border
//a light blue center apositioned from 50,50 to 150,150
GoSub>DrawRectangle,Dialog1.handle,8,111111,16777180,50,50,150,150
Goto>Loop
//DrawRectangle Usage:
//GoSub>DrawRectangle,WindowHandle,PenSize,PenColor,SolidColor,ULXLocation,ULYLocation,LRXLocation,LRYLocation
SRT>DrawRectangle
LibFunc>user32,GetDC,HDC,%DrawRectangle_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawRectangle_var_2%,%DrawRectangle_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
LibFunc>gdi32,CreateSolidBrush,SBres,%DrawRectangle_var_4%
LibFunc>gdi32,SelectObject,SOres,hdc,sbres
LibFunc>gdi32,Rectangle,recres,hdc,%DrawRectangle_var_5%,%DrawRectangle_var_6%,%DrawRectangle_var_7%,%DrawRectangle_var_8%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>gdi32,DeleteObject,DOres,sbres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawRectangle
Code: Select all
//Dialog to put a rectangle in
Dialog>Dialog1
object Dialog1: TForm
BorderIcons = [biSystemMenu, biMinimize]
Caption = 'Rectangle Example'
ClientHeight = 211
ClientWidth = 476
Position = poScreenCenter
object Label1: TLabel
Left = 65
Top = 88
Width = 32
Height = 13
Caption = 'Empty Center'
end
end
EndDialog>Dialog1
//handler to exit when the dialog is closed
AddDialogHandler>Dialog1,,OnClose,Quit
Show>Dialog1
SRT>Quit
Exit>0
END>Quit
//We loop to keep the rectangle active. If the dialog is minimised
//or goes off the desktop the rectangle goes away. They are not
//automatically redrawn. If you want it to stay visible, it must
//be redrawn continuously
Label>Loop
Wait>0.01
//Draw a green rectangle in dialog1 with an 8 pixel wide border
//and positioned from 50,50 to 150,150
GoSub>DrawLine,Dialog1.handle,8,111111,50,50,150,50
GoSub>DrawLine,Dialog1.handle,8,111111,150,50,150,150
GoSub>DrawLine,Dialog1.handle,8,111111,150,150,50,150
GoSub>DrawLine,Dialog1.handle,8,111111,50,150,50,50
Goto>Loop
//DrawLine Usage:
//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd
SRT>DrawLine
LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine
-
- Macro Veteran
- Posts: 252
- Joined: Fri Apr 15, 2005 8:32 am
Re: Draw / display a box
Thank you!
What are the chances I could get MS to draw a shape in a browser like Chrome? I've tried GetWindowHandle> and Let>WIN_USEHANDLE=1, but nothing works when passing the handle to the SRT with GoSub.
What are the chances I could get MS to draw a shape in a browser like Chrome? I've tried GetWindowHandle> and Let>WIN_USEHANDLE=1, but nothing works when passing the handle to the SRT with GoSub.