SendKeys and SendMessage Using Skills Select Blog from Northwolves

xiaoxiao2021-03-06  111

Private Declare Function SendMessage Lib "user32.dll" Alias ​​"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function FindWindow Lib "user32.dll" Alias ​​"FindWindowA" ( ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias ​​"FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Function SQRX (BYVAL X As Double) AS String 'Calculates the square root (higher than VB Double type precision) DIM TEMP AS STRING, I as long, J AS Longshell "Calc.exe", VBMinimizednofocus' Run Calculator Temp = X & "Y0 .5 = "for i = 1 to LEN (TEMP) SendKeys MID (TEMP, I, 1), True 'Sequential to the calculator X (x ^ y) 0.5 = NextTemp = String (64, CHR (0) i = FindWindow (VBnullString, "Calculator") 'window handle J = FindWindowEx (i, byval 0 &, "edit", vbnullstring)' edit box handle SendMessage J, & HD, len (temp), ByVal Temp 'Send Edit box Text to TempsendKeys "% {f4}", True 'calls Alt F4 Close Calculator window SQRX = Tempend Function

PRIVATE SUB Command1_Click () DIM I as INTEGERFOR I = 17 to 24debug.print "SQRX (" & I & ") =" & SQRX (i) Nextend Sub

转载请注明原文地址:https://www.9cbs.com/read-101391.html

New Post(0)