[ 
http://jira.openqa.org/browse/WTR-258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Charley Baker updated WTR-258:
------------------------------

    Affects Version/s: 1.6.5
        Fix Version/s:     (was: Future)
                       Soon
          Component/s: Other
          Environment: win32

The screen capture code is pretty clunky and needs to be refactored or 
replaced. Likely option being Aslak, now Jarmo's, screenshot library: 
http://github.com/jarmo/win32screenshot

> New Screen Capture Code
> -----------------------
>
>                 Key: WTR-258
>                 URL: http://jira.openqa.org/browse/WTR-258
>             Project: Watir
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 1.6.5
>         Environment: win32
>            Reporter: Bret Pettichord
>            Priority: Major
>             Fix For: Soon
>
>
> From: Heesob Park <[email protected]>
> Date: Tue, Sep 30, 2008 at 12:43 AM
> Subject: Re: screen capture to display it or to save it to a file possible?
> To: ruby-talk ML <[email protected]>
> 2008/9/30 liketofindoutwhy <[email protected]>:
> > On Sep 28, 1:46 pm, Tim Hunter <[email protected]> wrote:
> >> liketofindoutwhy wrote:
> >> > On Sep 28, 11:29 am, liketofindoutwhy <[email protected]>
> >> > wrote:
> >> >> i would like do screencaptureand then to display it in that app's
> >> >> window, or be able to save the file in hard disk as a GIF or PNG. I
> >> >> wonder if TCL Ruby or RMagick can already do that? Thanks.
> >>
> >> > oh i actually mean  Ruby/Tk
> >>
> >> RMagick can do it on systems that have X Window. In other words, not MS
> >> Windows.http://studio.imagemagick.org/RMagick/doc/image1.html#capture.
> >
> > hm... so can you install x-window capabilities on XP or Vista... will
> > that work?  I think the Cygwin install x-window capabilities on
> > Windows.
> >
> >
> >
> There is screen_capture method in watir. But it is unstable.
> Here is the revised screen_capture method for Windows:
> require 'win32ole'
> require 'Win32API'
> def screen_capture(filename, active_window_only=false)
>        keybd_event = Win32API.new("user32", "keybd_event", ['I','I','L','L'], 
> 'V')
>        openClipboard = Win32API.new('user32', 'OpenClipboard', ['L'], 'I')
>        setClipboardData = Win32API.new('user32', 'SetClipboardData', ['I', 
> 'I'], 'I')
>        closeClipboard = Win32API.new('user32', 'CloseClipboard', [], 'I')
>        globalAlloc = Win32API.new('kernel32', 'GlobalAlloc', ['I', 'I'], 'I')
>        globalLock = Win32API.new('kernel32', 'GlobalLock', ['I'], 'I')
>        globalUnlock = Win32API.new('kernel32', 'GlobalUnlock', ['I'], 'I')
>        memcpy = Win32API.new('msvcrt', 'memcpy', ['I', 'P', 'I'], 'I')
>        wsh = WIN32OLE.new('Wscript.Shell')
>        if not active_window_only
>          keybd_event.Call(0x2C,0,0,0)   # Print Screen
>        else
>          keybd_event.Call(0x2C,1,0,0)   # Alt+Print Screen
>        end
>        exec = wsh.Exec('mspaint.exe')
>        wsh.AppActivate(exec.ProcessID)
>        sleep(1)
>        # Ctrl + V  : Paste
>        wsh.SendKeys("^v")
>        sleep(1)
>        # Alt F + A : Save As
>        wsh.SendKeys("%fa")
>        # copy filename to clipboard
>        hmem = globalAlloc.Call(0x0002, filename.length+1)
>        mem = globalLock.Call(hmem)
>        memcpy.Call(mem, filename, filename.length+1)
>        globalUnlock.Call(hmem)
>        openClipboard.Call(0)
>        setClipboardData.Call(1, hmem)
>        closeClipboard.Call
>        sleep(1)
>        # Ctrl + V  : Paste
>        wsh.SendKeys("^v")
>        if filename[/\.gif/i]
>                wsh.SendKeys("{TAB}g")
>        elsif filename[/\.jpg/i]
>                wsh.SendKeys("{TAB}j")
>        end
>        wsh.SendKeys("~")  # enter
>        sleep(1)
>        wsh.SendKeys("yy")
>        sleep(4)
>        exec.Terminate
> end
> screen_capture("c:\\test.gif")
> Regards,
> Park Heesob

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.openqa.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development

Reply via email to