Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Operating Systems
»
Windows
»
How to launch a desktop shortcut for an application?
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
how to tweek fpmake to co...
by
paule32
[
Today
at 08:23:49 am]
splitting an image
by
paule32
[
Today
at 08:20:33 am]
Why isn't TTIRadioGroup's...
by
egsuh
[
Today
at 08:09:35 am]
FpDebug questions
by
440bx
[
Today
at 03:43:41 am]
Lazarus for Windows on aa...
by
Wallaby
[April 23, 2024, 11:46:56 pm]
Parameter passing odditie...
by
KodeZwerg
[April 23, 2024, 11:04:39 pm]
Can function be used for ...
by
jamie
[April 23, 2024, 10:53:10 pm]
(Solved) TIndexedAVLTree ...
by
lainz
[April 23, 2024, 10:49:03 pm]
Demo Scene Picture sinwav...
by
KodeZwerg
[April 23, 2024, 10:26:21 pm]
fkInternalCalc
by
zraja
[April 23, 2024, 09:31:07 pm]
A fairly simple sound sol...
by
KodeZwerg
[April 23, 2024, 09:23:37 pm]
add new targets to make
by
marcov
[April 23, 2024, 08:38:42 pm]
Quirky windows
by
ASerge
[April 23, 2024, 07:07:16 pm]
[Request] Demo Scene Sub ...
by
Gigatron
[April 23, 2024, 06:29:39 pm]
Unlocking Files
by
KodeZwerg
[April 23, 2024, 06:03:08 pm]
[SOLVED] trunk bug for mi...
by
Key-Real
[April 23, 2024, 05:56:32 pm]
Demo Scene Bitmap Font Sc...
by
Gigatron
[April 23, 2024, 05:56:27 pm]
Compile/Convert Delphi pr...
by
Martin_fr
[April 23, 2024, 05:43:11 pm]
Generics - correct syntax
by
Thaddy
[April 23, 2024, 05:40:59 pm]
InstallAware Using Lazaru...
by
msintle
[April 23, 2024, 05:26:36 pm]
Xcode Command Line Tools ...
by
Joseph
[April 23, 2024, 05:16:39 pm]
Offical launch of the 1 B...
by
Hartmut
[April 23, 2024, 04:49:29 pm]
what to do if my target M...
by
nickysn
[April 23, 2024, 04:16:02 pm]
compiler error in unit
by
paule32
[April 23, 2024, 03:49:50 pm]
Multithreading - synchron...
by
mika
[April 23, 2024, 01:48:51 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to launch a desktop shortcut for an application? (Read 1150 times)
Awesome Programmer
Sr. Member
Posts: 451
Programming is FUN only when it works :)
How to launch a desktop shortcut for an application?
«
on:
March 23, 2022, 07:14:01 am »
hey, I would like to know how you can programmatically click on a desktop shortcut for an application like say notepad.
I found a code that lets you create a desktop shortcut. I would like to know how you click on it or execute the shortcut.
Thanks.
«
Last Edit: March 27, 2022, 05:10:33 pm by Awesome Programmer
»
Logged
http://cool-technology.blogspot.com
dbannon
Hero Member
Posts: 2802
Re: How to click on a desktop shortcut for an application?
«
Reply #1 on:
March 23, 2022, 08:17:56 am »
Maybe it would make more sense to run eg notepad directly ?
https://wiki.freepascal.org/Executing_External_Programs
Davo
Logged
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project -
https://github.com/tomboy-notes/tomboy-ng
and my github -
https://github.com/davidbannon
marcov
Administrator
Hero Member
Posts: 11458
FPC developer.
Re: How to click on a desktop shortcut for an application?
«
Reply #2 on:
March 23, 2022, 09:20:59 am »
Execute over shellexecute()
Logged
RayoGlauco
Full Member
Posts: 179
Beers: 1567
Re: How to click on a desktop shortcut for an application?
«
Reply #3 on:
March 23, 2022, 11:21:38 am »
You can simulate a mouse clic as this example shows. But the previous answers are quite right.
Code: Pascal
[Select]
[+]
[-]
uses
JwaWinUser
procedure
MouseButtonDown
(
rightbutton
:
boolean
)
;
var
Input
:
TInput
;
begin
FillChar
(
Input
,
SizeOf
(
Input
)
,
0
)
;
Input
.
mi
.
mouseData
:
=
0
;
Input
.
mi
.
dx
:
=
0
;
Input
.
mi
.
dy
:
=
0
;
Input
.
type_
:
=
INPUT_MOUSE
;
if
rightbutton
then
Input
.
mi
.
dwFlags
:
=
MOUSEEVENTF_RIGHTDOWN
else
Input
.
mi
.
dwFlags
:
=
MOUSEEVENTF_LEFTDOWN
;
SendInput
(
1
,
@
Input
,
SizeOf
(
Input
)
)
;
procedure
MouseButtonUp
(
rightbutton
:
boolean
)
;
var
Input
:
TInput
;
begin
FillChar
(
Input
,
SizeOf
(
Input
)
,
0
)
;
Input
.
mi
.
mouseData
:
=
0
;
Input
.
mi
.
dx
:
=
0
;
Input
.
mi
.
dy
:
=
0
;
Input
.
type_
:
=
INPUT_MOUSE
;
if
rightbutton
then
Input
.
mi
.
dwFlags
:
=
MOUSEEVENTF_RIGHTUP
else
Input
.
mi
.
dwFlags
:
=
MOUSEEVENTF_LEFTUP
;
SendInput
(
1
,
@
Input
,
SizeOf
(
Input
)
)
;
end
;
procedure
SendMouseClick
(
rightbutton
:
boolean
)
;
begin
MouseButtonDown
(
rightbutton
)
;
sleep
(
30
)
;
MouseButtonUp
(
rightbutton
)
;
end
;
end
;
Logged
To err is human, but to really mess things up, you need a computer.
Awesome Programmer
Sr. Member
Posts: 451
Programming is FUN only when it works :)
Re: How to click on a desktop shortcut for an application?
«
Reply #4 on:
March 27, 2022, 05:04:17 pm »
Well, I might not have been more clear with my post... I want my program to be able to execute a desktop shortcut knowing what the name of the shortcut is. I am not trying to run Notepad... that was just an example...
I wrote a program that creates a shortcut for a program on the desktop and I want to execute or "run" that shortcut.
Thank you all for the reply.
Logged
http://cool-technology.blogspot.com
RayoGlauco
Full Member
Posts: 179
Beers: 1567
Re: How to launch a desktop shortcut for an application?
«
Reply #5 on:
March 27, 2022, 11:21:14 pm »
Take a look on this topic:
https://forum.lazarus.freepascal.org/index.php?topic=1709.0
Logged
To err is human, but to really mess things up, you need a computer.
Awesome Programmer
Sr. Member
Posts: 451
Programming is FUN only when it works :)
Re: How to launch a desktop shortcut for an application?
«
Reply #6 on:
March 30, 2022, 05:43:58 pm »
Quote from: RayoGlauco on March 27, 2022, 11:21:14 pm
Take a look on this topic:
https://forum.lazarus.freepascal.org/index.php?topic=1709.0
Thank you for your reply, but that question deals with creating a .ink shortcut. I already have a program that does. I want to be able to LAUNCH that .ink link I created from my program. How do you do that?
Logged
http://cool-technology.blogspot.com
AlexTP
Hero Member
Posts: 2406
Re: How to launch a desktop shortcut for an application?
«
Reply #7 on:
March 30, 2022, 05:50:28 pm »
Did you try this?
https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea
Logged
CudaText editor
-
ATSynEdit
-
More from me
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Operating Systems
»
Windows
»
How to launch a desktop shortcut for an application?
TinyPortal
© 2005-2018