Sign in to follow this  
Followers 0
gripper

ClipGet issues

9 posts in this topic

I have a program that pulls info from a webpage that is java.  I have decided to use the ClipGet command but, I am getting inconsistent information being pasted when the $Var = ClipGet() is called.

My error is that it will hold data from the last loop and not clear and gather fresh.

At the end of the loop I have it write the content to a txt file.

 

$Var = ClipGet()

FileWriteLine($OutputFile,$var & "," & $sFirst & "," & $sLast)

All data for the other variables which are from the array works perfectly but the ClipGet() gets messed up.

So I am looking for a quick suggestion - Is there something to flush the clipboard before the copy command to ClipGet() occurs.  I am thinking that if I could do that then that would dump out old information.

Any thoughts on this.

Thank you.

Share this post


Link to post
Share on other sites



I have a program that pulls info from a webpage that is java.  I have decided to use the ClipGet command but, I am getting inconsistent information being pasted when the $Var = ClipGet() is called.

My error is that it will hold data from the last loop and not clear and gather fresh.

At the end of the loop I have it write the content to a txt file.

 

$Var = ClipGet()

Add

$Var = ""

at the begining of the loop?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Add

$Var = ""

at the begining of the loop?

That will clear the variable's contents, not the clipboard's, although that may be part of the OPs problem. To clear the clipboard, you'd need

ClipPut("")

Although, I don't think the OPs problem is that the clipboard needs to be cleared, I think it's that whatever they're trying to put into it, or think they're putting into it, isn't getting put into the clipboard at all.

Edited by BrewManNH

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The ClipGet help states "Returns a string containing the text on the clipboard."

Good ole Microsoft implies there only can be one clipboard object which will contain the data is as many formats as possible : http://msdn.microsoft.com/en-us/library/windows/desktop/ms649014(v=vs.85).aspx

Which probably means your copy command will overwrite any existing content.

However, as you haven't shared your code - it is hard to tell if you need to clear the clipboard because of another reason.

Edited by MouseSpotter

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi guys,

I am going nuts with this so I made a test script.  What I am doing is trying to extract info from a javascript webpage.  The right click menus work fine on the page as far as "Select All" which highlights the line and then "Copy".  When I do it manually I can do the same and paste in to a text file without problems.

I am having a real mental block here.

Here is my test script to work through this and to experiment some.

#include <Clipboard.au3>


$OutputFile = @ScriptDir & "\Finished.txt"
ClipPut("")
$var = ClipGet()

FileOpen($OutputFile)

For  $i = 4 to 1 Step - 1
;*****************First Name
;Highlight the "Pick a name Field"
MouseClick("Left", 1097, 311, 1)
Sleep(1000)

;Bring up the sub menu
MouseClick("Right",1097, 311, 1)
Sleep(1000)
;MouseMove(1245, 529)

;Select "Select All"
MouseClick("Left", 1152, 452, 1)
Sleep(1000)

;Click on the "Pick a name Field again to highlight
MouseClick("Right", 1097, 311, 1)
Sleep(1000)

;Click on "Copy" to send to clipboard
MouseClick("Left", 1138, 380, 1)
Sleep(1000)

FileWriteLine($OutputFile,$i & "- "  & $var)
;*************************Last


;Highlight the "Pick a name Field"
MouseClick("Left", 1287, 312, 1)
Sleep(1000)

;Bring up the sub menu
MouseClick("Right", 1287, 312, 1)
Sleep(1000)
;MouseMove(1245, 529)

;Select "Select All"
MouseClick("Left", 1332, 451, 1)
Sleep(1000)

;Click on the "Pick a name Field again to highlight
MouseClick("Right", 1287, 312, 1)
Sleep(1000)

;Click on "Copy" to send to clipboard
MouseClick("Left", 1339, 375, 1)
Sleep(1000)

FileWriteLine($OutputFile,$i & "- "  & $var)


;************************8Username
;Username
;Highlight the "Pick a name Field"
MouseClick("Left", 1173, 380, 1)
Sleep(1000)

;Bring up the sub menu
MouseClick("Right", 1173, 380, 1)
Sleep(1000)

;Select "Select All"
MouseClick("Left", 1245, 529, 1)
Sleep(1000)

;Click on the "Pick a name Field again to highlight
MouseClick("Right", 1173, 380, 1)
Sleep(1000)

;Click on "Copy" to send to clipboard
MouseClick("Left", 1225, 450, 1)
Sleep(1000)

FileWriteLine($OutputFile,$i & "- "  & $var )

next

FileClose($OutputFile)

My output in the text file is this

4-
4-
4-
3-
3-
3-
2-
2-
2-
1-
1-
1-
 

So it is not recognizing the $var.

I know I am doing something backwards here or perhaps MouseSpotter is correct in that it could be an ops issue as far as the clipboard is not receiving the copy command from the javascript page into the clipboard.

Just for kicks I tried to do each Copy procedure twice but that was useless.

If that is the case is there a work around that anybody is aware of.  I am stuck using mouseclicks and such

Thanks in advance for your help

Edited by gripper

Share this post


Link to post
Share on other sites

That will clear the variable's contents, not the clipboard's, although that may be part of the OPs problem. To clear the clipboard, you'd need

ClipPut("")

Although, I don't think the OPs problem is that the clipboard needs to be cleared, I think it's that whatever they're trying to put into it, or think they're putting into it, isn't getting put into the clipboard at all.

Well, yes, this is what's the author's problem - "My error is that it will hold data from the last loop and not clear and gather fresh." If he isn't talking about the variable, then he is having another issue since if you copy let's say the letter "a" then copy "b" when you paste the content of the clipboard you won't see "ab" but "b".

Anyway @gripper, why do you want to write the username/password to a text file?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

At the beginning of the script, you're defining $var to equal what's in the clipboard, but after you copy stuff to the clipboard, you don't redefine it. So you're writing whatever was in your clipboard ($var), which has been cleared with the CipPut line.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

you are setting $var once ... at the beginning of the script

You need to set $var to the clipboard content after each copy:

$var = ClipGet()

FileWriteLine($OutputFile,$i & "- "  & $var)

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