cookiemonster

Test ClipPut for failure on purpose

3 posts in this topic

Hi,

So im using ClipPut ( "value" )  to copy a value to my clipboard.

It works all the time at the moment, and i have in if statement to show one message box if successful, and another if it fails.

Has anyone got any suggestions on how to make it fail on purpose, eg: lock windows clipboard so it fails.

Just want to confirm the action when it actually fails not that it ever should.

Share this post


Link to post
Share on other sites



Check the return value.

 

Share this post


Link to post
Share on other sites

Im doing that and its always successful, what im wanting is a way of forcing it to fail, eg: locking windows clipboard so script fails to clipput

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

  • Similar Content

    • piterek
      By piterek
      Hi...
      How to put data to clipboard in all available formats?   I use _ClipBoard_GetData to save all formats data to files but when I try to put them again to clipboard using _ClipBoard_SetData, I have available  only the last data format which I used. After that when I try put this data to "Microsoft Word" I get only "Cleaned" text format.  When I the set last format as a HTML and I put to "Micorosft Word" everything fine, but I can't put to Notepad (I get empty value).    When I doing this same with _ClipBoard_GetDataEx to save data to memory object (not to file) and put them again using _ClipBoard_SetDataEx all data formats are available...   Help?   
    • nf67
      By nf67
      Hi all,

      I've been copying a lot of text from PDF files and other documents. Problem is, this text appears badly mangled when pasted again, causing formatting issues. I've been trying to write a script that would automatically reformat the copied string:


      #include <Clipboard.au3> #include <Misc.au3> If _Singleton("PasteModify", 1) = 0 Then MsgBox(0, "NOPE.", "Already Running.") Exit EndIf #NoTrayIcon Opt("TrayMenuMode", 1) $AboutTrayItem = TrayCreateItem("About") TrayCreateItem("") $ExitTrayItem = TrayCreateItem("Exit") TraySetState() $hDLL = DllOpen("user32.dll") Beep(1100,300) While 1 While _IsPressed("11",$hDLL) If _IsPressed("43",$hDLL) Then Beep(1300,150) ;Sleep(750) ;fixes the issue, but not very elegantly. $OriginalClipboardData = ClipGet() $ClipGetError = @error $RegexClipboardData = StringRegExpReplace($OriginalClipboardData, '[\r\n\t]+', ' ') $StripWSClipboardData = StringStripWS($RegexClipboardData,4) ClipPut($StripWSClipboardData) MsgBox(0,$ClipGetError,"ORIGINAL: " & $OriginalClipboardData & @CRLF & @CRLF & "POST-REGEX APPLIED: " & StringRegExpReplace($OriginalClipboardData, '[\r\n\t]+', ' ') & @CRLF & @CRLF & "STRIPWS APPLIED: " & $StripWSClipboardData & @CRLF & @CRLF & "END RESULT: " & ClipGet()) While _IsPressed("43",$hDLL) Sleep(250) WEnd EndIf WEnd Local $msg = TrayGetMsg() Select Case $msg = $AboutTrayItem MsgBox(64, "About", "When CTRL+C is pressed, a reformatted version of the string that has thereby been copied, without any newline characters, should be placed on the clipboard.") Case $msg = $ExitTrayItem ExitLoop EndSelect WEnd DllClose($hDLL) Beep(600,300)
      However, every now and then it seems like there's a conflict between this script Windows' access to the clipboard.

      If I don't include a long enough sleep (see script), ClipGet() will return that my clipboard is empty, even though it wasn't empty before and I have only selected new text and pressed Ctrl+C since.

      Any suggestions? Could I check for clipboard access perhaps...?