Jump to content

ClipPut() ... how can this be happening?


qwert
 Share

Recommended Posts

I've had an odd case crop up when using ClipPut(). 

I have the function assigned to a button operation ... and with a couple of double clicks on the button, the button's label is placed in the field!!  How can this happen?

Here's a simple test script that I'm running with AutoIt v3.3.12.0 on Win7 Pro:

;
;       ClipPut Test ... with rapid doubleclick, picks up the text off of the button!!!
;
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

$GUI = GUICreate("ClipPut Test", 320, 100)
GUISetFont(12)
$iWord = GUICtrlCreateEdit("Test", 22, 24, 217, 24, 0)

$GetText = GUICtrlCreateLabel("Get", 260, 14, 30, 24, $SS_CENTER)
GUICtrlSetTip(-1, "Button to grab contents")

$PutText = GUICtrlCreateLabel("Put", 260, 40, 30, 24, $SS_CENTER)
GUICtrlSetTip(-1, "Button to replace contents")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GetText
            ClipPut(GUICtrlRead($iWord))    ; get, then flash the field
            GUICtrlSetBkColor($iWord, 0xAAFFFF)
            Sleep(200)
            GUICtrlSetBkColor($iWord, 0xFFFFFF)
        Case $PutText
            Local $iText = ClipGet()
            If @error = 0 Then      ; only if no error
                GUICtrlSetData($iWord, $iText)
            EndIf
    EndSwitch
WEnd

Thanks in advance for any help.

post-29172-0-72511900-1425164746_thumb.p

Link to comment
Share on other sites

It's a common Windows issue/bug, nothing to do with AutoIt.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You can try >here for an answer to get around it, not sure if it works because I've never tried it.

You can look here to see where it's been referenced hundreds of times.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thanks for the response.  Indeed, it looks like a long-standing problem, which, by all indications, got into the OS several years ago, with no easy way for them to undo it.

In my case, just reverting to $SS_SIMPLE doesn't work because I can't disable the button.

What I did was take the label off of the active button and place a disabled $SS_SIMPLE label on top of it.  Everything works ... meaning it doesn't copy the blank label to the clipboard as it did with the active label ... and it's still detected as a control click.

$PutText = GUICtrlCreateLabel("", 260, 40, 30, 24)
GUICtrlCreateLabel("Put", 262, 40, 30, 24, $SS_SIMPLE)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlSetTip(-1, "Button to replace contents")

I had to tweak the position of the disabled label because of the following aspect of $SS_SIMPLE:

Specifies a simple rectangle and displays a single line of left-aligned text in the rectangle. The text line cannot be shortened or altered in any way. Also, if the control is disabled, the control does not gray its text.

 

Although it sounded (from the links) like there might be other ways, this covers what I'm working on now.

Thanks again for your help.

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