Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
how to get the process/application/popup windows/ status and its PID in VBA

and input enter keys to save each file. THe dowload popup window will show out after I use setcursorpoistion and leftdown method to click the button. But each show up time of download
popup window is long and different and could be not estimated, so I put sleep(1000) before a.sendkeys {"enter"} IS there any way to know the popup window/appication/process ID is ready or not before we
confirm next operation by sending "enter" keys in VBA so that I can reduce the time I put in Sleep()? Please reveiw my following code to see my question is how to replace sleep(1000) in my following VBA code for each run if we can know the process ID is ready ? FOr 500 files, it costs me 100*1000ms=100second for waiting time of download popup windows. Some people suggest me to us getcurrent processid in kernel, I tried it but I got syntax errror
Please advise
Code:
=====================================
Option Explicit
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
Const MOUSEEVENTF_leftDOWN = &H2
Const MOUSEEVENTF_leftUP = &H4
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
'**Win32 API User Defined Types
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Sub loadfile(filename As String)
Dim a, WScript As Object
Set a = CreateObject("WScript.shell")
Dim pt As POINTAPI
Do until filename=""
call downloadfiel(filename) ' There is no any issue
SetCursorPos Range("b4"), Range("c4") ' click download popup window
Sleep (30)
Call leftDown 'download popup window will come out
Sleep (1000) 'Problem is here, I need to put longer ide time such as 1000 or 2000 to solve the problem
a.SendKeys "{enter}" ' Confirm to save the files
call checkfilesaved(filename) 'There is no any issue
loop
End Sub
The pop download window is Java application because I have seen the Java logo at
left top corner. Is it possible using findwindow("File Download") to find window handler
to check whether the window is existed or not.
The syntax of findwindow("the name of windows I search") is possible or not ?
Please advise
Duncan
The pop download window is Java application because I have seen the Java logo at
left top corner. Is it possible using findwindow("File Download") to find window handler
to check whether the window is existed or not.
The syntax of findwindow("the name of windows I search") is possible or not ?
Please advise
Duncan
The pop download window is Java application because I have seen the Java logo at
left top corner. Is it possible using findwindow("File Download") to find window handler
to check whether the window is existed or not.
The syntax of findwindow("the name of windows I search") is possible or not ?
Please advise
Duncan
The pop download window is Java application because I have seen the Java logo at
left top corner. Is it possible using findwindow("File Download") to find window handler
to check whether the window is existed or not.
The syntax of findwindow("the name of windows I search") is possible or not ?
Please advise
Duncan
The pop download window is Java application because I have seen the Java logo at
left top corner. Is it possible using findwindow("File Download") to find window handler
to check whether the window is existed or not.
The syntax of findwindow("the name of windows I search") is possible or not ?
Please advise
Duncan
The pop download window is Java application because I have seen the Java logo at
left top corner. Is it possible using findwindow("File Download") to find window handler
to check whether the window is existed or not.
The syntax of findwindow("the name of windows I search") is possible or not ?
Please advise
Duncan
The pop download window is Java application because I have seen the Java logo at
left top corner. Is it possible using findwindow("File Download") to find window handler
to check whether the window is existed or not.
The syntax of findwindow("the name of windows I search") is possible or not ?
Please advise
Duncan
The pop download window is Java application because I have seen the Java logo at
left top corner. Is it possible using findwindow("File Download") to find window handler
to check whether the window is existed or not.
The syntax of findwindow("the name of windows I search") is possible or not ?
Please advise
Duncan