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
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Klondike solitaire Part 2
by
TBMan
[
Today
at 04:16:40 pm]
Benchmark regular vs SIMD...
by
Thaddy
[
Today
at 04:14:01 pm]
Как правильно создать на ...
by
pmralbuquerque
[
Today
at 03:46:15 pm]
FPC Unleashed (inline var...
by
cdbc
[
Today
at 03:45:31 pm]
Cannot get FTP to work
by
rvk
[
Today
at 03:32:36 pm]
Problem with upgrading to...
by
wp
[
Today
at 03:15:03 pm]
How to wait until a WebDA...
by
Lutz Mändle
[
Today
at 02:44:10 pm]
Anubis's website security...
by
ALLIGATOR
[
Today
at 01:23:59 pm]
Anubis activated
by
rvk
[
Today
at 12:45:50 pm]
Can Lazarus support Auto-...
by
Martin_fr
[
Today
at 12:33:34 pm]
TFONT and related init ?
by
jamie
[
Today
at 12:17:36 pm]
ERROR: The current FPC ha...
by
Thaddy
[
Today
at 11:53:06 am]
Run code during DLL load
by
LemonParty
[
Today
at 11:48:20 am]
GocciaScript: JavaScript ...
by
Tomxe
[
Today
at 11:39:14 am]
text color visible
by
hedgehog
[
Today
at 10:36:48 am]
SYnEdit lose cursor
by
Martin_fr
[
Today
at 09:50:48 am]
Portable verion of FPC an...
by
marcov
[
Today
at 09:46:14 am]
P.I.S.S. a PlugIn-framewo...
by
cdbc
[
Today
at 09:41:18 am]
paszlib. Feature request ...
by
LemonParty
[
Today
at 08:09:37 am]
Death of the Power User
by
440bx
[
Today
at 05:47:41 am]
Linking a PortAudio stati...
by
bbrx
[May 20, 2026, 08:02:20 pm]
IDE Windows Centered
by
zeljko
[May 20, 2026, 01:51:37 pm]
QuotedStr
by
wp
[May 20, 2026, 12:52:30 pm]
LazNodeEditor (visual nod...
by
gidesa
[May 20, 2026, 12:36:09 pm]
TMemoryStream, manual mem...
by
marcov
[May 20, 2026, 12:16:31 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to launch a desktop shortcut for an application? (Read 1945 times)
Awesome Programmer
Sr. Member
Posts: 479
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: 3809
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: 12866
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: 227
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: 479
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: 227
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: 479
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: 2709
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