Jump to content

Retrieval from Clipboard Problem


ohpsn
 Share

Recommended Posts

Hi,

I run into problem trying to retrieve an 8 or 9 digit number from clipboard.

I am using the function _ClipBoard_GetData(1) to retrieve the number. It was running fine with number less than 8 digits.

Any suggestions on how I could get around this problem? Thanks.

Regards,

ohpsn

Link to comment
Share on other sites

What are you trying to do? Are you trying to set _clipboard_getdata as a variable?

If so, you can use this.

#include <clipboard.au3>

$whatever = _ClipBoard_GetData ()

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

What are you trying to do? Are you trying to set _clipboard_getdata as a variable?

If so, you can use this.

#include <clipboard.au3>

$whatever = _ClipBoard_GetData ()
Hi Pigeek,

I was trying to grab an 8 or 9 digit number from outlook or instant message to build an url where the number is a part of it.

If you cut and paste an 8 digit number and run the script, it will yield the error in the attachment.

post-45298-1232677917_thumb.jpg

Link to comment
Share on other sites

Hi,

I run into problem trying to retrieve an 8 or 9 digit number from clipboard.

I am using the function _ClipBoard_GetData(1) to retrieve the number. It was running fine with number less than 8 digits.

Any suggestions on how I could get around this problem? Thanks.

Regards,

ohpsn

Having never used any of the _ClipBoard_GetData() functions, I see your problem.

I experimented with the Help file example. Commenting out, ( ; ), different lines to see what worked and didn't work.

It appears _ClipBoard_Open() is necessary. And works with an external application window handle.

I have always used ClipPut() and ClipGet() for clipboard use.

I've learnt something from your question.

CODE
#include <GuiConstantsEx.au3>

#include <ClipBoard.au3>

#include <WindowsConstants.au3>

Local $hGUI, $Val, $hMemory, $tData, $hHwnd

Run("Notepad.exe")

WinActivate("Untitled - Notepad")

$hHwnd = WinGetHandle("Untitled - Notepad")

;OR

; Create GUI

;$hGUI = GUICreate("Clipboard", 600, 450)

;GUISetState()

$Val = 123456789

_ClipBoard_SetData($Val)

;_ClipBoard_Open($hGUI)

_ClipBoard_Open($hHwnd)

$hMemory = _ClipBoard_GetDataEx($CF_TEXT)

_ClipBoard_Close()

$tData = DllStructCreate("char Text[8192]", $hMemory)

MsgBox(0, "_ClipBoard_GetDataEx", DllStructGetData($tData, "Text") & @CRLF & _

"IsNumber " & IsNumber(DllStructGetData($tData, "Text")) & @CRLF & _

"IsString " & IsString(DllStructGetData($tData, "Text")), 0, $hHwnd)

;====== Second example ================

ClipPut($Val)

MsgBox(0, "ClipPut() ClipGet()", ClipGet() & @CRLF & _

"IsNumber " & IsNumber(ClipGet()) & @CRLF & _

"IsString " & IsString(ClipGet()), 0, $hHwnd)

Link to comment
Share on other sites

  • 3 weeks later...

I too had AutoIt crash when trying to use _ClipBoard_GetData(). After investigation what I discovered was that according to MSDN the handle returned by GetClipboardData should not be used after the CloseClipboard is used. This means the _ClipBoard_Close() should be moved just before the return in each case. But the else case returns the handle, which is effectively useless.

Also, how does the unicode part work. It converts $tData but $tData is never set?

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...