简单问题了(对于我很难) 进者有分 答者必有重谢!!!!!!!!!!!!!!!!!!!!!!!!!

zcm123 2004-07-31 08:56:11
如何实现
用自己的程序控制另一个程序具备刷新(类似于按F5那样产生的效果)的功能?那个程序有一个快捷键f5是刷新的。

如何实现如何实现阿!!!!!!!!!





还有
http://community.csdn.net/Expert/topic/3221/3221750.xml?temp=.1629755
有没有更好的方法阿?
我用的是
将所有的内容提取,晒选小节的值,在将所有的内容写回去,又慢又麻烦。
拜托诸位了。





...全文
276 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
zcm123 2004-08-02
  • 打赏
  • 举报
回复
非常感谢
rainstormmaster


最终结决
Public Function S_servU() '/向目标窗体发送刷新消息
Dim test_hwnd As Long

test_hwnd = FindWindowEx(0, 0, "TAdminForm", vbNullString)

SetForegroundWindow test_hwnd

ShowWindow test_hwnd, SW_RESTORE

SendKeys "%VZ"
SendKeys "{F5}"

End Function
rainstormmaster 2004-08-01
  • 打赏
  • 举报
回复
加上一句SetForegroundWindow whwnd就可以了:
Option Explicit
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private 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
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Const SW_RESTORE = 9
Dim mhwnd() As Long

Private Sub Form_Load()
Dim MyStr As String
Dim i As Long
Dim test_hwnd As Long
i = 0
test_hwnd = FindWindowEx(0, 0, "TAdminForm", vbNullString)
Do While test_hwnd <> 0
ReDim Preserve mhwnd(i)
mhwnd(i) = test_hwnd
MyStr = String(100, Chr$(0))
GetWindowText test_hwnd, MyStr, 100
MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1)
List1.AddItem CStr(test_hwnd) + "-----" + MyStr
test_hwnd = FindWindowEx(0, test_hwnd, "TAdminForm", vbNullString)
i = i + 1
Loop
End Sub

Private Sub List1_Click() '刷新指定的serv-U窗口
Dim whwnd As Long
whwnd = mhwnd(List1.ListIndex)
SetForegroundWindow whwnd
ShowWindow whwnd, SW_RESTORE
SendKeys "{F5}"
End Sub
zcm123 2004-08-01
  • 打赏
  • 举报
回复
这款软件公司以前就有 您可以在www.baidu.com上查 可以查到
qhyan23 2004-07-31
  • 打赏
  • 举报
回复
厉害呀!收藏了.
rainstormmaster 2004-07-31
  • 打赏
  • 举报
回复
不知道你具体要刷新什么程序,下面我以刷新ie为例说明以下:
窗体:一个listbox
窗体代码:
Option Explicit
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private 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
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_RESTORE = 9
Dim mhwnd() As Long

Private Sub Form_Load()
Dim MyStr As String
Dim i As Long
Dim test_hwnd As Long
i = 0
test_hwnd = FindWindowEx(0, 0, "IEFrame", vbNullString)
Do While test_hwnd <> 0
ReDim Preserve mhwnd(i)
mhwnd(i) = test_hwnd
MyStr = String(100, Chr$(0))
GetWindowText test_hwnd, MyStr, 100
MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1)
List1.AddItem CStr(test_hwnd) + "-----" + MyStr
test_hwnd = FindWindowEx(0, test_hwnd, "IEFrame", vbNullString)
i = i + 1
Loop
End Sub

Private Sub List1_Click() '刷新指定的ie窗口
Dim whwnd As Long
whwnd = mhwnd(List1.ListIndex)
ShowWindow whwnd, SW_RESTORE
SendKeys "{F5}"
End Sub
zcm123 2004-07-31
  • 打赏
  • 举报
回复
-_-如何得到另一个程序的焦点阿。如何发送键盘消息阿
rainstormmaster 2004-07-31
  • 打赏
  • 举报
回复
//用自己的程序控制另一个程序具备刷新(类似于按F5那样产生的效果)的功能?那个程序有一个快捷键f5是刷新的。

先使另一个程序获得焦点,然后发送键盘消息(简单点的就用sendkeys)
whj668 2004-07-31
  • 打赏
  • 举报
回复
兄弟我是新手。可否告诉我怎末在这里提问阿。进了技术社区后。教我去小类社区。我不知道啊
rainstormmaster 2004-07-31
  • 打赏
  • 举报
回复
//为何针对serv_u 这款软件就不行呢

给个下载地址
zcm123 2004-07-31
  • 打赏
  • 举报
回复
为何针对serv_u 这款软件就不行呢????????????似乎无法获得焦点并刷新发送不过去?
ffyykk 2004-07-31
  • 打赏
  • 举报
回复
学习了
jiazhi 2004-07-31
  • 打赏
  • 举报
回复
收藏,学习,学习

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