Jump to content

Recommended Posts

Posted

Hello wise people of the forums – long time since I’ve asked for assistance – it’s me, the Autoit dabbling accountant who is not a programmer (my standard disclaimer).

Is there somewhere in the forums that I can find a snippet that creates a moving dashstyle rectangle, similar to the one displayed when copying (“^C”) in excel? I’ve searched, but surprisingly could not find. Your help is greatly appreciated.

  • Moderators
Posted

@1905russell are you actually trying to copy data in Excel, or just looking for the effect? If the latter, is this in a GUI, web app, etc.? The more information you provide the better we are able to assist.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted (edited)

Thanks for the quick response JLogan3o13 - I'm just looking for the effect.

I'm making a little movie to illustrate a  software system that I have finally received the US patent for.

The movie uses a bunch of HotKeySets to fake what I can't program (while capturing the screen sequences).

This dash-rectangle would be HotkeySet to display at a selected x,y on top of any image displayed until HotKeySet turns it off and the recorded scene capture is over.

Am I making sense?

 

Edited by 1905russell
clarity
  • 2 months later...
Posted

Well obviously the above requested information I provided produced no help at all. So I tried to get a function written via Upwork/Freelancer (in Autoit or an exe) and I was ripped off by being charged for hours and hours (by mistake I was told) and nothing was ever produced. Upwork/Freelancer refunded me everything they had automatically taken from my credit card.

I know there are Autoit members that can do this easily. It’s for illustration purposes, please. There are many examples of code out there written in #C and other languages and the “marching ants” concept has been around for decades.

I have put together code using two approaches to create dash rectangles (with a hole) using forum snippets but they are static without animation. One uses _WinAPI_ExtCreatePen with $PS_DASH and the other uses _WinAPI_LineDDA. I have also tried to simply use splash image (and text) and then speed up the movie but it looks awful. I’m not a programmer.

I will donate again to Autoit or I will pay someone to help me please. My email for this project is rl@transaxy.com

Posted

Thanks Subz - I truly appreciate this - I had not found this before.  I'll go through these examples and maybe I'll figure out something. I know UEZ is the  animation expert and he could whip up something in seconds. There are others who are also pretty good but alas I think they find it infra dig to deal with me the accountant.  

Posted

a possible way...

#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()

; declare parameters to set the dashed rectangle; (out of screen and hidden at startup)
Global $show = 0, $xPosition = @DesktopWidth, $yPosition = @DesktopHeight, $Width = 10, $Height = 10
Global $RectColor = 0xFFFF0000 ; FFRRGGBB
Global $PixelThickness = 4
DashEdge() ; initialize the rectangle
AdlibRegister("DashEdge", 100) ; set the refresh rate


; Your scipt here....
Local $Timer = TimerInit()
Do

; ... when you need a dotted rectangle somewhere on the screen
; just set the following variables accordingly ...
;
; here we use random values
$show = 1
$xPosition = Random(10, 600, 1)
$yPosition = Random(10, 600, 1)
$Width = Random(200, 500, 1)
$Height = Random(150, 400, 1)
$RectColor = Random(0, 16777215, 1) + 4278190080 ; 0xFF000000 to 0xFFFFFFFF
Sleep(1500)

Until TimerDiff($Timer) >= 10000 ; show demo for ten seconds

; The end
$show = -1 ; set -1 to dispose all
DashEdge() ; Clean up GDI+ resources

Func DashEdge()

