Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to change the code to QM code
#1
how can I change the code as red color below to QM code :

COM methods, need to be registered to the system, the class name: sy.dt

Shell "regsvr32 / s sydt.dll"
Set sydt = CreateObject ("sy.dt")


or

LoadLibrary to load DLL, do not register with the system

LoadLibrary ("sydt.dll")

Thanks in advance!
#2
Macro Macro2132
Code:
Copy      Help
;Shell "regsvr32 / s "
RegisterComComponent "sydt.dll" 4
;Set sydt = CreateObject ("sy.dt")
IDispatch sydt._create("sy.dt")

Often don't need to register COM dlls. Try this:
Macro Macro2133
Code:
Copy      Help
;Set sydt = CreateObject ("sy.dt")
IDispatch sydt._create("{SYDT-CLASS-GUID}" "sydt.dll")

If have type library:
Macro Macro2135
Code:
Copy      Help
;Set sydt = CreateObject ("sy.dt")
typelib Sydt "sydt.dll" 1
Sydt.Class1 sydt._create(0 "sydt.dll")
;or
IDispatch sydt._create(uuidof(Sydt.Class1) "sydt.dll")
;or, if component registered
Sydt.Class1 sydt._create

Can use LoadLibrary, but usually we declare dll functions instead:
dll "sydt.dll"
,Func1 a b
,Func2 c d

Need to declare correct parameter types etc, read more in dll help.
Many Windows API are already declared, + you can download more Windows declarations.
#3
Hi Gintaras, thanks for your quickly support,
but I fail on other step.
the VB source code is as below:

VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "VB調用例子"
ClientHeight = 3090
ClientLeft = 45
ClientTop = 330
ClientWidth = 4905
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3090
ScaleWidth = 4905
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command6
Caption = "Send"
Height = 375
Left = 2640
TabIndex = 8
Top = 2280
Width = 975
End
Begin VB.CommandButton Command5
Caption = "Command5"
Height = 375
Left = 3840
TabIndex = 7
Top = 2400
Width = 975
End
Begin VB.CommandButton Command4
Caption = "Command4"
Height = 375
Left = 3840
TabIndex = 6
Top = 2040
Width = 975
End
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 375
Left = 3840
TabIndex = 5
Top = 1680
Width = 975
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 375
Left = 3840
TabIndex = 4
Top = 1320
Width = 975
End
Begin VB.CommandButton Command1
Caption = "截圖發送題目"
Height = 360
Left = 720
TabIndex = 3
Top = 2280
Width = 1320
End
Begin VB.TextBox Text1
Height = 300
Left = 840
TabIndex = 1
Text = "13663496867HHMGG5FLQ3N5LUBQ100"
Top = 120
Width = 3960
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 120
Top = 2640
End
Begin VB.ListBox List1
Height = 1500
Left = 120
TabIndex = 0
Top = 600
Width = 4695
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "驗證串:"
Height = 195
Left = 120
TabIndex = 2
Top = 180
Width = 585
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'可以改成API調用,見 Command6_Click
'順逸代答QQ技術群:210412674
Private Declare Function Send Lib "sydt.dll" (ByVal c1 As String, Optional ByVal c2 As String = "gif") As String
Dim sydt As Object
Dim TID As Variant

Private Sub Command2_Click()
MsgBox sydt.Send("charge/username/324166166/password/000000/cards/1366698708OXGULUXXXXXXZWVL0NJF")
End Sub

Private Sub Command3_Click()
MsgBox sydt.Send("register/username/324166166/password/000000/author/324166166/xtime/3/note/備註信息")
End Sub

Private Sub Command4_Click()
MsgBox sydt.Send("login/myapi/1366698708OXGULUXXXXXXZWVL0NJF/mode/1")
End Sub

Private Sub Command5_Click()
MsgBox sydt.Send("getpoints/username/324166166/password/000000")
End Sub

Private Sub Form_Load()
' Shell "regsvr32 /s sydt.dll"
' Set sydt = CreateObject("sy.dt")
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set sydt = Nothing
End Sub

Private Sub Command1_Click() '發送截圖
'sydt.CaptureGif 0, 0, 200, 200, "C:\1.gif"
TID = sydt.Send("sendvcode/myapi/" + Text1.Text + "/type/10001/timeout/30/note/備註", App.Path + "\驗證截圖.jpg")
List1.AddItem TID
If Left(TID, 1) <> "E" Then
Timer1.Enabled = True
End If
List1.ListIndex = List1.ListCount - 1
End Sub

Private Sub Command6_Click()
MsgBox Send("sendvcode/myapi/" + Text1.Text + "/type/10001/timeout/30/note/備註", App.Path + "\驗證截圖.jpg")
End Sub

Private Sub Timer1_Timer() '獲取答案
Dim Answer As String
Answer = sydt.Send("getanswer/id/" & TID)
List1.AddItem Answer
If Left(Answer, 7) <> "WAITING" Then
List1.ListIndex = List1.ListCount - 1
Timer1.Enabled = False
End If
End Sub


I have modified QM code, I encountered the problem, it occurs in "left(ID, 1)", it show the error message is that "unknown identifier".
Could you show me about your advice on my complete QM code and my error, because I am a novice on QM, thanks. I still have a lot to learn about QM...
#4
Replace VARIANT to str.
Replace left(ID, 1)<>'"W" to !ID.beg("W")
#5
Thanks again, the QM code is successful!
#6
I had another question, I want to use the function of sydt.dll to capture pic in Specific coordinate range,but it show unknown member , any advice?
or I can use the function of QM to do the same thing?

Code:
Copy      Help
str pic=sydt.CaptureJpg(0,0,200,200,location,50)

I use the function , but it need I manually control the coordination and capture, any advice?

Macro Macro3
Code:
Copy      Help
;capture image from screen
str sTempFile.expandpath("$temp$\qm_image.bmp")
if(!CaptureImageOrColor(0 32 0 sTempFile)) ret
#7
1.Do you use type library? If yes, do you see the function when you type . after variable name (sydt.)?

2. Please read CaptureImageOrColor help. You'll find other similar function.
#8
Thanks, I find the similar function from QM help.
about question 1, I just use the code that I post all in previous post.
#9
Try with type library. To insert type library declaration in macro, use "Type Libraries" dialog, it's in Tools menu.
#10
I insert sydt.dll to type library declaration.
It shows as below, I can't see the CaptureJpg and Send function.

SYDTLib

--- Coclasses ---
sydtdll

--- Interfaces ---
Isydtdll


But, the Send function can run successful

Macro 代答功能
Code:
Copy      Help
str ID = sydt.send(s1, location)
#11
If send is lowercase, maybe capturejpg also is lowercase.

When you insert typelib line, compile the macro. Then declare a variable like in the example below, and type . (dot) after it. Then you can see a list of functions.

typelib LibName {...} ...
LibName.ClassName var
var.
#12
Wow, thank you and taught me a good way.
Smile


Forum Jump:


Users browsing this thread: 2 Guest(s)