WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Selecting an area of the screen for a screenshot using your mouse  (Read 3838 times)

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #45 on: October 15, 2015, 10:07:10 AM »
Hi nitram
I hadn't planned on submitting it as an extension. If someone thinks it's worth putting into the repository, they're
welcome to do so with my blessing. Just read through the thread and apply the appropriate fixes first.
Windowshot was created to address a specific issue: What if I don't want the whole screen, but just one window?
Grabber was created to address a different issue: What if I want just a specific section of the screen?

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #46 on: October 15, 2015, 10:48:21 PM »
Hi coreplayer2
I've added an option that lets you include the mouse cursor in the saved image by hitting  c  instead of  s.
I'll PM you a download link so you can try it out if you wish.
Quote
So it sounds like you want to use upper/lower case x, y, w, and h to better match the notation used in the coordinates
window, that's doable.
I have not implemented this yet. If you confirm this is what you had in mind, I'll make the change.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #47 on: October 16, 2015, 07:30:52 AM »
Hi coreplayer2
Forgot to mention, if you're running this under TC5 or TC6 you'll need  libXfixes.tcz, it's small, only 20K. If you're
running under TC4 it depends on  Xorg-7.6-lib.tcz  which is most likely installed since so many extensions depend
on it anyway. These dependencies should only effect capturing the cursor.

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 2070
Selecting an area of the screen for a screenshot using your mouse
« Reply #48 on: October 16, 2015, 09:00:16 AM »
Rich, that's cool and yes the keyboard quick keys in keeping with coordinates notation was exactly my concern.

Since you reminded us of the history and grabber's intended use, the lower and right window border anomaly is I think a moot point.. 

Thanks


Sent from my iPhone using Tapatalk
« Last Edit: October 16, 2015, 09:10:50 AM by coreplayer2 »

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #49 on: October 16, 2015, 09:47:59 AM »
Hi coreplayer2
Getting ready to head out to go sailing now. I'll make the keyboard mods later tonight.

Offline nitram

  • Hero Member
  • *****
  • Posts: 771
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #50 on: October 16, 2015, 05:09:09 PM »
If someone thinks it's worth putting into the repository, they're welcome to do so with my blessing....
Hi Rich.
In the process of preparing to submit as windowshot.tcz.
- Still need to test if it will work in Xvesa with xwininfo (xorg-7.7-bin.tcz) dependency, otherwise info file will indicate Xorg only
- Stll need a desktop icon, if you have preference send a link otherwise i'll find something online
- The script was modified to reflect changes required in the link you posted above
- It was also changed to output 'windowshot' and the windowshot .png file name will be same name/date format as grabber

Take a look at modified script, OK with you? Will clean up before submit.
Code: [Select]
#!/bin/sh
#
# Based heavily on Tinycores screenshot.sh, this script captures a
# single window rather than the entire screen. When run, the cursor
# changes to a crosshair. Click on a window to save a .png of it in
# your home directory. Richard Rost 3-19-2013

[ -z ${DISPLAY} ] && echo "Requires X" &&  exit 1
which xwininfo > /dev/null
[ "$?" -ne 0 ] && exec popup "Requires xwininfo, see Xorg-7.(5 or 6)-bin.tcz" &&  exit 1
WINDOW_ID=`xwininfo -frame | grep " Window id:" | cut -d " " -f 4`
#filename=screenshot_`date "+%m%d%H%M%S"`.png
filename=windowshot-`date "+%Y%b%d-%H%M%S"`.png
#sleep 1
#/bin/sh -c "/usr/bin/imlib2_grab -id $WINDOW_ID $HOME/$filename"
/bin/sh -c "imlib2_grab -id $WINDOW_ID $HOME/$filename"
#exec popup "Screenshot saved to $HOME/$filename"
exec popup "Windowshot saved to $HOME/$filename"

Noticed your grabber is a binary - i don't know how to create that and was just going to place the .sh script into /usr/local/bin - OK?

grabber.tcz includes custom grabber-license text, do you want to provide something similar for windowshot.tcz or just GPL?

You will obviously be documented as author in the info file, i'm just the maintainer.