; following static variables are generated and initialized only the first time this function is called
    Local Static $AlphaKey = 0xFF0FF0FF ; this color will set background transparent (can be changed)
    Local Static $hGUI = GUICreate("", $Width, $Height, $xPosition, $yPosition, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_TRANSPARENT)
    Local Static $Dummy = _WinAPI_SetLayeredWindowAttributes($hGUI, $AlphaKey, 0, $LWA_COLORKEY)
    Local Static $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local Static $hPen = _GDIPlus_PenCreate($RectColor, $PixelThickness)

    _GDIPlus_PenSetColor($hPen, $RectColor)

    ; dots and dashes alternate
    If _GDIPlus_PenGetDashStyle($hPen) = $GDIP_DASHSTYLEDOT Then
        _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDASH)
    Else
        _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDOT)
    EndIf

    Local $aWinPos = WinGetPos($hGUI) ; check if we need to move the rectangle

    If $aWinPos[0] <> $xPosition Or $aWinPos[1] <> $yPosition Or $aWinPos[2] <> $Width Or $aWinPos[3] <> $Height Then
        _GDIPlus_GraphicsDispose($hGraphic)
        WinMove($hGUI, "", $xPosition, $yPosition, $Width, $Height)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    EndIf

    ; show or hide dashes as from the $show variable
    If $show = 1 Then GUISetState(@SW_SHOW, $hGUI)
    If $show = 0 Then GUISetState(@SW_HIDE, $hGUI)

    _GDIPlus_GraphicsClear($hGraphic, $AlphaKey) ; erase rect
    _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $Width, $Height, $hPen) ; draw again

    If $show = -1 Then ; we have to stop?
        AdlibUnRegister("DashEdge")
        _GDIPlus_PenDispose($hPen)
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_Shutdown()
        WinKill($hGUI)
    EndIf

EndFunc   ;==>DashEdge

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Posted

Yes Yes this will work – Chimp you’re a Champ. Unfortunately I’m away from my main computer for a week and am now using a limited laptop. I’m going to massage your script to run in my mini-movie but I can see that for sure it will work. Thanks to you, my weeks of frustration and going bananas (pun intended) are over. I can’t wait to get back home to modify your code. Thanks again and Abadabadaba 

Posted

Slightly modified version from Chimp's code:

#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()

; declare parameters to set the dashed rectangle; (out of screen and hidden at startup)
Global $show = 0, $xPosition = @DesktopWidth, $yPosition = @DesktopHeight, $Width = 10, $Height = 10
Global $RectColor = 0xFFFF0000 ; FFRRGGBB
Global $PixelThickness = 4
DashEdge() ; initialize the rectangle
AdlibRegister("DashEdge", 100) ; set the refresh rate


; Your scipt here....
Local $Timer = TimerInit()
Do

; ... when you need a dotted rectangle somewhere on the screen
; just set the following variables accordingly ...
;
; here we use random values
$show = 1
$xPosition = Random(10, 600, 1)
$yPosition = Random(10, 600, 1)
$Width = Random(200, 500, 1)
$Height = Random(150, 400, 1)
$RectColor = Random(0, 16777215, 1) + 4278190080 ; 0xFF000000 to 0xFFFFFFFF
Sleep(1500)

Until TimerDiff($Timer) >= 10000 ; show demo for ten seconds

; The end
$show = -1 ; set -1 to dispose all
DashEdge() ; Clean up GDI+ resources

Func DashEdge()

