|
-
Mar 28th, 2001, 10:59 AM
#1
Thread Starter
Junior Member
Here is my code for this program I have made when run it opens another external .exe in shell and sends keystrokes to it. This works in Windows 98 and Windows ME, but my beta tester that was on Windows 2000 got this error: Run-Time error '6' overflow
Code:
Private Sub Command1_Click()
End 'closes me
End Sub
Private Sub Form_Load()
Dim ID
ID = Shell("bin/setup2.pif", vbHide) 'opens dos app setup2.exe in bin folder
Timer1.Enabled = True 'begins timer 1
Timer2.Enabled = True 'begins timer 2
End Sub
Private Sub Timer1_Timer()
AppActivate "Cleaner" ' Sets sendkey window to cleaner
SendKeys "{Tab}", True 'sends tab stroke
SendKeys "{Tab}", True 'sends tab stroke
SendKeys "{ }", True 'sends space stroke
SendKeys "{Tab}", True 'sends tab stoke
SendKeys "{Tab}", True 'sends tab stroke
SendKeys "{Tab}", True 'sends tab stroke
SendKeys "{ }", True 'sends space stroke
Timer1.Enabled = False 'disables timer 1 from looping
End Sub
Private Sub Timer2_Timer()
Dim ID
ID = Shell("bin/setup.exe", 1) 'opens setup.exe in bin folder
Timer2.Enabled = False 'disables timer 2 from looping
End Sub
Private Sub Form_Paint() 'tiles image1 on background of form1
Dim x As Integer, y As Integer
Dim ImgWidth As Integer
Dim ImgHeight As Integer
Dim FrmWidth As Integer
Dim FrmHeight As Integer
ImgWidth = Image1.Width
ImgHeight = Image1.Height
FrmWidth = Form1.Width
FrmHeight = Form1.Height
For x = 0 To FrmWidth Step ImgWidth
For y = 0 To FrmHeight Step ImgHeight
PaintPicture Image1, x, y
Next y
Next x
End Sub
What is causing this to happen? The appactivate? Send keys?
He said that my form opens up and that setup2.exe does execute once its open and the 'sendkeys' should occur he gets that error. What can be done?
Plat
-
Mar 28th, 2001, 12:24 PM
#2
I don't know what the problem is, but shouldn't your path Shell statements be Shell("bin\setup.exe", 1)? As for where it's happening, you can put in msgbox statements in your routines and narrow in on the error by noting which messages you get to.
BTW, why are you shelling from a Timer?
-
Mar 28th, 2001, 12:40 PM
#3
Thread Starter
Junior Member
Originally posted by MartinLiss
I don't know what the problem is, but shouldn't your path Shell statements be Shell("bin\setup.exe", 1)?
Well i didnt realize that I had put a forward slash instead of a backslash. I switched them around and well it still works. I'll have to wait for my beta tester to get on to try it out. (not guessing that is the problem though).
I'll try ur message box technique and see if that can tell me where the problem is, but its hard cause im on 98 and it works fine for me. It's good to have a patient beta tester though
-
Mar 28th, 2001, 01:37 PM
#4
You might also consider doing away with the timers. They look like they execute only once, but if they get out of control you could wind up shelling over and over again, and, while I think that would cause "out of stack space" errors - who knows?
-
Mar 28th, 2001, 06:55 PM
#5
Thread Starter
Junior Member
The timers are the main workings of this project though.
This .pif program takes 3 seconds to load up after its called so I must sendkeys at exactly 3100 - 3500 in order for it to do its task properly. Unless of course I could figure out a way to sendkeys 'when app loaded' oer whatever, but im not sure how to go by doing that.
-
Mar 28th, 2001, 07:26 PM
#6
The speed of anything depends on the users PC so that could be a problem. Is the app a Windows app? If so then there are a number of ways to tell when it's loaded. (Probably also for DOS apps but I don't know.) One way is through the use of the GetWindowText API which looks for certain text in a window's title bar. If you want an example let me know. Another way (if you can modify the shelled app) is to simply have it create and write an "I am active" file after it's loaded and you loop looking for that file until it's found.
-
Mar 29th, 2001, 12:03 AM
#7
Thread Starter
Junior Member
Originally posted by MartinLiss
Is the app a Windows app? If so then there are a number of ways to tell when it's loaded. (Probably also for DOS apps but I don't know.) One way is through the use of the GetWindowText API which looks for certain text in a window's title bar. If you want an example let me know.
An example would be great!
I've looked around a bit but havent really gotten my hands on a good example.
thx
-
Mar 29th, 2001, 12:01 PM
#8
Thread Starter
Junior Member
I must salvage this from the 3rd page cause i still need help :c(
-
Mar 29th, 2001, 12:28 PM
#9
This will launch NotePad..and wait for it to load before sendkeys! Just change to your app...
Code:
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Const INFINITE = &HFFFF
Const STARTF_USESHOWWINDOW = &H1
Private Enum enSW
SW_HIDE = 0
SW_NORMAL = 1
SW_MAXIMIZE = 3
SW_MINIMIZE = 6
End Enum
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Enum enPriority_Class
NORMAL_PRIORITY_CLASS = &H20
IDLE_PRIORITY_CLASS = &H40
HIGH_PRIORITY_CLASS = &H80
End Enum
Private Function SuperShell(ByVal App As String, ByVal WorkDir As String, dwMilliseconds As Long, ByVal start_size As enSW, ByVal Priority_Class As enPriority_Class) As Boolean
Dim pclass As Long
Dim sinfo As STARTUPINFO
Dim pinfo As PROCESS_INFORMATION
Dim sec1 As SECURITY_ATTRIBUTES
Dim sec2 As SECURITY_ATTRIBUTES
sec1.nLength = Len(sec1)
sec2.nLength = Len(sec2)
sinfo.cb = Len(sinfo)
sinfo.dwFlags = STARTF_USESHOWWINDOW
sinfo.wShowWindow = start_size
pclass = Priority_Class
If CreateProcess(vbNullString, App, sec1, sec2, False, pclass, _
0&, WorkDir, sinfo, pinfo) Then
WaitForSingleObject pinfo.hProcess, dwMilliseconds
SuperShell = True
Else
SuperShell = False
End If
End Function
Private Sub Form_Load()
Me.Show
sFile = "C:\winnt\notepad.exe"
sDir = "C:\winnt\"
SuperShell sFile, sDir, 0, SW_NORMAL, HIGH_PRIORITY_CLASS
AppActivate "notepad"
SendKeys "Hello!"
End Sub
VBBrowser v2.2.1
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Mar 29th, 2001, 12:33 PM
#10
Lively Member
beside the subject
Private Sub Command1_Click()
End 'closes me
End Sub
You should really try to avoid End in you app.
Its a bit too abrubt for a program to close.
use:
Code:
Private Sub Command1_Click()
Unload me 'closes me
End Sub
It really closes all object and frees your memory...
Life is not a problem to solve, It's a reality to experience
-
Mar 29th, 2001, 12:36 PM
#11
Attached is the way I do it.
Last edited by MartinLiss; Apr 5th, 2011 at 03:07 PM.
-
Mar 29th, 2001, 12:42 PM
#12
Thread Starter
Junior Member
Doesnt want to work with the program I am trying to load. It's sending the keys before it shows up, giving me an error.
Well I mean, this code works great for me and I am on win98. It also works on winME.
So either appactivate or the sendkeys (i think) is giving win2000 the problem.
-
Mar 29th, 2001, 12:53 PM
#13
Thread Starter
Junior Member
Not working :c(
grrr
I see where your coming from Martin, but it doesnt want to send keys in the form_load command (where i need it)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|