| View previous topic :: View next topic |
| Author |
Message |
LiquidNeon Cheater
Reputation: 0
Joined: 26 Oct 2007 Posts: 32
|
Posted: Fri Jan 04, 2008 8:11 am Post subject: [VB6] Invalid procedure call or argument [Closed] |
|
|
My original idea was to execute a program then focusing on the particular program while this program sends keys that were set to the execute program.
However, I keep getting an error;
Runtime error '5'
Invalid procedure call or argument
Here's the code.
| Code: |
Private Sub execute_Click()
Shell "App Location", vbNormalFocus
End Sub
Private Sub Form_Load()
Label1.Caption = "Text"
Label2.Caption = "Text"
Label3.Caption = "Text"
Label4.Caption = "Text"
Label5.Caption = "Text"
Label6.Caption = "Text"
End Sub
Private Sub Timer1_Timer()
SendKeys "abc"
Timer1 = 10
End Sub
Private Sub stop_Click()
Timer1 = 0
End Sub
Private Sub start_Click()
AppActivate "App Name"
Timer1 = 1
End Sub
|
Help is very much appreciated.[/code]
Last edited by LiquidNeon on Fri Jan 04, 2008 9:14 am; edited 1 time in total |
|
| Back to top |
|
 |
Pseudo Xero I post too much
Reputation: 0
Joined: 16 Feb 2007 Posts: 2607
|
Posted: Fri Jan 04, 2008 8:21 am Post subject: Re: [VB6] Invalid procedure call or argument |
|
|
| LiquidNeon wrote: | My original idea was to execute a program then focusing on the particular program while this program sends keys that were set to the execute program.
However, I keep getting an error;
Runtime error '5'
Invalid procedure call or argument
Here's the code.
| Code: |
Private Sub execute_Click()
Shell "App Location", vbNormalFocus
End Sub
Private Sub Form_Load()
Label1.Caption = "Text"
Label2.Caption = "Text"
Label3.Caption = "Text"
Label4.Caption = "Text"
Label5.Caption = "Text"
Label6.Caption = "Text"
End Sub
Private Sub Timer1_Timer()
SendKeys "abc"
Timer1 = 10
End Sub
Private Sub stop_Click()
Timer1 = 0
End Sub
Private Sub start_Click()
AppActivate "App Name"
Timer1 = 1
End Sub
|
Help is very much appreciated.[/code] |
Where is the error?
|
|
| Back to top |
|
 |
Blader I post too much
Reputation: 2
Joined: 19 Jan 2007 Posts: 2049
|
Posted: Fri Jan 04, 2008 8:23 am Post subject: |
|
|
Is Timer1 a string or something?
Maybe it should be Timer1.Interval?
_________________
|
|
| Back to top |
|
 |
LiquidNeon Cheater
Reputation: 0
Joined: 26 Oct 2007 Posts: 32
|
Posted: Fri Jan 04, 2008 8:49 am Post subject: |
|
|
Timer1_Timer() is not a string.
@ Xeno - That's the thing. I don't know where the error is.
|
|
| Back to top |
|
 |
Blader I post too much
Reputation: 2
Joined: 19 Jan 2007 Posts: 2049
|
Posted: Fri Jan 04, 2008 8:50 am Post subject: |
|
|
I mean this:
Timer1 = 10
_________________
|
|
| Back to top |
|
 |
LiquidNeon Cheater
Reputation: 0
Joined: 26 Oct 2007 Posts: 32
|
Posted: Fri Jan 04, 2008 8:53 am Post subject: |
|
|
| @ Blader - I've tested it using a notepad and it does gives out any error. But, when I test it with a online game, it does.
|
|
| Back to top |
|
 |
Blader I post too much
Reputation: 2
Joined: 19 Jan 2007 Posts: 2049
|
Posted: Fri Jan 04, 2008 8:58 am Post subject: |
|
|
What are you trying to do with the timer?
I see you have:
| Code: | Timer1 = 10
Timer1 = 0
Timer1 = 1 |
Btw, do you mean it works for notepad, but not online games?
_________________
|
|
| Back to top |
|
 |
Pseudo Xero I post too much
Reputation: 0
Joined: 16 Feb 2007 Posts: 2607
|
Posted: Fri Jan 04, 2008 9:03 am Post subject: |
|
|
It should highlight the error, or show you where it is.
Did you purposely make the Shell execute string "AppLocation?"
|
|
| Back to top |
|
 |
Blader I post too much
Reputation: 2
Joined: 19 Jan 2007 Posts: 2049
|
Posted: Fri Jan 04, 2008 9:06 am Post subject: |
|
|
I compiled it, and it showed an error here:
| Code: | | AppActivate "App Name" |
I think you might have got the wrong application name, try checking it again
_________________
|
|
| Back to top |
|
 |
LiquidNeon Cheater
Reputation: 0
Joined: 26 Oct 2007 Posts: 32
|
Posted: Fri Jan 04, 2008 9:09 am Post subject: |
|
|
@ Xeno - It does not. And, yes.
Btw, I think its most probably the SendKeys thingy. Coz when I changed it to SendKeys "{Space}"
It gives out the similar error.
But, if I used the code as I've written in the first post, it doesn't.
So, do you have any suggestion on doing a -Space- using the sendkey function? Like {Space} or something else?
@ Blader - Still shows an error.
Nvm, I'll close this thread for a while now.
|
|
| Back to top |
|
 |
Pseudo Xero I post too much
Reputation: 0
Joined: 16 Feb 2007 Posts: 2607
|
Posted: Fri Jan 04, 2008 9:14 am Post subject: |
|
|
|
|
|
| Back to top |
|
 |
LiquidNeon Cheater
Reputation: 0
Joined: 26 Oct 2007 Posts: 32
|
Posted: Fri Jan 04, 2008 9:16 am Post subject: |
|
|
| But, how can you put in CTRL & Space in the same time?
|
|
| Back to top |
|
 |
Pseudo Xero I post too much
Reputation: 0
Joined: 16 Feb 2007 Posts: 2607
|
Posted: Fri Jan 04, 2008 9:19 am Post subject: |
|
|
| LiquidNeon wrote: | | But, how can you put in CTRL & Space in the same time? |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Jan 04, 2008 6:24 pm Post subject: |
|
|
I see a lot of issues with this code. Firstly, you have 'Timer1' as Blader pointed out. This will do nothing since you don't use it anywhere other then giving it a value. If you are trying to alter the interval of the timer, you need to use Timer1.Interval. If you are trying to do something else with the timer, please state what you are trying to do with it.
As for AppActivate, the syntax for it is:
| Quote: | | AppActivate( Title, [Wait]) |
Meaning the Title is required, and the wait time is optional. The wait time is the time to have the program 'pause' before pulling the program into focus. For example:
| Quote: | Private Sub Form_Load()
AppActivate "Untitled - Notepad", 5000
End Sub |
The reason for your error? AppActive raises an error if it fails. The error that is raised is invalid procedure call meaning the first param, the title, was invalid and not found. You can either add:
| Quote: | | On Error Resume Next |
Or add error handling to fail without crashing if this error arises.
_________________
- Retired. |
|
| Back to top |
|
 |
|