argumentum Posted Monday at 04:57 PM Posted Monday at 04:57 PM (edited) In _WinAPI_GetStartupInfo() one gets the data from $tagSTARTUPINFO ( in <WinAPISys.au3> ) and the structure is at https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfow typedef struct _STARTUPINFOW { DWORD cb; LPWSTR lpReserved; LPWSTR lpDesktop; LPWSTR lpTitle; DWORD dwX; DWORD dwY; DWORD dwXSize; DWORD dwYSize; DWORD dwXCountChars; DWORD dwYCountChars; DWORD dwFillAttribute; DWORD dwFlags; WORD wShowWindow; WORD cbReserved2; LPBYTE lpReserved2; HANDLE hStdInput; HANDLE hStdOutput; HANDLE hStdError; } STARTUPINFOW, *LPSTARTUPINFOW; I'd like to read the "LPWSTR lpTitle;" but don't know how to read the string from the pointer. Help. Quote STARTF_TITLEISLINKNAME 0x00000800 The lpTitle member contains the path of the shortcut file (.lnk) that the user invoked to start this process. This is typically set by the shell when a .lnk file pointing to the launched application is invoked. Most applications will not need to set this value. This flag cannot be used with STARTF_TITLEISAPPID. This description above is what am after. I'd like to know if my script loaded from a .lnk or not. Edited Monday at 05:05 PM by argumentum more Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Solution Nine Posted Monday at 05:11 PM Solution Posted Monday at 05:11 PM #include <WinAPISys.au3> Local $tInfo = _WinAPI_GetStartupInfo ( ) $tString = DllStructCreate("wchar str[256]", $tInfo.title) ConsoleWrite($tString.str & @CRLF) argumentum 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
UEZ Posted Monday at 05:13 PM Posted Monday at 05:13 PM (edited) Try: #include <WinAPISys.au3> $t = _WinAPI_GetStartupInfo() $tP = DllStructCreate("wchar title[255]", $t.Title) ConsoleWrite($tP.title & @CRLF) I was too slow... Edited Monday at 05:14 PM by UEZ argumentum and Nine 1 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
argumentum Posted Monday at 05:15 PM Author Posted Monday at 05:15 PM Thank you both Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted Monday at 05:17 PM Author Posted Monday at 05:17 PM ... since _WinAPI_GetStartupInfo() don't have an example, would any of you make a decent one ? Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted Monday at 05:22 PM Author Posted Monday at 05:22 PM (edited) expandcollapse popup#include <WinAPISys.au3> #include <WinAPIShellEx.au3> #include <WinAPIMisc.au3> Global $g_ScriptLnk = StringTrimRight(@ScriptFullPath, 4) & " (script) - Shortcut.lnk" Global $g_ScriptIco = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1)) & "Icons\au3.ico" TraySetIcon($g_ScriptIco) If Not IsFromLNK() Then _WinAPI_SetCurrentProcessExplicitAppUserModelID(@ScriptName & '-' & TimerInit()) EnsureScriptLnk() ; this will create the shortcut.lnk for you in the same folder MsgBox(262144, @ScriptName, "was loaded from link ??? " & IsFromLNK(), 5) ; #FUNCTION# ==================================================================================================================== ; Name...........: IsFromLNK ; Description....: Determine if the current application was launched from a shortcut (.lnk file). ; Syntax.........: IsFromLNK() ; Parameters.....: None ; Return values .: Success: Returns 1 if the application was launched from a .lnk shortcut, otherwise returns 0. ; Failure: ; @error = 1: An error occurred retrieving startup information. ; @error = 2: The title string could not be retrieved. ; Author ........: ; Modified ......: ; Remarks .......: This function uses the _WinAPI_GetStartupInfo and _WinAPI_GetString functions to determine if the application was launched from a shortcut. ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/index.php?showtopic=212920&view=findpost&p=1543594 ; Example .......: If IsFromLNK() Then MsgBox(0, "Information", "This script was launched from an .lnk shortcut.") ; =============================================================================================================================== Func IsFromLNK() Local $tInfo = _WinAPI_GetStartupInfo() If @error Then Return SetError(1, 0, -1) Local $sTitle = _WinAPI_GetString($tInfo.title) If @error Then Return SetError(2, 0, -2) Return Int(StringRight($sTitle, 4) = ".lnk") EndFunc ;==>IsFromLNK Func CreateScriptLnk($sLinkFileName = $g_ScriptLnk, $sFileDescription = "My awesome script", $sIcon = $g_ScriptIco) If Not FileCreateShortcut(@AutoItExe, $sLinkFileName, @ScriptDir, '/AutoIt3ExecuteScript "' & _ @ScriptFullPath & '"', $sFileDescription, $sIcon) Then ConsoleWrite('FileCreateShortcut FAILED' & @CRLF) Return SetError(1, 0, 1) EndIf FileCopy($sLinkFileName, StringTrimRight($sLinkFileName, 4) & " - Copy.lnk") ; so you can play with that and see the implicit CurrentProcessExplicitAppUserModelID EndFunc ;==>CreateScriptLnk Func EnsureScriptLnk($sLinkFileName = $g_ScriptLnk) ConsoleWrite('EnsureScriptLnk("' & $sLinkFileName & '")' & @CRLF) Local $aDetails = FileGetShortcut($sLinkFileName) If Not @error And $aDetails[0] = @AutoItExe Then ConsoleWrite('EnsureScriptLnk, All good.' & @CRLF) Return 0 EndIf ConsoleWrite('EnsureScriptLnk() FAILED, calling CreateScriptLnk()' & @CRLF) Local $vRet = CreateScriptLnk($sLinkFileName) ConsoleWrite('CreateScriptLnk() returned val,error,extended = ' & $vRet & ',' & @error & ',' & @extended & @CRLF) Return SetError(@error, @extended, $vRet) EndFunc ;==>EnsureScriptLnk Edited Wednesday at 12:33 AM by argumentum better Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
KaFu Posted Monday at 06:05 PM Posted Monday at 06:05 PM Or this way. #include <WinAPISys.au3> Local $tInfo = _WinAPI_GetStartupInfo() ConsoleWrite(_WinAPI_GetString($tInfo.title) & @CRLF) argumentum 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now