Jump to content

Copy from Clipboard and Place in GUI


4Bidden
 Share

Recommended Posts

Hi everybody

This is my first foray into scripting issues.

Issue:

I want copy from clipboard and place it in my GUI Application Form,

My script will be continuously copying and pasting into the clipboard, so I wanna continuously be feeding the last

copied Clipboard image into my Application form

Any Ideas on how to do this, I would be grateful for any help or direction on how to do this..

Thanks

Edited by 4Bidden
Link to comment
Share on other sites

Put "_Clip" into the helpfile index tab to bring up the _ClipBoard_ functions, read about them, study and test the examples provided.

I have done the above stuff all I can do is put text into a Msgbox, I wanna work with Images ......

Any Ideas Plz Help

Link to comment
Share on other sites

Then you also want to study:

_ScreenCapture_Capture

hey thanks for this.. This looks like this could work....

Issue is how will image show up on the GUI Im building or a Msgbox, Only text seems to show

up on the Msgbox

Any help would be greatly appreciated

Link to comment
Share on other sites

Here one method:

;coded by UEZ 2011
#include <Clipboard.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$msgb = MsgBox(4, "Clipboard to GUI", "Ready to copy an image from clipboard to GUI?")
If $msgb <> 6 Then Exit

If Not _ClipBoard_Open(0) Then Exit _WinAPI_ShowError ("_ClipBoard_Open failed")
$hMemory = _ClipBoard_GetDataEx($CF_BITMAP)
If $hMemory  = 0 Then Exit _WinAPI_ShowError ("_ClipBoard_GetDataEx failed")

_GDIPlus_Startup()
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hMemory)
If $hBitmap  = 0 Then Exit _WinAPI_ShowError ("_GDIPlus_BitmapCreateFromHBITMAP failed")

$iWidth = _GDIPlus_ImageGetWidth($hBitmap)
$iHeight = _GDIPlus_ImageGetHeight($hBitmap)


$hGUI = GUICreate("Show Image from Clipboard", $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW, $hGUI)

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _ClipBoard_Close()
            _GDIPlus_BitmapDispose($hBitmap)
            _GDIPlus_GraphicsDispose($hGraphic)
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            ExitLoop
    EndSwitch
WEnd

Copy an image to the clipboard and start script.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Here one method:

;coded by UEZ 2011
#include <Clipboard.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$msgb = MsgBox(4, "Clipboard to GUI", "Ready to copy an image from clipboard to GUI?")
If $msgb <> 6 Then Exit

If Not _ClipBoard_Open(0) Then Exit _WinAPI_ShowError ("_ClipBoard_Open failed")
$hMemory = _ClipBoard_GetDataEx($CF_BITMAP)
If $hMemory  = 0 Then Exit _WinAPI_ShowError ("_ClipBoard_GetDataEx failed")

_GDIPlus_Startup()
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hMemory)
If $hBitmap  = 0 Then Exit _WinAPI_ShowError ("_GDIPlus_BitmapCreateFromHBITMAP failed")

$iWidth = _GDIPlus_ImageGetWidth($hBitmap)
$iHeight = _GDIPlus_ImageGetHeight($hBitmap)


$hGUI = GUICreate("Show Image from Clipboard", $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW, $hGUI)

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _ClipBoard_Close()
            _GDIPlus_BitmapDispose($hBitmap)
            _GDIPlus_GraphicsDispose($hGraphic)
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            ExitLoop
    EndSwitch
WEnd

Copy an image to the clipboard and start script.

Br,

UEZ

YOU THE MAN !!!!!!!!!!!!!!

Thanks a lot just curious how long have you been working with Auto-it

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...