-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit: add gem to github repo
- Loading branch information
0 parents
commit 814be2d
Showing
11 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
= deskshot CHANGELOG | ||
|
||
== v1.0.2 [24-Feb-2014] : | ||
|
||
* add default filename | ||
|
||
== v1.0.1 [12-Feb-2014] : | ||
|
||
* Minor bug fix | ||
|
||
== v1.0.0 [12-Feb-2014] : | ||
|
||
* Hide menu when click on 'Take Screenshot' | ||
* Save as Dialog for new screenshot | ||
* Suppress warning | ||
* Matured Product | ||
* Update README | ||
|
||
== v0.0.2 [10-Feb-2014] : | ||
|
||
* Fix icon issue | ||
* Fix rdoc issue | ||
* Change shortcut to 'CTRL + ALT + Q' to remove conflict in Linux | ||
|
||
== v0.0.1 [10-Feb-2014] : | ||
|
||
* Fix icon issue. Refactor code for ease. | ||
* Include RDoc,History,Manifest | ||
|
||
== v0.0.0 [7-Feb-2014] : | ||
|
||
* Born Deskshot. Happy Birthday Dear Deskshot! | ||
* Ignore console warning. Many more updates are coming soon :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Copyright (c) 2014 Parth Bharadiya | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CHANGELOG.rdoc | ||
LICENCE | ||
Manifest.txt | ||
README.rdoc | ||
lib/deskshot.rb | ||
lib/deskshot/deskshot_icon.png | ||
lib/deskshot/screenshot.rb | ||
lib/deskshot/tray.rb | ||
lib/deskshot/tray_app.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
= deskshot | ||
|
||
* Homepage: https://rubygems.org/gems/deskshot | ||
|
||
== DESCRIPTION: | ||
Deskshot allows you to take screenshot of your desktop. You can | ||
capture your favourite page by using opened window or by using | ||
System tray icon. Mainly It is designed for Windows users. | ||
but Yes, if your keyboard's 'Print Screen' key is not working | ||
in Linux then It is for you also! | ||
|
||
|
||
== FEATURES: | ||
|
||
* Cross-platform App(Windows/Linux)[Haven't tested in Mac] | ||
* Capture whole Screen | ||
* Keyboard Shortcut | ||
|
||
== REQUIREMENTS: | ||
|
||
* You have to install JRuby if you already do not have. http://jruby.org/download | ||
|
||
|
||
== INSTALL: | ||
|
||
=== Gem Package | ||
|
||
Install by running: | ||
|
||
gem install deskshot | ||
|
||
=== Alternate Gem download: | ||
|
||
* https://rubygems.org/gems/deskshot | ||
|
||
|
||
== GETTING STARTED: | ||
|
||
Step 1 : After installing gem, you can simply run following command in your Windows console/Linux Terminal to start Deskshot app | ||
|
||
irb -rdeskshot | ||
|
||
Step 2 : To take screenshot, Follow File > Take Screenshot or by right clicking System Tray Icon. | ||
Shortcut : Ctrl + Alt + Q (keep your deskshot app on top while using shortcut) | ||
|
||
== LICENSE: | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2014 Parth Bharadiya | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Gem::Specification.new do |s| | ||
s.name = 'deskshot' | ||
s.version = '1.0.2' | ||
s.date = '2014-02-24' | ||
s.summary = 'Desktop application for taking screenshot' | ||
s.description = 'Deskshot allows you to take screenshot of your desktop. It also has system tray application along with. It is implemented using JRuby.' | ||
s.author = 'Parth Bharadiya' | ||
s.email = 'parthbharadiya007@gmail.com' | ||
s.files = Dir.glob("lib/**/*") + %w(CHANGELOG.rdoc Manifest.txt README.rdoc) | ||
s.homepage = 'http://rubygems.org/gems/deskshot' | ||
s.license = 'MIT' | ||
s.require_paths = ["lib"] | ||
s.requirements << 'Working installation of JRuby' | ||
s.post_install_message = " ==================================================================================== \n | ||
Thanks for installing! Please go through Documentation provided in http://rubydoc.info/gems/deskshot \n | ||
== REQUIREMENTS: \n | ||
* You have to install JRuby if you already do not have. http://jruby.org/download \n | ||
== GETTING STARTED: \n | ||
Step 1 : After installing gem, you can simply run following command in your Windows console/Linux Terminal to start Deskshot app \n | ||
irb -rdeskshot \n | ||
Step 2 : To take screenshot, Follow File > Take Screenshot or by right clicking System Tray Icon. \n | ||
Shortcut : Ctrl + Alt + Q (keep your deskshot app on top while using shortcut) \n | ||
====================================================================================" | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'deskshot/tray_app' | ||
require 'deskshot/screenshot' | ||
|
||
include Java | ||
|
||
import java.awt.event.KeyEvent | ||
import java.awt.event.ActionEvent | ||
import javax.swing.JFrame | ||
import javax.swing.JMenuBar | ||
import javax.swing.JMenu | ||
import javax.swing.JMenuItem | ||
import javax.swing.KeyStroke | ||
import java.lang.System | ||
|
||
|
||
class DeskShot < JFrame | ||
def initialize | ||
super "Deskshot" | ||
self.initUI | ||
end | ||
|
||
def initUI | ||
menubar = JMenuBar.new | ||
|
||
fileMenu = JMenu.new "File" | ||
$VERBOSE = nil #to supress warning of setMnemonic | ||
fileMenu.setMnemonic KeyEvent::VK_F | ||
|
||
fileNew = JMenuItem.new "Take Screenshot!" | ||
fileNew.addActionListener do | ||
self.setVisible false | ||
Screenshot.capture | ||
self.setVisible true | ||
end | ||
fileNew.setAccelerator KeyStroke.getKeyStroke KeyEvent::VK_Q, 10 | ||
#10 is a combination of 8 + 2, 8 is ALT, 2 is CTRL | ||
|
||
fileExit = JMenuItem.new "Exit" | ||
fileExit.addActionListener { puts "Exit!"; System.exit 0 } | ||
fileExit.setAccelerator KeyStroke.getKeyStroke KeyEvent::VK_W, 2 | ||
|
||
fileMenu.add fileNew | ||
fileMenu.add fileExit | ||
|
||
menubar.add fileMenu | ||
|
||
self.setJMenuBar menubar | ||
|
||
self.setDefaultCloseOperation JFrame::EXIT_ON_CLOSE | ||
self.setSize 230, 110 | ||
self.setLocationRelativeTo nil | ||
self.setVisible true | ||
end | ||
end | ||
|
||
DeskShot.new |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class Screenshot | ||
include Java | ||
|
||
import java.awt.FileDialog #For File save as Dialog | ||
import java.awt.Robot | ||
import java.awt.Toolkit | ||
import java.awt.Rectangle | ||
import javax.imageio.ImageIO | ||
|
||
def self.capture | ||
begin | ||
output = FileDialog.new(nil, "Save as", FileDialog::SAVE) | ||
defaultfilename = Time.now.strftime("%F %H-%M-%S") | ||
output.setFile(defaultfilename + ".png") | ||
output.show | ||
filename = output.getDirectory + output.getFile | ||
#to avoide conflict of capturing own menu/window itself | ||
sleep 1 | ||
|
||
robot = Robot.new | ||
toolkit = Toolkit.get_default_toolkit | ||
dim = toolkit.get_screen_size | ||
rectangle = Rectangle.new(0, 0, dim.get_width, dim.get_height) | ||
image = robot.create_screen_capture(rectangle) | ||
file = java::io::File.new(filename) | ||
ImageIO::write(image, "png", file) | ||
rescue Exception | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class TrayApplication | ||
include Java | ||
|
||
import java.awt.TrayIcon | ||
import java.awt.Toolkit | ||
|
||
attr_accessor :menu_items | ||
|
||
def initialize(name) | ||
@menu_items = [] | ||
@name = name | ||
puts "Application is started successfully!! Right click on Tray Icon" | ||
end | ||
|
||
def item(label, &block) | ||
item = java.awt.MenuItem.new(label) | ||
item.add_action_listener(block) | ||
|
||
@menu_items << item | ||
end | ||
|
||
def run | ||
popup = java.awt.PopupMenu.new | ||
@menu_items.each { |i| popup.add(i)} | ||
abs_path = File.dirname(__FILE__) | ||
image = java.awt.Toolkit::default_toolkit.get_image(abs_path + '/deskshot_icon.png') | ||
tray_icon = TrayIcon.new(image, @name, popup) | ||
tray_icon.image_auto_size = true | ||
|
||
tray = java.awt.SystemTray::system_tray | ||
tray.add(tray_icon) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require_relative 'tray' | ||
require_relative 'screenshot' | ||
|
||
app = TrayApplication.new('Deskshot') | ||
app.item('Take Screenshot') { Screenshot.capture } | ||
app.item('Exit') {puts "Exit!"; java.lang.System::exit(0)} | ||
app.run |