将 vb6 转换为 autoit

发布于 2024-10-28 13:29:30 字数 1628 浏览 12 评论 0原文

谁能帮我将其转换为 autoit,或者至少告诉我如何在 autoit 中执行此操作?

Private Const DC_PAPERNAMES = 16

Private Declare Function DeviceCapabilities Lib "winspool.drv" _
    Alias "DeviceCapabilitiesW" ( _
    ByVal lpDeviceName As Long, _
    ByVal lpPort As Long, _
    ByVal iIndex As Long, _
    ByVal lpOutput As Long, _
    ByVal lpDevMode As Long) As Long

Private Sub Form_Load()
    Dim P As Printer

    For Each P In Printers
        lstPrinters.AddItem P.DeviceName
    Next
End Sub

Private Sub lstPrinters_Click()
    Dim P As Printer
    Dim lngPapers As Long
    Dim strPaperNames As String
    Dim lngPaper As Long
    Dim strPaperName As String
    Dim lngActualLength As Long

    Set P = Printers(lstPrinters.ListIndex)
    lngPapers = DeviceCapabilities(StrPtr(P.DeviceName), _
                                   StrPtr(P.Port), _
                                   DC_PAPERNAMES, _
                                   0, _
                                   0)
    strPaperNames = String$(lngPapers * 64, 0)
    lngPapers = DeviceCapabilities(StrPtr(P.DeviceName), _
                                   StrPtr(P.Port), _
                                   DC_PAPERNAMES, _
                                   StrPtr(strPaperNames), _
                                   0)
    lstPapers.Clear
    For lngPaper = 0 To lngPapers - 1
        strPaperName = Mid$(strPaperNames, 64 * lngPaper + 1, 64)
        lngActualLength = InStr(strPaperName, vbNullChar) - 1
        If lngActualLength > 1 Then strPaperName = Left$(strPaperName, lngActualLength)
        lstPapers.AddItem strPaperName
    Next
End Sub

can anyone help me convert this to autoit, or at least tell me how i can do this in autoit?

Private Const DC_PAPERNAMES = 16

Private Declare Function DeviceCapabilities Lib "winspool.drv" _
    Alias "DeviceCapabilitiesW" ( _
    ByVal lpDeviceName As Long, _
    ByVal lpPort As Long, _
    ByVal iIndex As Long, _
    ByVal lpOutput As Long, _
    ByVal lpDevMode As Long) As Long

Private Sub Form_Load()
    Dim P As Printer

    For Each P In Printers
        lstPrinters.AddItem P.DeviceName
    Next
End Sub

Private Sub lstPrinters_Click()
    Dim P As Printer
    Dim lngPapers As Long
    Dim strPaperNames As String
    Dim lngPaper As Long
    Dim strPaperName As String
    Dim lngActualLength As Long

    Set P = Printers(lstPrinters.ListIndex)
    lngPapers = DeviceCapabilities(StrPtr(P.DeviceName), _
                                   StrPtr(P.Port), _
                                   DC_PAPERNAMES, _
                                   0, _
                                   0)
    strPaperNames = String$(lngPapers * 64, 0)
    lngPapers = DeviceCapabilities(StrPtr(P.DeviceName), _
                                   StrPtr(P.Port), _
                                   DC_PAPERNAMES, _
                                   StrPtr(strPaperNames), _
                                   0)
    lstPapers.Clear
    For lngPaper = 0 To lngPapers - 1
        strPaperName = Mid$(strPaperNames, 64 * lngPaper + 1, 64)
        lngActualLength = InStr(strPaperName, vbNullChar) - 1
        If lngActualLength > 1 Then strPaperName = Left$(strPaperName, lngActualLength)
        lstPapers.AddItem strPaperName
    Next
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小霸王臭丫头 2024-11-04 13:29:30

这是一个有人试图做完全相同的事情的线程: http://www.autoitscript.com/forum/topic/25857-need-a-help-from-the-pros-on-making-api-call/

还有一个指南可以帮助您编写 Windows API 调用: http:// www.autoitscript.com/forum/topic/7072-dllcall/ 它主要处理找到正确的类型转换,这是唯一困难的部分。

Here's a thread where someone is trying to do the exact same thing: http://www.autoitscript.com/forum/topic/25857-need-a-help-from-the-pros-on-making-api-call/

There is also a guide which will help you write windows API calls: http://www.autoitscript.com/forum/topic/7072-dllcall/ it deals mainly with finding the correct type conversion which is the only hard part.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文