Starting .exe...
-
Hello, how can i start another app from my application? After this i like to call the F4 Button? Thanks in advance, Mark
-
Hello, how can i start another app from my application? After this i like to call the F4 Button? Thanks in advance, Mark
The simplest way is to use
ShellExecute()
.ShellExecute(NULL, NULL, _T("myprog.exe"), NULL, SW_SHOWNORMAL);
Look at the docs on
ShellExecute()
to find out what the parameters do and how to use them. To find out whether it is successful or not,ShellExecute()
returns a value >32 if it is successful, and <=32 if it is not. Hope this helps, Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact" -
Hello, how can i start another app from my application? After this i like to call the F4 Button? Thanks in advance, Mark
macmac38 wrote: how can i start another app from my application?
BOOL CreateProcess(
LPCTSTR lpApplicationName,
// pointer to name of executable module
LPTSTR lpCommandLine, // pointer to command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // process security attributes
LPSECURITY_ATTRIBUTES lpThreadAttributes, // thread security attributes
BOOL bInheritHandles, // handle inheritance flag
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // pointer to new environment block
LPCTSTR lpCurrentDirectory, // pointer to current directory name
LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO
LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION
);macmac38 wrote: After this i like to call the F4 Button? You want to call the F4 button? I'm not sure what you mean... You can kill the process using the
TerminateProcess
function (you got the handle from CreateProcess). If you want to simulate a press to F4 you can use theSendInput
orkeybd_event
functions. -Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) -
macmac38 wrote: how can i start another app from my application?
BOOL CreateProcess(
LPCTSTR lpApplicationName,
// pointer to name of executable module
LPTSTR lpCommandLine, // pointer to command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // process security attributes
LPSECURITY_ATTRIBUTES lpThreadAttributes, // thread security attributes
BOOL bInheritHandles, // handle inheritance flag
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // pointer to new environment block
LPCTSTR lpCurrentDirectory, // pointer to current directory name
LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO
LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION
);macmac38 wrote: After this i like to call the F4 Button? You want to call the F4 button? I'm not sure what you mean... You can kill the process using the
TerminateProcess
function (you got the handle from CreateProcess). If you want to simulate a press to F4 you can use theSendInput
orkeybd_event
functions. -Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;)Yep, i can call the .exe now when i press a button in my app. What i like to do is to simulate the pressing of F4 after this. Because this starts a macro in the opened .exe. I cannot understand the help for these functions you gave me and do not know which code to use for F4(Hardwareadress, number..???) Do u have a code snip? Thanks, Mark
-
Yep, i can call the .exe now when i press a button in my app. What i like to do is to simulate the pressing of F4 after this. Because this starts a macro in the opened .exe. I cannot understand the help for these functions you gave me and do not know which code to use for F4(Hardwareadress, number..???) Do u have a code snip? Thanks, Mark
-
SendMessage(wndOfStartedApp, WM_KEYDOWN, VK_F4, 0);
The first parameter is the HWND of the app you just started. Instead of WM_KEYDOWN you might also try WM_KEYUP. -
It is normal: the HWND defines which window will receive the message, then if you send the KeyPress to a null window... you should start your app, then find the window of that app and after that send the message there... I think that you can also do it better, and in order to do so, you should take a look at CreateProcess(...). hope this helps.
-
It is normal: the HWND defines which window will receive the message, then if you send the KeyPress to a null window... you should start your app, then find the window of that app and after that send the message there... I think that you can also do it better, and in order to do so, you should take a look at CreateProcess(...). hope this helps.
-
But how can i find the window of that app? It is a commercial one. By the way i think i have to wait till the app is up before i send the message there? Thanks, Mark
If you launch it by using the CreateProcess api, one of the parameters is a PROCESS_INFORMATION structure. This gets filled in with the THREAD HANDLE of the primary thread for the newly lauched app. After the CreateProcess call returns, wait for the app to initialize by calling WaitForInputIdle(). When this returns, then you should be able to simulate a keystroke with the PostThreadMessage api, passing the new app's main thread handle as the parameter. Good Luck! onwards and upwards...