Plan to submit for TC6 x86. Anything else let me know - thanks.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #51 on: October 16, 2015, 06:11:51 PM »
Hi nitram
Quote
- Still need to test if it will work in Xvesa with xwininfo (xorg-7.7-bin.tcz) dependency, otherwise info file will indicate Xorg only
Since the 7.5 and 7.6 versions of xwininfo work under Xvesa, I would expect the 7.7 version to work too, but
confirmation would be prudent.
Quote
- Stll need a desktop icon, if you have preference send a link otherwise i'll find something online
I'll leave the icon selection to you.
Quote
Take a look at modified script, OK with you? Will clean up before submit.
Minor change:
Code: [Select]
#[ "$?" -ne 0 ] && exec popup "Requires xwininfo, see Xorg-7.(5 or 6)-bin.tcz" &&  exit 1
[ "$?" -ne 0 ] && exec popup "Requires xwininfo, see Xorg-7.(5, 6, or 7)-bin.tcz" &&  exit 1
Quote
Noticed your grabber is a binary - i don't know how to create that and was just going to place the .sh script into /usr/local/bin - OK?
That's because grabber was written in C and is compiled. /usr/local/bin/windowshot.sh  is correct.
Quote
grabber.tcz includes custom grabber-license text, do you want to provide something similar for windowshot.tcz or just GPL?
Good question. The original script was part of the TC4 base installation and not signed by the author. I think just GPL
should be fine.
Quote
Plan to submit for TC6 x86. Anything else let me know - thanks.
You will need a  .dep  file containing:
Code: [Select]
imlib2-bin.tcz
Xorg-7.7-bin.tcz

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #52 on: October 16, 2015, 07:09:30 PM »
Hi coreplayer2
I just updated the keyboard functions and update the help window to match. You'll have a link to the updated tcz
PM'd to you in a few minutes.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #53 on: October 19, 2015, 09:24:33 PM »
Hi coreplayer2
Have you had a chance to try the last version I sent you to make sure I got it right?

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 2070
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #54 on: October 20, 2015, 05:05:10 AM »
yes thanks, the extension works great, is easy to use and intuitive.  good job thanks  :)

help menu is perfect also thanks

Thinking out loud here and I keep thinking..   Perhaps there is a simpler way to move the selection boundaries...  the arrow keys seem intuitive right?  there are four boundaries, all are independent and there are four arrow keys.    the shift key could can be used to determine an alternate direction of movement..  Anyhow that's most likely a lot of work and the app is great as is, just thinking....


Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #55 on: October 20, 2015, 08:18:50 PM »
Hi coreplayer2
Interesting idea, but a shifted arrow key returns the same keycode as an unshifted arrow.
Also found a subtle bug with the escape key. Running under TC4, xorg7.5, and flwm. Start grabber from the command
line, use escape to exit, then click the mouse. All mouse clicks will now be ignored. Hit Alt-Tab a couple of times, then
click the mouse, and proper operation of the mouse is restored. This does not occur under Xvesa. It also does not
appear to be a bug with grabber itself. I can reproduce the same behavior by hitting escape in a terminal that has
focus and then clicking the mouse. I'll have to remove the escape key function if I can't resolve this.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 9047
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #56 on: October 21, 2015, 01:17:16 AM »
Shift can be checked in the mask field (the ShiftMask bit is 0x1).
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #57 on: October 21, 2015, 05:23:19 AM »
Hi curaga
True, but this also affects the keypad arrows. Under Xorg, shifted arrows revert back to numbers when NumLock is
off and do the opposite when NumLock is on. I'd prefer not to add special levels of decoding for these corner cases.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #58 on: May 09, 2016, 12:42:41 PM »
Hi coreplayer2
Secondly,   this is more difficult to explain..     When you position the selection box exactly over the desired window border lets say over the outermost one pixel width of the widow border, the top & left selection components capture the one pixel beneath the selection bars.  Whereas the right & bottom (W & H) selection bars do not capture the one pixel of the window border directly beneath them, ie the saved window shot is missing the one pixel off the bottom and right sides.  Conversely you could say that the top and left portion of the saved window shot have gained the extra one pixel of the window border.

Honestly I don't know which is right, but I think the x/y and w/h selection co-ordinates should capture the same.  That is either the pixel inside the border or the pixel underneath, for all sides of the selection box.   I'm thinking if you draw a box around a window you should capture every pixel inside that selection., seems logical..?

sorry if that's clear as mud...
 8)

Having just dealt with that issue in another program I'm working on, I fixed grabber so the width and height readouts now
reflect the inside dimensions of the selection rectangle. Modified the info file to read:
Quote
      Move the mouse with the left button depressed to draw an outline around the
      section of the screen to save. Everything inside the outline will saved as
      a  .png  file. The outline will not be included in the saved file.

I also removed the Esc key to quit function since I wasn't able to resolve the problem in post #55.

grabber version 1.2 has been submitted and will probably be available in about a week.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5004
Re: Selecting an area of the screen for a screenshot using your mouse
« Reply #59 on: May 23, 2016, 06:53:04 AM »
The updated grabber.tcz version 1.2 is now available in the repository. Thank you to all that tried it and provided
feedback, especially nitram and coreplayer2 who assisted in bug fixes, testing, and improving the user interface.