Jump to content

ClipGet question


Go to solution Solved by gruntydatsun,

Recommended Posts

Posted

I have something like this:

;an event outside of autoit happens so that some data is copied to the clipboard
msgbox (0,"", clipget())
$myvar = clipget()
;an event outside of autoit happens so that some new data is copied to the clipboard
msgbox (0,"", $myvar)

I have a problem with Line 5, that the value of $myvar displayed is that of the newly copied data that happened on Line 4 - how do I get $myvar on Line 5 to show the data copied from Line 1?

Posted

You'd have to put the ClipGet return into another variable to store it, otherwise when you overwrite it in line 4 it will be gone and you can't retrieve it. Basically, do the same thing you did in line 3, get the contents of the clipboard and put it into a variable, then use that variable in your message box.

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!

  Reveal hidden contents

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

Posted
  On 11/2/2013 at 1:27 AM, molotofc said:

I have something like this:

;an event outside of autoit happens so that some data is copied to the clipboard
msgbox (0,"", clipget())
$myvar = clipget()
;an event outside of autoit happens so that some new data is copied to the clipboard
msgbox (0,"", $myvar)

I have a problem with Line 5, that the value of $myvar displayed is that of the newly copied data that happened on Line 4 - how do I get $myvar on Line 5 to show the data copied from Line 1?

If what you say is happening, really is, it does not make sense, and would be some sort of time travelling quantum bug.

I suspect there is much more to it than the events you describe, and that is where your problems lie.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted
  On 11/2/2013 at 1:35 AM, BrewManNH said:

You'd have to put the ClipGet return into another variable to store it, otherwise when you overwrite it in line 4 it will be gone and you can't retrieve it. Basically, do the same thing you did in line 3, get the contents of the clipboard and put it into a variable, then use that variable in your message box.

 

I already assigned ClipGet() into a variable ($myVar) on Line 3 - where am I going wrong?

  • Solution
Posted

if you are testing this by:

  • copy "a" to the clipboard
  • run program
  • when message box shows copy "b" to the clipboard
  • click OK on message box

 

then you will see the problem you describe.

  • your program is retrieving the clipboard and displaying in a message box
  • program has halted executing here at line 1
  • you put "b" onto the clipboard
  • you press ok in the message box
  • program moves to line 2 and gets "b" off the clipboard and puts it in $myvar
  • program moves to line 3 and displays $myvar which is now "b"

 

if this is happening with an external program, then the contents of the clipboard are changing while the message box is up and before line 2 runs to assigned the contents of the clipboard to a variable.

try this:

$myvar = clipget()
msgbox (0,"", $myvar)
;an event outside of autoit happens so that some new data is copied to the clipboard
$myvar2 = clipget()
msgbox (0,"", "$myvar = " & $myvar & "     $myvar2 = " & $myvar2)

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
  • Recently Browsing   0 members

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