Jump to content
BatMan22

Assigning Array Values Until ClipGet gives dup data or ""

Recommended Posts

BatMan22

Hey guys.. I'm trying to figure out the logic of my loop and I'm changing the values and in my head it makes sense but my program isn't doing what I need it to do. So the idea is this... Copy a value from a cell, save in array, send down key, and repeat until either the clipboard doesn't copy anything or until it copies duplicate data.

 

;~ BatchFixer

#include <Array.au3>


WinWait("Sample Selection Box")
WinActivate("Sample Selection Box")
Sleep(500)
Global $var[1]= ["SampleID's"]
$counter = 1

While  $var[$counter-1] <> "" ;OR $var[$counter] <> $var[$counter-1]
    Send("^c")
    Send("{Down}")
    $var[$counter-1] = ClipGet()
    ConsoleWrite("Var is: " & $var[$counter-1] & " this cycle." & "Counter is:" & $counter & @CRLF)
    $counter = $counter + 1
    ReDim $var[UBound($var) + 1]
WEnd

_ArrayDisplay($var, "Total Copied From Available")

 

Share this post


Link to post
Share on other sites
Subz

Couple of examples:

#include <Array.au3>
_Example1()
    MsgBox(32, "Reset Selection", "Reset Selection for Example 2")
_Example2()
Exit
Func _Example1()
    Local $sClip
    WinWait("Sample Selection Box")
    WinActivate("Sample Selection Box")
    Sleep(250)
    Local $aArray[1]= ["SampleID's"]
    Local $i = 1
    While 1
        Send("^c")
        Send("{Down}")
        Sleep(250)
        $sClip = StringStripWS(ClipGet(), 7)
        If StringStripWS($sClip, 8) = "" Then
            ExitLoop
        Else
            ReDim $aArray[UBound($aArray) + 1]
            $i += 1
            $aArray[$i-1] = $sClip
        EndIf
        ConsoleWrite("Var is: " & $aArray[$i-1] & " this cycle." & "Counter is:" & $i - 1 & @CRLF)
    WEnd
    _ArrayDisplay($aArray, "Total Copied From Available")
EndFunc

Func _Example2()
    Local $sClip
    WinWait("Sample Selection Box")
    WinActivate("Sample Selection Box")
    Sleep(250)
    Local $aArray[1]= ["SampleID's"]
    Local $i = 0
    Do
        Send("^c")
        Send("{Down}")
        Sleep(100)
        $sClip = StringStripWS(ClipGet(), 7)
        If StringStripWS($sClip, 8) <> "" Then
            ReDim $aArray[UBound($aArray) + 1]
            $i += 1
            $aArray[$i] = $sClip
        EndIf
        ConsoleWrite("Var is: " & $aArray[$i] & " this cycle." & "Counter is:" & $i & @CRLF)
    Until StringStripWS($sClip, 8) = ""

    _ArrayDisplay($aArray, "Total Copied From Available")
EndFunc

 

  • Like 1

Share this post


Link to post
Share on other sites
BatMan22

Thank you both, you guys replied while I was asleep. I’ll check it out more in detail when I get to work. Thanks guys.

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

×