德尔福奇怪的问题与剪贴板

时间:2016-02-06 02:16:55

标签: delphi winapi pascal delphi-10-seattle

我正在尝试使用我的应用程序读取窗口文本(控制台类型的窗口)。我就是这样做的。

1。使用'sendkey'发送Ctrl + a然后按Ctrl + C到终端

<?php
if (isset($_GET['variable'])) {
    $_SESSION['variable'] = $_GET['variable'];
    $results = mysqli_query($mysqli,"select q1.variable, t3.label, q1.numvalue, description, num_cases from (select variable, numvalue, count(variable) as num_cases from nhws.num_all_{$_SESSION['country']} where variable = '{$_SESSION['variable']}' group by variable, numvalue) q1 inner join (select * from nhws.luvalues where source = '{$_SESSION['country']}' and variable = '{$_SESSION['variable']}') t2 on q1.numvalue=t2.numvalue inner join (select * from nhws.luvariables where source = '{$_SESSION['country']}' and variable = '{$_SESSION['variable']}') t3 on q1.variable=t3.variable;");
    echo "<h5>Counts</h5>";
    if ($results->num_rows > 0) {
         echo "<table><tr><th>Variable</th><th>label</th><th>Numvalue</th><th>Description</th><th>Num Cases</th></tr>";
         // output data of each row
         while($row = $results->fetch_assoc()) {
              echo "<tr><td>" . $row["variable"]. "</td><td>" . $row["label"]. "</td><td>" . $row["numvalue"]. "</td><td>" . $row["description"]. "</td><td>" . $row["num_cases"]. "</td></tr>";
         }
         echo "</table>";
    } else {echo "0 results";} 

    $rows = array();
    //flag is not needed
    $flag = true;
    $table = array();
    $table['cols'] = array(

    // Labels for your chart, these represent the column titles
    // Note that one column is in "string" format and another one is in "number" format as pie chart only required "numbers" for calculating percentage and string will be used for column title
    array('label' => 'variable', 'type' => 'string'),
    array('label' => 'num_cases', 'type' => 'number')

    );

    $rows = array();
    while($r = $results->fetch_assoc()) {
         $temp = array();
         // the following line will be used to slice the Pie chart
         $temp[] = array('v' => (string) $r["variable"]); 

         // Values of each slice
         $temp[] = array('v' => (int) $r["num_cases"]);
         $rows[] = array('c' => $temp);
    }

    $table['rows'] = $rows;
    $jsonTable = json_encode($table);
    echo $jsonTable;
}
?>

2。复制后,它将保存到剪贴板中的txt文件

// Ctrl + a       
keybd_event(VK_CONTROL, 0, 0, 0);
fn_SendKeys('a');
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);

// Ctrl + c
keybd_event(VK_CONTROL, 0, 0, 0);
fn_SendKeys('c');
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);

第3。通过阅读来处理txt文件中的信息

除了在我的应用程序中,在将Ctrl + c发送到窗口之前在备忘录上执行Ctrl + C时,一切都运行正常。当我在备忘录中执行Ctrl + C,并尝试将剪贴板保存为我的应用程序中的文本时,它会抛出异常,说“无法打开剪贴板 - 访问被拒绝”。

当我在屏幕复制之前不对备忘录进行复制操作时,它可以100%完美地工作。奇怪的是,如果我在屏幕阅读之前复制/粘贴备忘录,它会100%失败。

有人可以帮我确认一下,我在这里做错了什么?

0 个答案:

没有答案