|
-
Jan 28th, 2008, 04:30 PM
#1
Thread Starter
Member
how to type the letter A with API
Hi i'm looking for a way to make a program type the letter A thank's to the api declaration and function
-
Jan 29th, 2008, 08:21 AM
#2
Re: how to type the letter A with API
I don't know of any spelling APIs. Why API?
-
Jan 29th, 2008, 10:15 AM
#3
Thread Starter
Member
Re: how to type the letter A with API
No problem
i've solved this problem yesterday by myself , may be that i haven't explained and developped my question .
What I wanted , is to simulate the letter A with the keyboard ; without typing it
The solution was with the function keybd_event
-
Jan 29th, 2008, 10:18 AM
#4
Re: how to type the letter A with API
You might be better off using findWindow and SendMessage as its not dependant upon the receiving app having the input focus. If the user minimizes or changes the apps focus then keybd_event will fail.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 29th, 2008, 10:21 AM
#5
Thread Starter
Member
Re: how to type the letter A with API
ok i will try this thank you my friend
-
Jan 29th, 2008, 10:28 AM
#6
Re: how to type the letter A with API
No prob. Just think of the keybd_event API as the same thing that SendKeys does.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 29th, 2008, 10:36 AM
#7
Thread Starter
Member
Re: how to type the letter A with API
just a question by the way , because i have a probleme with the findwindow first argument ,
let's say that i have 3 windows opened in my computer
1-MS WORD name : a
2-MS EXCEL name : b
3-NOTEPAD name : c
if i want to find the Notepad name :c
how to do that with the findwindow function
thank you
-
Jan 29th, 2008, 10:39 AM
#8
Re: how to type the letter A with API
lHwnd = FindWindow("notepad", "Untitled - Notepad")
But it will only work for a blank new notepad. If notepad contains a opened file then the window caption will be different.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 29th, 2008, 10:50 AM
#9
Thread Starter
Member
Re: how to type the letter A with API
ok and do you know how to focus on a window
for example : if i have MS WORD and Notepad open
and in the first plan i have NOTEPAD , do you know how to do to make MS WORD on the first plan instead of Notepad
thank you .
-
Jan 29th, 2008, 11:00 AM
#10
Re: how to type the letter A with API
You can use SetActiveWindow API.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 29th, 2008, 11:15 AM
#11
Thread Starter
Member
Re: how to type the letter A with API
my last question in sendmessage argument ; if i want to send to the
lHwnd = FindWindow("notepad", "Untitled - Notepad")
the sentence "hello world"
how can i do that with sendmessage
thank you very much for your help
-
Jan 29th, 2008, 11:30 AM
#12
Re: how to type the letter A with API
Just pass the window handle and the message constant. Then the last tow arguments will be "0&" and "A"
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 29th, 2008, 11:34 AM
#13
Thread Starter
Member
Re: how to type the letter A with API
yes but for the message constant
what is this constant if i have the message "hello world"
i mean i can't do sendmessage(hwnd,"hello world",0&,A)
-
Jan 29th, 2008, 11:35 AM
#14
Re: how to type the letter A with API
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 29th, 2008, 12:07 PM
#15
Thread Starter
Member
Re: how to type the letter A with API
i tried this but it doesn't work
Public Class Form1
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_SETTEXT As Long = &HC
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Const VK_M = &H4D
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nPad As Long
nPad = FindWindow("notepad", "essai") ' send to first notepad found.
Call SendMessageByString(nPad, WM_SETTEXT, 0, "hello world")
End Sub
End Class
-
Jan 29th, 2008, 12:14 PM
#16
Re: how to type the letter A with API
Oh of course not you are using VB.NET.
The APIs and code will all need changing. Hold on ...
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 29th, 2008, 12:31 PM
#17
Re: how to type the letter A with API
Here is a full working example. Note you will want to improve it with error handling and error prevention.
Code:
Option Explicit On
Option Strict On
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll", CharSet:=CharSet.Auto, EntryPoint:="SendMessage")> _
Private Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto, EntryPoint:="FindWindow")> _
Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto, EntryPoint:="FindWindowEx")> _
Private Shared Function FindWindowEx(ByVal hWnd1 As IntPtr, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
End Function
Private Const WM_SETTEXT As Integer = &HC
Private Const VK_M As Integer = &H4D
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nPad As IntPtr
Dim nPadChild As IntPtr
nPad = FindWindow("notepad", "Untitled - Notepad") ' send to first notepad found.
nPadChild = FindWindowEx(nPad, 0, "edit", String.Empty)
SendMessage(nPadChild, WM_SETTEXT, 0, "hello world")
End Sub
End Class
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 29th, 2008, 12:45 PM
#18
Thread Starter
Member
Re: how to type the letter A with API
Thank you for your help
and finally if i want to put notpad in the first plan
i made
SetActiveWindow(CLng(nPad))
should i add something before because it didn't work
-
Jan 29th, 2008, 01:02 PM
#19
Re: how to type the letter A with API
You need to use the .NET definition syntax for your APIs. If you dont have an API utility then download the one in my signature. API Viewer.
Code:
<DllImport("user32.dll", CharSet:=CharSet.Auto, EntryPoint:="SetActiveWindow")> _
Private Shared Function SetActiveWindow (ByVal hwnd As IntPtr) As IntPtr
End Function
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|