Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by hrolsons
at 2024-07-19 13:43:56
Point:500 Replies:2 POST_ID:829030USER_ID:11661
Topic:
Visual Basic Programming;;
So I have the following function that works great:
Public Sub ShellAndWait(ByVal program_name As String, _ Optional ByVal window_style As VbAppWinStyle = vbNormalFocus, _ Optional ByVal max_wait_seconds As Long = 0) Dim lngProcessId As Long Dim lngProcessHandle As Long Dim datStartTime As Date Dim lngCursor As Long Const WAIT_TIMEOUT = &H102 Const SYNCHRONIZE As Long = &H100000 Const INFINITE As Long = &HFFFFFFFF lngCursor = Screen.MousePointer 'Screen.'MousePointer = vbHourglass ' Start the program. On Error GoTo ShellError lngProcessId = Shell(program_name, window_style) On Error GoTo 0 DoEvents ' Wait for the program to finish. ' Get the process handle. lngProcessHandle = OpenProcess(SYNCHRONIZE, 0, lngProcessId) If lngProcessHandle <> 0 Then datStartTime = Now Do If WaitForSingleObject(lngProcessHandle, 250) <> WAIT_TIMEOUT Then Exit Do End If DoEvents If max_wait_seconds > 0 Then If DateDiff("s", datStartTime, Now) > max_wait_seconds Then Exit Do End If Loop CloseHandle lngProcessHandle End If Screen.MousePointer = lngCursor Exit SubShellError:End Sub 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:
I would like to change it so that it does the same thing but doesn't wait for the process to finish. I still want it to finish, but in the background.
Any ideas?
Accepted Solution
Expert: JamesBurger replied at 2024-07-20 04:38:32
250 points EXCELLENT
Simply call Shell alone instead of calling ShellAndWait:
Shell(program_name, window_style)
Shell(program_name, window_style)
Assisted Solution
Expert: duncanb7 replied at 2024-07-20 03:06:32
250 points EXCELLENT
At this link, http://www.cpearson.com/excel/ShellAndWait.aspx
it mentions you can use Shell function to do command and don't wait for the command complete. Is Shell function what your want. The ShellAndWait function is target to improve Shell function to wait the command finish before go to next step
Actually, you can use Shell function that can be programmed to wait or not wait for comand complete , you can find it at Wait option from MS manual at http://msdn.microsoft.com/en-us/library/xe736fyk(v=vs.90).aspx
Hope understand your question. If not , please point it out
Duncan
it mentions you can use Shell function to do command and don't wait for the command complete. Is Shell function what your want. The ShellAndWait function is target to improve Shell function to wait the command finish before go to next step
Actually, you can use Shell function that can be programmed to wait or not wait for comand complete , you can find it at Wait option from MS manual at http://msdn.microsoft.com/en-us/library/xe736fyk(v=vs.90).aspx
Hope understand your question. If not , please point it out
Duncan