; following static variables are generated and initialized only the first time this function is called
    Local Static $AlphaKey = 0xFF0FF0FF ; this color will set background transparent (can be changed)
    Local Static $hGUI = GUICreate("", $Width, $Height, $xPosition, $yPosition, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_TRANSPARENT)
    Local Static $Dummy = _WinAPI_SetLayeredWindowAttributes($hGUI, $AlphaKey, 0, $LWA_COLORKEY)
    Local Static $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local Static $hPen = _GDIPlus_PenCreate($RectColor, $PixelThickness)
    Local Static $fOffset = 0
    _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDOT)
    _GDIPlus_PenSetColor($hPen, $RectColor)

    DllCall($__g_hGDIPDll, "int", "GdipSetPenDashOffset", "handle", $hPen, "float", $fOffset) ;this is the key for the animated dotted line ;-)

    Local $aWinPos = WinGetPos($hGUI) ; check if we need to move the rectangle

    If $aWinPos[0] <> $xPosition Or $aWinPos[1] <> $yPosition Or $aWinPos[2] <> $Width Or $aWinPos[3] <> $Height Then
        _GDIPlus_GraphicsDispose($hGraphic)
        WinMove($hGUI, "", $xPosition, $yPosition, $Width, $Height)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    EndIf

    ; show or hide dashes as from the $show variable
    If $show = 1 Then GUISetState(@SW_SHOW, $hGUI)
    If $show = 0 Then GUISetState(@SW_HIDE, $hGUI)

    _GDIPlus_GraphicsClear($hGraphic, $AlphaKey) ; erase rect
    _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $Width, $Height, $hPen) ; draw again

    $fOffset += 0.5


    If $show = -1 Then ; we have to stop?
        AdlibUnRegister("DashEdge")
        _GDIPlus_PenDispose($hPen)
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_Shutdown()
        WinKill($hGUI)
    EndIf

EndFunc   ;==>DashEdge

^_^

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)
1 hour ago, 1905russell said:

Yes Yes this will work – Chimp you’re a Champ. Unfortunately I’m away from my main computer for a week and am now using a limited laptop. I’m going to massage your script to run in my mini-movie but I can see that for sure it will work. Thanks to you, my weeks of frustration and going bananas (pun intended) are over. I can’t wait to get back home to modify your code. Thanks again and Abadabadaba

You are welcome :)

 

46 minutes ago, UEZ said:

Slightly modified version from Chimp's code:

.... the master's touch makes the difference!... :)
 

p.s.
@UEZ, the _GDIPlus_PenSetDashStyle allows the $GDIP_DASHSTYLECUSTOM parameter  as a user-defined, custom dashed line, but I've not found how to set the custom dashed line. Here (http://csharphelper.com/blog/2015/02/draw-lines-with-custom-dash-patterns-in-c/) there is a brief explanation on how to setup the custom dashed line, but I don't know how to do it in AutoIt. Do you know how to make use of the  $GDIP_DASHSTYLECUSTOM parameter?? Thank You

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Posted

@Chimp - that could be done this way:

Local Static $fOffset = 0

    _GDIPlus_PenSetColor($hPen, $RectColor)
    
    Local $iCount = 4, $tArray = DllStructCreate("float;float;float;float")
    DllStructSetData($tArray, 1, 5.0)   ;dash length
    DllStructSetData($tArray, 2, 2.0)   ;space length
    DllStructSetData($tArray, 3, 15.0)  ;dash length
    DllStructSetData($tArray, 4, 4.0)   ;space length
    DllCall($__g_hGDIPDll, "int", "GdipSetPenDashArray", "handle", $hPen, "struct*", $tArray, "long", $iCount) ;This method will set the DashStyle enumeration for this Pen object to DashStyleCustom. 
    
    DllCall($__g_hGDIPDll, "int", "GdipSetPenDashOffset", "handle", $hPen, "float", $fOffset) ;this is the key for the animated dotted line ;-)

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

@UEZ, ... it works. Very interesting, it allows nice effects.
Thank You!.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

  • Moderators
Posted

UEZ,

Bravo!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

@UEZ I have always been in awe of your work and was blown away by the fact that you would take an interest in assisting me by expanding on Chimp’s code with your brilliance. I’m so excited and have ants in my pants to get back home to watch them march in my mini-movie. This week, if time allows, I hope to revisit the museum of your inspirer in St Petersburg. He was innovating rock star with his art, as you are with yours. Thank you so much.

  • Moderators
Posted

1905russell,

I agree with both of your assertions: UEZ is indeed our GDI guru and the St Pete's Dali museum is one of my favourites too.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Regarding assertion 1: guys, keep well grounded - no need to exaggerate. :>

Assertion 2: well, maybe one day I will be in St. Petersburg to visit my avatar's art...

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...