|
-
Nov 3rd, 2005, 07:52 AM
#1
Thread Starter
Hyperactive Member
SendKeys.SendWait
I am trying to sendkeys.sendwait("%FO"), but for some reason it will not send these keys or it sends them but will not wait. I need to make this macro for a program that doesn't have an activeX handle, so it has to be shelled in order to put it as the active window when sendkeys shoots off.
VB Code:
shell("MyProgramToSendKeysTo")
Wait(12) 'my own wait command that works
SendKeys.SendWait("%FO")
-
Nov 4th, 2005, 07:27 AM
#2
Thread Starter
Hyperactive Member
Re: SendKeys.SendWait
Bump, I could still use some help on this problem.
Thanks!
Taco
-
Nov 4th, 2005, 07:41 AM
#3
Member
Re: SendKeys.SendWait
This will send keys ALT+F followed by O (without ALT). Are these the keys you want to send to the active application ?
-
Nov 4th, 2005, 08:45 AM
#4
Thread Starter
Hyperactive Member
Re: SendKeys.SendWait
I need to send ALT, then F, then O.
Basically a macro to Save from the filemenu. Dan't ask, it's for my company program I am working on.
Thanks for the reply!
Taco
-
Nov 4th, 2005, 02:47 PM
#5
Frenzied Member
Re: SendKeys.SendWait
This is just a small guess, but if the secondary program isn't the active window, then the send keys command would be applied to your app.
~Peter

-
Nov 4th, 2005, 04:15 PM
#6
Thread Starter
Hyperactive Member
Re: SendKeys.SendWait
That is understood, but the 2nd app IS the active app. I can check again but if it isn't, how would I go about making it the active window without using a getobject commend? It doesn't seem to have a handle I can grab and processes class doesn't have the option to make a process z-order 0.
Thanks.
Taco
-
Nov 4th, 2005, 04:21 PM
#7
Lively Member
Re: SendKeys.SendWait
VB Code:
Shell("target.bat", AppWinStyle.NormalFocus, True)
The last true make the rest of the code wait until the program is "finished". Whether that means that the program closes or if it finishes starting up I'm not sure.
This is in VS .NET 2005.
-
Nov 4th, 2005, 06:37 PM
#8
Frenzied Member
Re: SendKeys.SendWait
thought about using API functions? Find the handle of the window, then send a WM_COMMAND(this basically sends a filemenu command). You may have to use spy++ to find out what the id number of the "Save" menu. But then again, if your not familiar with using API functions, then ignore this message.
-
Nov 4th, 2005, 07:00 PM
#9
Frenzied Member
Re: SendKeys.SendWait
however, if all you need is to make the other app the active window, use this code:
VB Code:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function BringWindowToTop Lib "user32" Alias "BringWindowToTop" (ByVal hwnd As Integer) As Integer
Dim hwnd As Integer
hwnd = FindWindow(vbNullString, "put name of the title bar of app here")
BringWindowToTop(hwnd)
just remember though, the app you want to make as the active window must not be currently minimized. It only works if its behind in the background.
Last edited by benmartin101; Nov 4th, 2005 at 07:06 PM.
-
Nov 5th, 2005, 02:09 AM
#10
Re: SendKeys.SendWait
Send a message is always going to be safer than using SendKeys. In fact, I'd go so far as to say, never use SendKeys at all. It is a lousy, quick+dirty method of accomplishing something that should be done the "proper" way, with window messages (i.e. SendMessage).
-
Nov 5th, 2005, 12:09 PM
#11
Thread Starter
Hyperactive Member
Re: SendKeys.SendWait
In VS 2005, How do I get a list of the API calls like in VB6? I would like to research more on this sending messages to the program.
Thanks to all who reply!!
Taco
-
Nov 5th, 2005, 03:58 PM
#12
Re: SendKeys.SendWait
API calls are platform-dependent, so they're the same for each language. Use MSDN 
Just remember to type HWND's as IntPtr's and that what you would make Long's in VB6 you make Integer's in VB.NET.
VB Code:
Imports System.Runtime.InteropServices
<DLLImport("user32"> _
Private Shared Function SendMessageW ( _
hWnd As IntPtr, _
uMsg As Integer, _
wParam As IntPtr, _
lParam As IntPtr _
) As IntPtr: End Function
Last edited by penagate; Nov 5th, 2005 at 04:01 PM.
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
|