- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试为一款游戏制作一个机器人,但他们有很酷的反像素机器人技术。
所以我想,“如果我可以制作一个机器人,只检查光标是否变为手形然后单击,它就会起作用,”因为我需要收集奖金盒,当你将光标指向它时,它变为“手”光标。
所以我对这个想法非常高兴,但在 C# 中,它不起作用!
在 C# 中 - Cursor.Current
仅检查表单上的光标状态,而不检查整个计算机的光标状态,这不是我想要的。
那么,我怎样才能获得真正的光标类型状态呢? (如果是手,普通光标,调整某些东西的大小或等待等)
最佳答案
好吧,我找到了一些东西并使其正常工作,如果有人需要的话,这里是代码:
private static string GetCursorState()
{
var h = Cursors.WaitCursor.Handle;
CURSORINFO pci;
pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
GetCursorInfo(out pci);
return pci.hCursor.ToString();
}
[StructLayout(LayoutKind.Sequential)]
struct POINT
{
public Int32 x;
public Int32 y;
}
[StructLayout(LayoutKind.Sequential)]
struct CURSORINFO
{
public Int32 cbSize; // Specifies the size, in bytes, of the structure.
// The caller must set this to Marshal.SizeOf(typeof(CURSORINFO)).
public Int32 flags; // Specifies the cursor state. This parameter can be one of the following values:
// 0 The cursor is hidden.
// CURSOR_SHOWING The cursor is showing.
public IntPtr hCursor; // Handle to the cursor.
public POINT ptScreenPos; // A POINT structure that receives the screen coordinates of the cursor.
}
[DllImport("user32.dll")]
static extern bool GetCursorInfo(out CURSORINFO pci);
关于C# - 如何获取当前光标状态(如果当前是箭头、手、等待等),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25367952/
在 firefox 中,链接手形光标显示正常,但在 IE7 中显示文本光标。 如何在所有浏览器的链接上获得相同的光标(手)? 我可以在 CSS 重置中添加一些内容,以便在所有浏览器中的链接上获取光标吗
我试图在表单元素上方显示我的表单标签,所以我在我的 CSS 中使用了 display:block。但是,我无法通过这种方式每行显示超过 1 个表单元素。 如何正确更新我的 CSS 以在表单元素上方显示
我想找到人手的宽度,但卡在手上的洞上。 我有一只手的图片并找到了它的二进制文件。手上有一个圆圈,其半径和中心已知(引用对象)。我想找到手的宽度,但它上面有一些补丁(孔),这阻碍了找到手的最佳宽度。 这
我尝试为一款游戏制作一个机器人,但他们有很酷的反像素机器人技术。 所以我想,“如果我可以制作一个机器人,只检查光标是否变为手形然后单击,它就会起作用,”因为我需要收集奖金盒,当你将光标指向它时,它变为
我尝试为一款游戏制作一个机器人,但他们有很酷的反像素机器人技术。 所以我想,“如果我可以制作一个机器人,只检查光标是否变为手形然后单击,它就会起作用,”因为我需要收集奖金盒,当你将光标指向它时,它变为
所以我有一副牌的代码,但我不知道如何让另一个类来处理 4 手牌,每手 10 张牌。另一类应在屏幕上以文字形式打印 4 手 10 张随机卡片。有人可以向我展示如何完成此任务的代码吗?我也使用 blueJ
我正在尝试通过在开放正方形内插入图标来使用 fontawesome 创建图标。悬停时,我想更改正方形内背景的颜色,以及正方形的实际颜色和图标颜色。 我在这里举了一个例子:http://jsfiddle
当我手动启 Action 业时,我正在寻找设置变量的正确方法。 我试过 : stages: - test my_job: stage: test script: - echo "H
我必须添加以下代码: a {cursor:pointer;} 在 angular-ui-bootstrap 中将光标更改为标签、分页、下拉切换等链接上的指针/手。 为什么默认不改为指针?这是故意的吗?
我是一名优秀的程序员,十分优秀!