Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated screenshot + drop at mouse click location #24

Closed
axgkl opened this issue Dec 7, 2020 · 2 comments
Closed

Automated screenshot + drop at mouse click location #24

axgkl opened this issue Dec 7, 2020 · 2 comments

Comments

@axgkl
Copy link

axgkl commented Dec 7, 2020

Hi, thanks for dragon.
No issue here just a note: This is may be of use for someone else as well (just realized I got a few points at SO for it, so why not share):

Function: Hotkey to start script -> select area -> click into drop area. Done.

drag_into

It uses scrot to make a screenshot of a selected area, then dragon, to create a drag window top left, then xdotool to click and drag that to the point where you click.

Here the script

2.bin$ cat drag_into
#!/usr/bin/env bash
doc="$0 <filename|'shot'>

Drags a given file to where the mouse is using dragon. Click to drop it (anywere).
If filename is 'shot' then the file will be a shot of a an area to be selected
(i.e. ideal to be triggered by a hotkey).
"

cmd_shot="shot"
file=

exit_help () { echo -e "$doc"; exit 1; }

select_shot_area () {
    # create screen shot
    notify-send "Select area - we'll shoot it and drag to where the mouse is."
    cd "$HOME/Pictures/shots/" || exit 1
    rm -f "latest.png"
    scrot -s '%Y-%m-%d_$wx$h_scrot.png' -e 'ln -s $f latest.png'
    file="`readlink latest.png`"
}

main () {
    file="$1"
    test -z "$file" -o "$file" == "-h" && exit_help
    eval "$(xdotool getmouselocation --shell)" # into $X and $Y
    test "$file" == "$cmd_shot" && { select_shot_area || return 1; }
    killall dragon 2>/dev/null # No accidential drops of wrong items ...
    dragon --and-exit "$file" &
    while true; do
        xid="$(xdotool search --onlyvisible --class  dragon | head -n 2)"
        test -z "$xid" || break
        sleep 0.05
    done
    xdotool mousemove --sync -w "$xid" 1 1 mousedown 1 mousemove $X $Y
    notify-send "Click to drop $file..."
}

main "$@"
@mwh
Copy link
Owner

mwh commented Mar 8, 2021

Closing this to tidy the open issues list, but it's pretty neat as a script.

@mwh mwh closed this as completed Mar 8, 2021
@axgkl
Copy link
Author

axgkl commented Mar 9, 2021

right, should have closed myself.
Thanks again for dragon, our IT landscape meanwhile keeps me using it bascially all the time :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants