问题列表 - 第35733页

截取OSX中的键盘输入

我正在尝试编写一个应用程序来阻止某些关键信号在OSX中传播到OS之外.为了澄清,我想做到这一点,以便用户几乎看到他们在键盘上按下的键被打破了.因此,相关的字母不会出现在textarea中,该键不会激活另一个应用程序中的函数等.任何想法?提前致谢.

macos cocoa

2
推荐指数
1
解决办法
3282
查看次数

如何实现异步运行的可重用命名管道侦听器?

我找不到一个很好的例子来说明如何创建一个异步运行的可重用命名管道侦听器.我可以做一个可重用的听众:

NamedPipeServerStream pipeServer = new NamedPipeServerStream("MyPipe", PipeDirection.InOut);

    while (true)
    {
            pipeServer.WaitForConnection();

            StreamReader reader = new StreamReader(pipeServer);

            MessageBox.Show(reader.ReadLine());

            pipeServer.Disconnect();
    }
Run Code Online (Sandbox Code Playgroud)

我可以做一个不常见的倾听者:

NamedPipeServerStream pipeServer = new NamedPipeServerStream("MyPipe", PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous);

    pipeServer.BeginWaitForConnection((a) =>
    {
        pipeServer.EndWaitForConnection(a);

        StreamReader reader = new StreamReader(pipeServer);
        MessageBox.Show(reader.ReadLine());

    }, null);
Run Code Online (Sandbox Code Playgroud)

但我似乎无法兼得.这有一个很好的例子吗?我也担心部分发送的消息,因为我认为这是异步通信的问题.

更新:我离我更近一点了.

pipeServer = new NamedPipeServerStream("MyPipe", PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous);

pipeServer.BeginWaitForConnection((a) =>
{
    pipeServer.EndWaitForConnection(a);

    StreamReader reader = new StreamReader(pipeServer);

    while (running)
    {
        String text = reader.ReadLine();

        if (String.IsNullOrEmpty(text) == false)
        {
            MessageBox.Show(text);
        }
    }

    MessageBox.Show("Done!");

}, null);
Run Code Online (Sandbox Code Playgroud)

这将成功读取一次,并将继续循环,ReadLine在初始成功读取后返回空的空字符串.所以它显然没有阻止,并试图再次阅读.问题是如果我第二次发送相同的消息,它不会被拾取,我的管道编写者说它收到错误2316(虽然我无法弄清楚这意味着什么).我想我只需要做一些类似于管道每次清理的事情,就像我列出的第一个代码示例一样,但我还没有完成工作.

.net asynchronous named-pipes reusability

6
推荐指数
1
解决办法
8057
查看次数

如何在Javascript中实现'onVisible'事件?

是否有任何技术或技术可用于实现JavaScript中的onVisible'事件'实际上是什么?

我希望我的JavaScript能够检测网页中的元素(例如文本段落或图像)在用户向下滚动页面时何时在浏览器窗口中可见.我还想要一个相应的'事件',onNotVisible,当浏览器窗口中曾经可见的元素再也看不到时触发.

如果无法在JavaScript中轻松实现,是否有任何特定于浏览器的事件可以提供相同的功能?

html javascript javascript-events

21
推荐指数
3
解决办法
1万
查看次数

Powershell 2.0在字符之间生成空值

使用PowerShell 2.0:

write-output "abcd" >> mytext.txt  
Run Code Online (Sandbox Code Playgroud)

收益:

n n b nul c nul d nul

od -c将nul显示为真正的二进制零\0,或:( a \0 b \0 c \0 d \0\r \0 \n \0).

我试图生成一些SQL,所以我不认为这样做.有关正在发生什么的想法以及如何使用write-output来获取指定的字符?

null powershell-2.0

14
推荐指数
1
解决办法
5711
查看次数

在某些情况下,对于html img标签,alt =""是否合适?

我们有一个关于Web可访问性合规性的项目.从发布开始大约一周后,我们让无障碍委员会审查我们的网站,以给予最后的赞许.然而,他们向我们报告说,我们应该在我们的一些图标上设置alt ="",因为它们不向网站提供任何额外的内容,因此仅仅分散了屏幕阅读器的注意力,但没有产生任何好处.

  1. 它是否正确?
  2. 我的印象是alt是img的必需属性?在img标签上确定alt =""将包含alt属性,但这是否有效?

评论表示赞赏.

html accessibility alt-attribute

16
推荐指数
3
解决办法
469
查看次数

Android:LinearLayout中的中心ImageButton

如何将ImageButton置于此LinearLayout中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main"
>
Run Code Online (Sandbox Code Playgroud)

的ImageButton

              <ImageButton android:id="@+id/btnBut"
                      android:background="@drawable/button"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

我不想使用固定尺寸.

谢谢

android

5
推荐指数
2
解决办法
2万
查看次数

如何获得html元素的"绝对"位置

我有一些通过CSS定位的元素:

#myItem{
position: absolute;
left: 50%;
margin-left: -350px;
}
Run Code Online (Sandbox Code Playgroud)

我想从页面的左上边缘到左边距离.如何使用javascript/jquery获取这些度量?

谢谢

javascript css jquery

3
推荐指数
2
解决办法
863
查看次数

使用Javascript/jQuery进行同步GET请求

我有一个函数,它使得ajax GET请求和基于返回的值设置一个全局JS变量.我使用这个变量(下面的代码中的isCalculateTax)进行进一步处理:

var isCalculateTax;

function setCalculateTaxValue(taxStatementId) {
 $.get('/taxstatements/calculatetax/' + taxStatementId, function (data) {
  isCalculateTax = data.isCalculateTax;
 });
}

$(document).ready(function () {
 // initially check the tax statements dropdown to see which one is selected
 // and set the isCalculateTax to the right value
 var taxStatementId = $('#taxStatements').val();
 setCalculateTaxValue(taxStatementId);
 enumerateDocumentItems(isCalculateTax);
});
Run Code Online (Sandbox Code Playgroud)

我的问题是,当enumerateDocumentItems()被调用并执行时,isCalculateTax尚未从AJAX GET请求更新,因此我收到了不可预测的结果.

如何在执行enumerateDocumentItems()之前等待必要的时间,以便isCalculateTax正确?

javascript jquery

7
推荐指数
1
解决办法
6384
查看次数

插件系统如何工作?

我正在开发一个项目,我会发现一个基本的插件系统很有用.本质上,我创建了基类,并可以为插件开发人员提供此基类.然后开发人员覆盖它并覆盖方法.然后这就是我对它有点不清楚的地方.它是如何工作的?我在哪里可以找到有关这类系统开发的文档?

谢谢

c c++ plugins

5
推荐指数
1
解决办法
1003
查看次数

为什么'print(52-80)*42'与Perl中的'print 42*(52-80)'不同?

Perl ::什么是:

1. (52-80)*42
2. 42*(52-80)
Run Code Online (Sandbox Code Playgroud)

答:

1. -28
2. -1176
Run Code Online (Sandbox Code Playgroud)

为什么?

请乐趣解释/证明这一点!

#!/usr/bin/perl
use strict;
print 42*(52-80) , "\n";
print ((52-80)*42) , "\n";
print (52-80)*42 , "\n";
print "\n";
my $i=(52-80)*42;
print $i, "\n";
Run Code Online (Sandbox Code Playgroud)

输出:

> -1176
> -1176-28
> -1176
Run Code Online (Sandbox Code Playgroud)

printing math perl operators

3
推荐指数
3
解决办法
455
查看次数