标题: [系统相关] 哪个第三方工具可以获取鼠标坐标 [打印本页]
作者: 522235677 时间: 2015-4-8 11:06 标题: 哪个第三方工具可以获取鼠标坐标
是可以获取鼠标在屏幕上的坐标,不是cmd窗口中点击的坐标。
作者: 523066680 时间: 2015-4-8 11:36
看到某君回复了又删了?
应该有好几个工具,论坛里找找
作者: 522235677 时间: 2015-4-8 13:14
回复 2# 523066680
论坛里我只找到了一个,但是需要按一下end键然后才能显示出坐标。我想找到不用操作的直接就能获取
作者: pcl_test 时间: 2015-4-8 13:24
本帖最后由 pcl_test 于 2015-4-8 13:30 编辑
结合vbs代码- @echo off
- more +5 %~nx0>"%temp%\getCursor.vbs"
- for /f "tokens=1*" %%i in ('cscript /nologo "%temp%\getCursor.vbs"') do echo X=%%i Y=%%j
- pause
- exit
- Option Explicit
- Dim WshShell
- Dim oExcel, oBook, oModule
- Dim strRegKey, strCode, x, y
- Set oExcel = CreateObject("Excel.Application")
- set WshShell = CreateObject("wscript.Shell")
-
- strRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\$\Excel\Security\AccessVBOM"
- strRegKey = Replace(strRegKey, "$", oExcel.Version)
- WshShell.RegWrite strRegKey, 1, "REG_DWORD"
-
- Set oBook = oExcel.Workbooks.Add
- Set oModule = obook.VBProject.VBComponents.Add(1)
- strCode = _
- "Private Declare Function SetCursorPos Lib ""user32"" (ByVal x As Long, ByVal y As Long) As Long" & Chr(13) & _
- "Private Type POINTAPI : X As Long : Y As Long : End Type" & Chr(13) & _
- "Private Declare Function GetCursorPos Lib ""user32"" (lpPoint As POINTAPI) As Long" & Chr(13) & _
- "Sub SetCursor(x as Long, y as Long) : SetCursorPos x, y : End Sub" & Chr(13) & _
- "Public Function GetXCursorPos() As Long" & Chr(13) & _
- "Dim pt As POINTAPI : GetCursorPos pt : GetXCursorPos = pt.X" & Chr(13) & _
- "End Function" & Chr(13) & _
- "Public Function GetYCursorPos() As Long" & Chr(13) & _
- "Dim pt As POINTAPI: GetCursorPos pt : GetYCursorPos = pt.Y" & Chr(13) & _
- "End Function"
- oModule.CodeModule.AddFromString strCode
- x = oExcel.Run("GetXCursorPos")
- y = oExcel.Run("GetYCursorPos")
- WScript.Echo x, y
- oExcel.DisplayAlerts = False
- oBook.Close
- oExcel.Quit
复制代码
作者: 522235677 时间: 2015-4-8 16:26
回复 4# pcl_test
谢啦,网上也搜到过这个脚本,不过得有excel的支持
作者: yiwuyun 时间: 2015-4-10 17:44
因为感兴趣,所以研究了一下powershell对win32函数的调用,但只懂点皮毛:- if ($true){}# == ($true){}# goto ___yiwuyun
- <#BeginBatOperation#
- :___yiwuyun
- @echo off&setlocal&cls
- (echo $yiwuyun_fileName="%~f0"&echo $strPath="%~dp0"&type "%~f0")|powershell -command -
- pause
- exit/b 0
- #EndBatOperation#>
-
- <#StartPowerShell#>
-
- $Signature = @"
- [System.Runtime.InteropServices.DllImport("user32.dll",EntryPoint="GetCursorPos")]public static extern bool GetCursorPos(out long lPoint);
- "@
- $MouseLocation= Add-Type -MemberDefinition $Signature -Name "Win32CursorPos" -Namespace Win32Functions -PassThru
- $point=[int64]0;
- $MouseLocation::GetCursorPos([ref] $point)|Out-Null;
- $dy=[int16]($point -shr 32);
- $dx=[int16]($point -band 0xffff);
- "鼠标坐标:($dx,$dy)";
-
- <#EndPowerShell#>
-
- <#StartJS#
-
- #EndJS#>
-
-
- <#StartVBS#
-
- #EndVBS#>
-
- <#StartRouterCommand#
-
- #EndRouterCommand#>
复制代码
作者: yiwuyun 时间: 2015-4-12 17:44
一翻思索,总算解决了不能传结构的问题。看来要学好powershell还需要学学C#- if ($true){}# == ($true){}# goto ___yiwuyun
- <#BeginBatOperation#
- :___yiwuyun
- @echo off&setlocal&cls
- (echo $yiwuyun_fileName="%~f0"&echo $strPath="%~dp0"&type "%~f0")|powershell -command -
- pause
- exit/b 0
- #EndBatOperation#>
-
- <#StartPowerShell#>
-
- $TypeSignature=@"
- public struct Point{
- public int x,y;
- };
- public class MyPoint{
- [System.Runtime.InteropServices.DllImport("user32.dll",EntryPoint="GetCursorPos")]
- private static extern bool GetCursorPos(ref Point lpPoint);
- public Point GetCursor(){
- Point lpPoint=new Point();
- GetCursorPos(ref lpPoint);
- return lpPoint;
- }
- }
- "@
- Add-Type -TypeDefinition $TypeSignature;
- $point=New-Object MyPoint;
- "鼠标坐标:`($($point.GetCursor().x),$($point.GetCursor().y)`)"
-
- <#EndPowerShell#>
-
- <#StartJS#
-
- #EndJS#>
-
-
- <#StartVBS#
-
- #EndVBS#>
-
- <#StartRouterCommand#
-
- #EndRouterCommand#>
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |