Is there anything in the utils to capture a screen ( or maybe just a window) and save to a file. I have this, but I have no idea where it came from, but it gives a corrupted image Paul # -*- ruby -*- # screen capture -- # This script runs with a Ruby/DL which is included in ruby-1.7. require ''dl/import'' module ScreenCapture extend DL::Importable dlload "kernel32.dll","user32.dll","gdi32.dll" HORZRES = 8 VERTRES = 10 SRCCOPY = 0xCC0020 GMEM_FIXED = 0 GMEM_MOVEABLE = 0x0002 DIB_RGB_COLORS = 0 GHND = 0x40 GPTR = 0x42 typealias "HDC","unsigned long" typealias "HBITMAP","unsigned long" extern "HDC GetWindowDC(int)" extern "HDC CreateCompatibleDC(HDC)" extern "int GetDeviceCaps(HDC, int)" extern "HBITMAP CreateCompatibleBitmap(HDC, int, int)" extern "long SelectObject(HDC, HBITMAP)" extern "long BitBlt(HDC, long, long, long, long, HDC, long, long, long)" extern "void* GlobalAlloc(long, long)" extern "void* GlobalLock(void*)" extern "long GetDIBits(HDC, HBITMAP, long, long, void*, void*, long)" extern "long GlobalUnlock(void*)" extern "long GlobalFree(void*)" extern "long DeleteObject(unsigned long)" extern "long DeleteDC(HDC)" extern "long ReleaseDC(long, HDC)" module_function def screenCapture(filename = "tmp.bmp") hScreenDC = getWindowDC(0) hmemDC = createCompatibleDC(hScreenDC) screenWidth = getDeviceCaps(hScreenDC, HORZRES) screenHeight = getDeviceCaps(hScreenDC, VERTRES) hmemBM = createCompatibleBitmap(hScreenDC, screenWidth, screenHeight) selectObject(hmemDC, hmemBM) printf("width,height = #{screenWidth},#{screenHeight}\n") r = bitBlt(hmemDC, 0, 0, screenWidth, screenHeight, hScreenDC, 0, 0, SRCCOPY) printf("bitBlt : #{r}\n") hpxldata = globalAlloc(GMEM_FIXED, screenWidth * screenHeight * 3) lpvpxldata = globalLock(hpxldata) bmInfo = [ 40, screenWidth, screenHeight, 1, 24, 0, 0, 0, 0, 0, 0, 0].pack(''LLLSSLLLLLL'').to_ptr bmFileHeader = [ 19778, (screenWidth * screenHeight * 3) + 40 + 14, 0, 0, 54].pack(''ILIIL'').to_ptr r = getDIBits(hmemDC, hmemBM, 0, screenHeight, lpvpxldata, bmInfo, DIB_RGB_COLORS) printf("getDIBits : #{r}\n") File::open(filename, "w") { |bitmap| bitmap.print(bmFileHeader.to_s(14)) bitmap.print(bmInfo.to_s(40)) bitmap.print(lpvpxldata.to_s(screenWidth * screenHeight * 3)) } globalUnlock(hpxldata) globalFree(hpxldata) deleteObject(hmemBM) deleteDC(hmemDC) releaseDC(0, hScreenDC) end end ScreenCapture::screenCapture()
Hi, ----- Original Message ----- From: "Paul Rogers" <paul.rogers@shaw.ca> To: <win32utils-devel@rubyforge.org> Sent: Friday, April 22, 2005 5:28 AM Subject: [Win32utils-devel] Screen capture, save to file> > > Is there anything in the utils to capture a screen ( or maybe just a > window) and save to a file. > > I have this, but I have no idea where it came from, but it gives a > corrupted image > > Paul >I have made another simple and annoying solution using Print Screen,Clipboard and MSPaint.exe. Regards, Park Heesob ================================================require ''Win32API'' KEYEVENTF_KEYUP = 0x2 SW_HIDE = 0 SW_SHOW = 5 SW_SHOWNORMAL = 1 VK_CONTROL = 0x11 VK_F4 = 0x73 VK_MENU = 0x12 VK_RETURN = 0x0D VK_SHIFT = 0x10 VK_SNAPSHOT = 0x2C VK_TAB = 0x09 def screenCapture(filename = "tmp.bmp") keybd_event = Win32API.new("user32", "keybd_event", [''I'',''I'',''L'',''L''], ''V'') vkKeyScan = Win32API.new("user32", "VkKeyScan", [''I''], ''I'') winExec = Win32API.new("kernel32", "WinExec", [''P'',''L''], ''L'') filename = Dir.getwd.tr(''/'',''\\'') + ''\\'' + filename unless filename.index(''\\'') keybd_event.Call(VK_SNAPSHOT,0,0,0) # Print Screen # keybd_event.Call(VK_SNAPSHOT,1,0,0) # Alt+Print Screen winExec.Call(''mspaint.exe'', SW_SHOW) sleep(1) # Ctrl + V : Paste keybd_event.Call(VK_CONTROL, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0) # Alt E + O : Save Selected Image keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Enter filename filename.each_byte { |ch| keybd_event.Call(VK_SHIFT, 1, 0, 0) if ch==?: keybd_event.Call(vkKeyScan.Call(ch), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(ch), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_SHIFT, 1, KEYEVENTF_KEYUP, 0) if ch==?: } keybd_event.Call(VK_RETURN, 1, 0, 0) keybd_event.Call(VK_RETURN, 1, KEYEVENTF_KEYUP, 0) sleep(1) # Y keybd_event.Call(vkKeyScan.Call(?Y), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?Y), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Alt + F4 : Exit keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(VK_F4, 1, 0, 0) keybd_event.Call(VK_F4, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) sleep(1) # N keybd_event.Call(vkKeyScan.Call(?N), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?N), 1, KEYEVENTF_KEYUP, 0) end screenCapture
Thanks! I''ll settle for simple and annoying for now! Paul -----Original Message----- From: win32utils-devel-bounces@rubyforge.org [mailto:win32utils-devel-bounces@rubyforge.org] On Behalf Of Park Heesob Sent: 23 April 2005 17:20 To: Development and ideas for win32utils projects Subject: Re: [Win32utils-devel] Screen capture, save to file Hi, ----- Original Message ----- From: "Paul Rogers" <paul.rogers@shaw.ca> To: <win32utils-devel@rubyforge.org> Sent: Friday, April 22, 2005 5:28 AM Subject: [Win32utils-devel] Screen capture, save to file> > > Is there anything in the utils to capture a screen ( or maybe just a > window) and save to a file. > > I have this, but I have no idea where it came from, but it gives a > corrupted image > > Paul >I have made another simple and annoying solution using Print Screen,Clipboard and MSPaint.exe. Regards, Park Heesob ================================================require ''Win32API'' KEYEVENTF_KEYUP = 0x2 SW_HIDE = 0 SW_SHOW = 5 SW_SHOWNORMAL = 1 VK_CONTROL = 0x11 VK_F4 = 0x73 VK_MENU = 0x12 VK_RETURN = 0x0D VK_SHIFT = 0x10 VK_SNAPSHOT = 0x2C VK_TAB = 0x09 def screenCapture(filename = "tmp.bmp") keybd_event = Win32API.new("user32", "keybd_event", [''I'',''I'',''L'',''L''], ''V'') vkKeyScan = Win32API.new("user32", "VkKeyScan", [''I''], ''I'') winExec = Win32API.new("kernel32", "WinExec", [''P'',''L''], ''L'') filename = Dir.getwd.tr(''/'',''\\'') + ''\\'' + filename unless filename.index(''\\'') keybd_event.Call(VK_SNAPSHOT,0,0,0) # Print Screen # keybd_event.Call(VK_SNAPSHOT,1,0,0) # Alt+Print Screen winExec.Call(''mspaint.exe'', SW_SHOW) sleep(1) # Ctrl + V : Paste keybd_event.Call(VK_CONTROL, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0) # Alt E + O : Save Selected Image keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Enter filename filename.each_byte { |ch| keybd_event.Call(VK_SHIFT, 1, 0, 0) if ch==?: keybd_event.Call(vkKeyScan.Call(ch), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(ch), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_SHIFT, 1, KEYEVENTF_KEYUP, 0) if ch==?: } keybd_event.Call(VK_RETURN, 1, 0, 0) keybd_event.Call(VK_RETURN, 1, KEYEVENTF_KEYUP, 0) sleep(1) # Y keybd_event.Call(vkKeyScan.Call(?Y), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?Y), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Alt + F4 : Exit keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(VK_F4, 1, 0, 0) keybd_event.Call(VK_F4, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) sleep(1) # N keybd_event.Call(vkKeyScan.Call(?N), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?N), 1, KEYEVENTF_KEYUP, 0) end screenCapture _______________________________________________ win32utils-devel mailing list win32utils-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/win32utils-devel
I havent had a chance to try this so far, but Im sure it will be fine. The reason I wanted this is that Im a developer on Watir ( http://wtr.rubyforge.org/ ) and several people have asked for the ability to capture screen shots when running tests. So my question is this - Is it ok for us to redistribute this code with Watir? I will obviously credit you with writing it. Thanks Paul -----Original Message----- From: win32utils-devel-bounces@rubyforge.org [mailto:win32utils-devel-bounces@rubyforge.org] On Behalf Of Park Heesob Sent: 23 April 2005 17:20 To: Development and ideas for win32utils projects Subject: Re: [Win32utils-devel] Screen capture, save to file Hi, ----- Original Message ----- From: "Paul Rogers" <paul.rogers@shaw.ca> To: <win32utils-devel@rubyforge.org> Sent: Friday, April 22, 2005 5:28 AM Subject: [Win32utils-devel] Screen capture, save to file> > > Is there anything in the utils to capture a screen ( or maybe just a > window) and save to a file. > > I have this, but I have no idea where it came from, but it gives a > corrupted image > > Paul >I have made another simple and annoying solution using Print Screen,Clipboard and MSPaint.exe. Regards, Park Heesob ================================================require ''Win32API'' KEYEVENTF_KEYUP = 0x2 SW_HIDE = 0 SW_SHOW = 5 SW_SHOWNORMAL = 1 VK_CONTROL = 0x11 VK_F4 = 0x73 VK_MENU = 0x12 VK_RETURN = 0x0D VK_SHIFT = 0x10 VK_SNAPSHOT = 0x2C VK_TAB = 0x09 def screenCapture(filename = "tmp.bmp") keybd_event = Win32API.new("user32", "keybd_event", [''I'',''I'',''L'',''L''], ''V'') vkKeyScan = Win32API.new("user32", "VkKeyScan", [''I''], ''I'') winExec = Win32API.new("kernel32", "WinExec", [''P'',''L''], ''L'') filename = Dir.getwd.tr(''/'',''\\'') + ''\\'' + filename unless filename.index(''\\'') keybd_event.Call(VK_SNAPSHOT,0,0,0) # Print Screen # keybd_event.Call(VK_SNAPSHOT,1,0,0) # Alt+Print Screen winExec.Call(''mspaint.exe'', SW_SHOW) sleep(1) # Ctrl + V : Paste keybd_event.Call(VK_CONTROL, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0) # Alt E + O : Save Selected Image keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Enter filename filename.each_byte { |ch| keybd_event.Call(VK_SHIFT, 1, 0, 0) if ch==?: keybd_event.Call(vkKeyScan.Call(ch), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(ch), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_SHIFT, 1, KEYEVENTF_KEYUP, 0) if ch==?: } keybd_event.Call(VK_RETURN, 1, 0, 0) keybd_event.Call(VK_RETURN, 1, KEYEVENTF_KEYUP, 0) sleep(1) # Y keybd_event.Call(vkKeyScan.Call(?Y), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?Y), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Alt + F4 : Exit keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(VK_F4, 1, 0, 0) keybd_event.Call(VK_F4, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) sleep(1) # N keybd_event.Call(vkKeyScan.Call(?N), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?N), 1, KEYEVENTF_KEYUP, 0) end screenCapture _______________________________________________ win32utils-devel mailing list win32utils-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/win32utils-devel
Ok, Ive just tried it, and there is a weird bug I don''t understand. In the Save as dialog, a _ gets changed to a - c:\watir_bonus>screen_capture.rb file to use is: c:\watir_bonus\tmp.bmp after E O sending c 99 SHIFT sending : 58 sending \ 92 sending w 119 sending a 97 sending t 116 sending i 105 sending r 114 sending _ 95 <-- correct char is sent sending b 98 sending o 111 sending n 110 sending u 117 sending s 115 sending \ 92 sending t 116 sending m 109 sending p 112 sending . 46 sending b 98 sending m 109 sending p 112 after filename c:\watir_bonus>irb irb(main):001:0> "_".asc NoMethodError: undefined method `asc'' for "_":String from (irb):1 irb(main):002:0> 95.chr => "_" irb(main):003:0> "-"[0] => 45 irb(main):004:0> 45.chr => "-" irb(main):005:0> But it shows up in the save as dialog as - Thanks Paul -----Original Message----- From: win32utils-devel-bounces@rubyforge.org [mailto:win32utils-devel-bounces@rubyforge.org] On Behalf Of Paul Rogers Sent: 26 April 2005 13:03 To: ''Development and ideas for win32utils projects'' Subject: RE: [Win32utils-devel] Screen capture, save to file I havent had a chance to try this so far, but Im sure it will be fine. The reason I wanted this is that Im a developer on Watir ( http://wtr.rubyforge.org/ ) and several people have asked for the ability to capture screen shots when running tests. So my question is this - Is it ok for us to redistribute this code with Watir? I will obviously credit you with writing it. Thanks Paul -----Original Message----- From: win32utils-devel-bounces@rubyforge.org [mailto:win32utils-devel-bounces@rubyforge.org] On Behalf Of Park Heesob Sent: 23 April 2005 17:20 To: Development and ideas for win32utils projects Subject: Re: [Win32utils-devel] Screen capture, save to file Hi, ----- Original Message ----- From: "Paul Rogers" <paul.rogers@shaw.ca> To: <win32utils-devel@rubyforge.org> Sent: Friday, April 22, 2005 5:28 AM Subject: [Win32utils-devel] Screen capture, save to file> > > Is there anything in the utils to capture a screen ( or maybe just a > window) and save to a file. > > I have this, but I have no idea where it came from, but it gives a > corrupted image > > Paul >I have made another simple and annoying solution using Print Screen,Clipboard and MSPaint.exe. Regards, Park Heesob ================================================require ''Win32API'' KEYEVENTF_KEYUP = 0x2 SW_HIDE = 0 SW_SHOW = 5 SW_SHOWNORMAL = 1 VK_CONTROL = 0x11 VK_F4 = 0x73 VK_MENU = 0x12 VK_RETURN = 0x0D VK_SHIFT = 0x10 VK_SNAPSHOT = 0x2C VK_TAB = 0x09 def screenCapture(filename = "tmp.bmp") keybd_event = Win32API.new("user32", "keybd_event", [''I'',''I'',''L'',''L''], ''V'') vkKeyScan = Win32API.new("user32", "VkKeyScan", [''I''], ''I'') winExec = Win32API.new("kernel32", "WinExec", [''P'',''L''], ''L'') filename = Dir.getwd.tr(''/'',''\\'') + ''\\'' + filename unless filename.index(''\\'') keybd_event.Call(VK_SNAPSHOT,0,0,0) # Print Screen # keybd_event.Call(VK_SNAPSHOT,1,0,0) # Alt+Print Screen winExec.Call(''mspaint.exe'', SW_SHOW) sleep(1) # Ctrl + V : Paste keybd_event.Call(VK_CONTROL, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0) # Alt E + O : Save Selected Image keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Enter filename filename.each_byte { |ch| keybd_event.Call(VK_SHIFT, 1, 0, 0) if ch==?: keybd_event.Call(vkKeyScan.Call(ch), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(ch), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_SHIFT, 1, KEYEVENTF_KEYUP, 0) if ch==?: } keybd_event.Call(VK_RETURN, 1, 0, 0) keybd_event.Call(VK_RETURN, 1, KEYEVENTF_KEYUP, 0) sleep(1) # Y keybd_event.Call(vkKeyScan.Call(?Y), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?Y), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Alt + F4 : Exit keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(VK_F4, 1, 0, 0) keybd_event.Call(VK_F4, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) sleep(1) # N keybd_event.Call(vkKeyScan.Call(?N), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?N), 1, KEYEVENTF_KEYUP, 0) end screenCapture _______________________________________________ win32utils-devel mailing list win32utils-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/win32utils-devel _______________________________________________ win32utils-devel mailing list win32utils-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/win32utils-devel
Paul Rogers wrote:>Ok, Ive just tried it, and there is a weird bug I don''t understand. >In the Save as dialog, a _ gets changed to a - >Is it because ''_'' (underscore) requires pressing of the Shift key without which it is simply ''-'' (hyphen)? Just a guess ... don''t know if the code handles Shift, Ctrl and Alt key presses. -- shanko
Hi Paul, Shashank Date wrote:> Is it because ''_'' (underscore) requires pressing of the Shift key > without which it is simply ''-'' (hyphen)?I guessed it right. This worked for me: ## Screen Capture program By Park Heesob ## require ''Win32API'' KEYEVENTF_KEYUP = 0x2 SW_HIDE = 0 SW_SHOW = 5 SW_SHOWNORMAL = 1 VK_CONTROL = 0x11 VK_F4 = 0x73 VK_MENU = 0x12 VK_RETURN = 0x0D VK_SHIFT = 0x10 VK_SNAPSHOT = 0x2C VK_TAB = 0x09 def screenCapture(filename = "C:\\watir_bonus\\tmp.bmp") keybd_event = Win32API.new("user32", "keybd_event", [''I'',''I'',''L'',''L''], ''V'') vkKeyScan = Win32API.new("user32", "VkKeyScan", [''I''], ''I'') winExec = Win32API.new("kernel32", "WinExec", [''P'',''L''], ''L'') filename = Dir.getwd.tr(''/'',''\\'') + ''\\'' + filename unless filename.index(''\\'') keybd_event.Call(VK_SNAPSHOT,0,0,0) # Print Screen # keybd_event.Call(VK_SNAPSHOT,1,0,0) # Alt+Print Screen winExec.Call(''mspaint.exe'', SW_SHOW) sleep(1) # Ctrl + V : Paste keybd_event.Call(VK_CONTROL, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0) # Alt E + O : Save Selected Image keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?E), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?O), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Enter filename filename.each_byte { |ch| keybd_event.Call(VK_SHIFT, 1, 0, 0) if [?:,?_,?$].include?(ch) keybd_event.Call(vkKeyScan.Call(ch), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(ch), 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_SHIFT, 1, KEYEVENTF_KEYUP, 0) if [?:,?_,?$].include?(ch) sleep(1) } keybd_event.Call(VK_RETURN, 1, 0, 0) keybd_event.Call(VK_RETURN, 1, KEYEVENTF_KEYUP, 0) sleep(1) # Y keybd_event.Call(vkKeyScan.Call(?Y), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?Y), 1, KEYEVENTF_KEYUP, 0) sleep(1) # Alt + F4 : Exit keybd_event.Call(VK_MENU, 1, 0, 0) keybd_event.Call(VK_F4, 1, 0, 0) keybd_event.Call(VK_F4, 1, KEYEVENTF_KEYUP, 0) keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0) sleep(3) # N keybd_event.Call(vkKeyScan.Call(?N), 1, 0, 0) keybd_event.Call(vkKeyScan.Call(?N), 1, KEYEVENTF_KEYUP, 0) end screenCapture
Hi Shanko, I reassigned feature request #872 to you. :) (Port of Win32::Screenshot) Unless you object, that is. By all means, feel free to use Win32API rather than C code (which is what the Perl module uses). That is, unless you don''t want this assignment. :) Regards, Dan
Hi Dan, Berger, Daniel wrote:>I reassigned feature request #872 to you. :) > >(Port of Win32::Screenshot) > >Great !!>Unless you object, that is. By all means, feel free to use Win32API >rather than C code (which is what the Perl module uses). > >Win32API will be easier for me to tackle so I will work in it first. But then I also want to get my hands dirty in Ruby-C and with your (and Park''s) help learn a thing or two. So I will end up doing that too.>That is, unless you don''t want this assignment. :) > >I will love to do this unless there some urgency ... you may want to ask the requestor how long he/she is willing to wait. It could be a while (a couple of months) before I get around to it. Many high-pri things pending.>Regards, > >Dan > >Thanks, -- shanko
As soon as possible is always the answer ;-) No, whenever is fine. The code that Park Heesob and yourself posted will be fine for a while. As soon as there is on ethat doesn''t need paint, we''ll switch Thanks for even looking into it! Paul -----Original Message----- From: win32utils-devel-bounces@rubyforge.org [mailto:win32utils-devel-bounces@rubyforge.org] On Behalf Of Shashank Date Sent: 27 April 2005 21:23 To: Development and ideas for win32utils projects Subject: Re: [Win32utils-devel] Screen capture, save to file Hi Dan, Berger, Daniel wrote:>I reassigned feature request #872 to you. :) > >(Port of Win32::Screenshot) > >Great !!>Unless you object, that is. By all means, feel free to use Win32API >rather than C code (which is what the Perl module uses). > >Win32API will be easier for me to tackle so I will work in it first. But then I also want to get my hands dirty in Ruby-C and with your (and Park''s) help learn a thing or two. So I will end up doing that too.>That is, unless you don''t want this assignment. :) > >I will love to do this unless there some urgency ... you may want to ask the requestor how long he/she is willing to wait. It could be a while (a couple of months) before I get around to it. Many high-pri things pending.>Regards, > >Dan > >Thanks, -- shanko _______________________________________________ win32utils-devel mailing list win32utils-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/win32utils-devel