Asked by duncanb7
at 2024-10-08 22:58:37
Point:500 Replies:7 POST_ID:828374USER_ID:11059
Topic:
Microsoft Excel Spreadsheet Software;Java Programming Language;Visual Basic Programming
-My system is Windows Vista, IE7, Excel2003 VBA editior
-My target data download website is Java Applet application in IE and it need user to mouse click
to the download bar to show-up small Java popup dowload window and enter a key of enter to comfirm
for each file save
-My project is I try to connect one data website page to download 500 huge exmaple.csv files in VBA
by IE.navigate and mouse-click simulation in order to download all files automatically without any
real hand mouse click. The problem is I need to click download bar in the data website page and
after-clicking the small Java popup window will be shown up. The issue is the time of shown-up the small
popup windows will be a little longer and vary so I need to put longer waiting time to solve the issue like
put Sleep(3000) before sendkeys {"enter") to confirm each file save that will waste a lot of time for waiting if download 500 files
I would like to know how to find out the small Java popup window process ID or handler so if it is
possible, I might put code to detect the small popup window process is ready or not. Once ready, go
to sendkeys to confirm each file save that will reduce the waiting time. Please revise the following
attached code area for my main download VBA code , loadfile() subroutine which is using
Sleep(3000) for waiting.
I tried to use Window API method to replace Sleep() like bGetwindows() subroutine code below
to get the window title and check whether the popup window is ready or not but it always report
the first data webpage and not foreground windows information. I use debug.print to print
out mystr variable, it report title of " *****-WIndows Internet Explorer" and not the one I want
that is "Download Trans.Log" Please view the Two windows image and be reminded the small Java windows
is forground windows of data website paga or on the top of webiste page by click the download bar in first
website page. Please ignore the screen capture stamp.
Next Method I tried to use API FindWindowsEX() but I am not familar with part and I need to do
some tuturial at this site http://www.downloadfreescript.com/source-code-detail-text/find-window-tutorial-part1-a-must-see-by-paul-zaczkowski-in-miscellaneous-visual-basic.htm
The Question:
1-Any good methed to Replace code of Sleep(3000) to reduce the waiting time ?
2- At bGetWindow_Click(), why it will debug.print the background window title instead of forground window
even use GetforgroundWindow in the VBA code ? it seems always report the parent process title
instead of child process. How to find out child process title or id ?
3- I have checked by Task Manage in windows, both is in process, Is it true API function could not
solve any Java Window issue ?
4- [ANyone know how to get Java application/process/windows title or ID in VBA ?
Please advise
Ducan
*************************************bGetwindow_Click()********************************
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function GetForegroundWindow Lib "user32" () As Long
Private Sub bGetWindow_Click()
Dim MyStr As String, AHwnd As Long
tWinName = "waiting..."
Do
AHwnd = GetForegroundWindow
MyStr = String(GetWindowTextLength(AHwnd) + 1, Chr$(0))
'Get the window's text
GetWindowText AHwnd, MyStr, Len(MyStr)
debug.print mystr
Loop Until Left(MyStr, 18) = "Download Trans.Log"
tWinName = Mystr
End Sub
-My target data download website is Java Applet application in IE and it need user to mouse click
to the download bar to show-up small Java popup dowload window and enter a key of enter to comfirm
for each file save
-My project is I try to connect one data website page to download 500 huge exmaple.csv files in VBA
by IE.navigate and mouse-click simulation in order to download all files automatically without any
real hand mouse click. The problem is I need to click download bar in the data website page and
after-clicking the small Java popup window will be shown up. The issue is the time of shown-up the small
popup windows will be a little longer and vary so I need to put longer waiting time to solve the issue like
put Sleep(3000) before sendkeys {"enter") to confirm each file save that will waste a lot of time for waiting if download 500 files
I would like to know how to find out the small Java popup window process ID or handler so if it is
possible, I might put code to detect the small popup window process is ready or not. Once ready, go
to sendkeys to confirm each file save that will reduce the waiting time. Please revise the following
attached code area for my main download VBA code , loadfile() subroutine which is using
Sleep(3000) for waiting.
I tried to use Window API method to replace Sleep() like bGetwindows() subroutine code below
to get the window title and check whether the popup window is ready or not but it always report
the first data webpage and not foreground windows information. I use debug.print to print
out mystr variable, it report title of " *****-WIndows Internet Explorer" and not the one I want
that is "Download Trans.Log" Please view the Two windows image and be reminded the small Java windows
is forground windows of data website paga or on the top of webiste page by click the download bar in first
website page. Please ignore the screen capture stamp.
Next Method I tried to use API FindWindowsEX() but I am not familar with part and I need to do
some tuturial at this site http://www.downloadfreescript.com/source-code-detail-text/find-window-tutorial-part1-a-must-see-by-paul-zaczkowski-in-miscellaneous-visual-basic.htm
The Question:
1-Any good methed to Replace code of Sleep(3000) to reduce the waiting time ?
2- At bGetWindow_Click(), why it will debug.print the background window title instead of forground window
even use GetforgroundWindow in the VBA code ? it seems always report the parent process title
instead of child process. How to find out child process title or id ?
3- I have checked by Task Manage in windows, both is in process, Is it true API function could not
solve any Java Window issue ?
4- [ANyone know how to get Java application/process/windows title or ID in VBA ?
Please advise
Ducan
*************************************bGetwindow_Click()********************************
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function GetForegroundWindow Lib "user32" () As Long
Private Sub bGetWindow_Click()
Dim MyStr As String, AHwnd As Long
tWinName = "waiting..."
Do
AHwnd = GetForegroundWindow
MyStr = String(GetWindowTextLength(AHwnd) + 1, Chr$(0))
'Get the window's text
GetWindowText AHwnd, MyStr, Len(MyStr)
debug.print mystr
Loop Until Left(MyStr, 18) = "Download Trans.Log"
tWinName = Mystr
End Sub
Attachment:Snap2.bmp