Sign in to follow this  
Followers 0
ohpsn

Retrieval from Clipboard Problem

6 posts in this topic

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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Thanks for pointing out the easy way of clipboard use. The use of function clipget() solves my problem. Thanks again.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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
Sign in to follow this  
Followers 0