#!/usr/bin/env python3
from controlfloor import *

# Get clipboard text by pasting it into an app we control, and pulling the
# text from the element. (obviously clipboard TEXT only)

def get_clipboard( kill_app_when_complete = False ):
    select_all_strings  = get_ios_strings("UIKit", "SELECT_ALL")
    cut_strings         = get_ios_strings("UIKit", "CUT")
    paste_strings       = get_ios_strings("UIKit", "PASTE")

    launchApplication("com.dryark.CFAUIInspector")
    wait(2)

    tap("buttonClear")
    wait(1)

    textViewDefault = getElement("textViewDefault","textView")
    textViewDefault.paste()

    wait(0.5)

    textViewDefault = getElement("textViewDefault","textView")
    v = textViewDefault.value

    tap("buttonClear")
    if kill_app_when_complete:
        killApplication("com.dryark.CFAUIInspector")
        wait(0.5)

    #print(v)
    return v

def run():
    print(get_clipboard())

cfrun(__name__, run )
