Jump to content

Irreliable copy method


Sodori
 Share

Recommended Posts

Hello humans!

I have been copying stuff rather heavy lately. Trying to clean up my code, begins at the weakest link when I am actually copying. Because I have to wait for some time just for I don't know windows to get the thing. Did a small test, code looks like this (because I know some of you really get's turned on by them ;) ):

Global $Chrome = WinWait("[TITLE:Jobb - Google Kalkylark - Google Chrome]")
If $Chrome = 0 Then Exit 2

For $j = 1 To 10
    Local $aArray[0], $Average = 0
    WinActivate($Chrome)

    For $i = 1 To 1000
        TrayTip("Counting, do not touch please!", $j & ":" & $i, 10)
        ClipPut(512036762)
        Local $Timer = TimerInit()
        Do
            _Send("^c") ;CTRL + C
        Until ClipGet() = 1160203
        $Average += TimerDiff($Timer)
        _ArrayAdd($aArray, Round(TimerDiff($Timer), 0))
    Next
    ConsoleWrite("Max: " & _ArrayMax($aArray) & @LF & "Min: " & _ArrayMin($aArray) & @LF & "Average: " & $Average / UBound($aArray) & @LF)
    ConsoleWrite("-------------------------------------------------------------------------------------------------------" & @LF)

Next

Func _Send($command, $delay = Default)
    If $delay = Default Then $delay = 100
    Sleep($delay)
    Send($command)
EndFunc

This did a total of 10,000 times a copy, and calculated the time it took. Because I knew what was being copied, I could easily determine code to keep on trying till it got it.

This is not the case real life. Nor can I real life set clip to "bladiblabla" and hope for the best, because sometimes it turns blank. Neither can I check for no blanks together, since real life can have blanks. So I need it proper! Here is the result of 10,000 copies, I think you can see the issue: https://docs.google.com/spreadsheets/d/1MvusqDZPsA9Qh6COOeN0hz2s81RxAf6EMCbVsSwnEuk/edit?usp=sharing

It's way, way to unprecise! I am already waiting half a second, and it needs to be faster. Code faster! I can't extract it by ways of IE get objects, copying is the best solution unless someone has a Google spreadsheet UDF.

Link to comment
Share on other sites

_ArrayAdd might be part of your problem, it's using ReDim in a loop of 1000 so it's going to slow down your script.

The rest of your problem I can't comment on, because I'm not sure what exactly you're trying to say.

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

_ArrayAdd might be part of your problem, it's using ReDim in a loop of 1000 so it's going to slow down your script.

The rest of your problem I can't comment on, because I'm not sure what exactly you're trying to say.

Saying I can't just do a 

_Send("^c")

And be done with it. I need to check when windows actually have copied the proper text. and that is a bottleneck to me.

Link to comment
Share on other sites

Found a workaround. Compromising startup time a bit, but makes it considerable more stable. Whatever cell active it will extract that data.

Local $oIE = _IECreate("https://docs.google.com/spreadsheets/d/1-wX5uG143jSCY9AIvBWaLmCaBx60gIjLuqGmeljKvBI/edit?usp=sharing", 1)

$tags = _IETagNameGetCollection($oIE, "div")
For $tag in $tags
    If $tag.className = "cell-input disabled-input" Then
        Local $IEGet = $tag
        ExitLoop
    EndIf

Next

TrayTip("Ready!", "We are ready!!", 1)

While 1
    Local $test = $IEGet.innertext
    If $test <> $IEGet.innertext Then
        ConsoleWrite($IEGet.innertext & @LF)
        $test = $IEGet.innertext
    Else
        TrayTip("Eh...", $IEGet.innertext, 5)
        Sleep(100)
    EndIf

WEnd

 

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