I am running a process in my GUI program that starts ffmpeg in a hidden cmd shell. I need to make it so when i press the STOP button on my GUI it sends a key stroke message to the cmd shell as if i pressed the "q" key which would tell ffmpeg to stop. I can`t use the Process.Kill() command because it messes up the file that ffmpeg is making.
I found some examples of sending messages to other windows made with VB6 : - Dim lNotepadHwnd As Long
-
Dim lNotepadEdit As Long
-
Dim sMsg As String = "q"
-
lNotepadHwnd = FindWindow("Notepad", vbNullString)
-
lNotepadEdit = FindWindowEx(lNotepadHwnd, 0&, "Edit", vbNullString)
-
SendMessageSTRING(lNotepadEdit, WM_SETTEXT, 256, sMsg)
I get the SendMessage and FindWindow is not declared error in my VB 2008 program. It looks more like C++ to me but, can someone tell me why I get this error or can someone show an example of how to send a message to a hidden cmd shell in VB 2008 ?
I can get as far as getting the handle of the process but i cant find what i need to send the message.
This is my Stop button code : - Private Sub Btn_Stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Stop.Click
-
Dim processHandle As Long = Process1.Handle
-
-
'What type of command do i need hear to send "q" key to hidden cmd shell ?
-
-
Btn_Stop.Enabled = False
-
Btn_Record.Enabled = True
-
UD_Minutes.Enabled = True
-
End Sub
-
2 3977 PsychoCoder 465
Recognized Expert Moderator Contributor
Check out the SendKeys Class, it may help you accomplish what you're looking for.
Also, moving to VB.NET forum so more VB.NET experts can see your question :)
First i would like to say Thanks For helping me. After checking out the link you gave, i stumbled onto a lot of stuff from there that helped me get a lot farther than i was. I now have the following that works if i have the Process running in a normal or minimized window state.
This is what i have added to get it to work so far: - Imports System.Runtime.InteropServices
-
-
Dim hWnd As IntPtr
-
-
<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", SetLastError:=True, CharSet:=CharSet.Auto)> Private Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As Long
-
End Function
-
-
Private Sub Btn_Record_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesBtn_Record.Click
-
Process1.Start()
-
End Sub
-
-
Private Sub Btn_Stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Stop.Click
-
hWnd = FindWindow(Nothing, Process1.MainWindowTitle)
-
SetForegroundWindow(hWnd)
-
SendKeys.Send("q")
-
End Sub
I would really like to have the Process running in a hidden window state. Is it possible to use SendMessage, PostMessage, or maybe SendInput to send a KeyDown and KeyUp to the Process if it is running in a hidden window state or is it just not possible?
PS. I realized yesterday that it was in the wrong VB Forum and tried re-posting it in VB.NET and it got removed. I will see if i can figure out how to move it.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: crowl |
last post by:
Hi all,
I'm looking for a simple c source sample which I can send message to
ICQ and MSN Messenger.
I have search with google, but without luck on my side. Do you know
any doc for programming icq or msn messenger?
Many thanks for your assistance.
|
by: Eka Gautama |
last post by:
Hi all,
Is it possible to intercept net send message? I don't want windows show the
message to screen directly, but i want process first, then display to the
screen...
Thanks
|
by: Jerry |
last post by:
Hi,
I send a message WM_HELP, but it return false. The code is:
Point point = new Point(e.X, e.Y);
Control child = GetChildAtPoint(point);
if (child != null) {
point = PointToScreen(point);
HELPINFO helpInfo = new HELPINFO();
helpInfo.iContextType = HELPINFO_WINDOW;
|
by: Raj |
last post by:
Hi,
I am trying to send message (WM_CLICK) to a button control in a
PowerBuilder application using a C# spy program. This works for all
other windows applications but in case of PB application it does not
work.
Would appreciate any help on this.
Thanks in advance
|
by: Ahmad Jalil Qarshi |
last post by:
Hi!
I want to develop two applications one a Windows Service and the other a GUI
based application. I want some sort of communication between Service and
GUI. I have decided to use Remoting for this purpose.
For this I registered an object on Service side for Remoting purposes.
Remote Object exposes a function named ReloadFiles() that should internally
send a message to service class to Reload some files. Now I don't know how
to send...
| |
by: ad |
last post by:
How can I send message to cellular phone by program?
|
by: napster |
last post by:
hi,
I am working on a project to control some pc activities from mobile but am not able to send a message from mobile to pc.I have tried the AT commands but its not working for me.Can anybody help and tell how to send message from mobile to PC.My paltform is VC++.NET
|
by: sauravpn |
last post by:
I am new to perl and I cant figure out how to write a perl script to send message to syslog wih facilty user
|
by: Balabhadra Kar |
last post by:
Hello
how can i send message to all mobile set using asp code .Please Help me.
thnak.s
|
by: anbu |
last post by:
there in one database and one table that have three field one is
name and another one is date
and last is email address
data are stored in following ways
name date email address
anbu 2008-03-26 something@gmail.com
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |