El-Arabi Posted March 4, 2012 Share Posted March 4, 2012 (edited) S.a arkadaşlar bir konuda yardımınıza ihtiyacım var ben fazla autoit den anlamam ama şu kadar kodladım yardım etmenizi bekliyorum [code]#include <File.au3> #include <Array.au3> If Not $CmdLine[0] = 0 Then For $i = 1 To $CmdLine[0] Local $szDrive, $szDir, $szFName, $szExt Local $TestPath =_PathSplit($CmdLine[$i],$szDrive, $szDir,$szFName, $szExt) Local $Targetpath = $TestPath[1] & $TestPath[2] & $TestPath[3] & $TestPath[4] Local $aDetails = FileGetShortcut(@StartupDir & $Targetpath) If FileExists(@TempDir & "\text.txt") Then FileDelete(@TempDir & "\text.txt") FileWrite(@TempDir & "\text.txt",$aDetails[0]) Else FileWrite(@TempDir & "\text.txt",$aDetails[0]) EndIf Next endif [/code] Şimdi ben bu kodlarla örnegin projem startup.exe olsun ben startup.exe /avira.lnk diye çalıştırdıgımda bu kodlar bana temp de text.txt ye o kısayolun tam dosya yolunu yazdırmasını istiyorum.Fakat getshortcut komutunda hata yaptım galiba olmadı bir türlü. Edited March 4, 2012 by El-Arabi Quote Link to comment Share on other sites More sharing options...
Mehmet Posted March 5, 2012 Share Posted March 5, 2012 tam anlamadım ne demek istediğini ama belki bu örnek sana yardımcı olur [codebox] FileCreateShortcut(@WindowsDir & "\explorer.exe", @DesktopDir & _ "\txt.lnk", @WindowsDir, "/e,c:\", "Açıklama", @SystemDir & "\shell32.dll", "^!t", "70", @SW_MINIMIZE) Local $aDetails = FileGetShortcut(@DesktopDir & "\txt.lnk") If Not @error Then FileWrite(@DesktopDir & "\text.txt", "Path: " & $aDetails[0] & @CRLF & _ "Working directory: " & $aDetails[1] & @CRLF & _ "Arguments: " & $aDetails[2] & @CRLF & _ "Description: " & $aDetails[3] & @CRLF & _ "Icon filename: " & $aDetails[4] & @CRLF & _ "Icon index: " & $aDetails[5] & @CRLF & _ "Shortcut state: " & $aDetails[6] & @CRLF) EndIf [/codebox] Quote Link to comment Share on other sites More sharing options...
El-Arabi Posted March 5, 2012 Author Share Posted March 5, 2012 Demek istediğim şuydu mesela ben bir exe oluşturacagım adı x olsun.Ben bunu x.exe /Avira.lnk diye çalıştırdıgımda bu exe otomatik olarak başlangıç klasöründeki aviranın kısayolunu alıp tam adresini yazdıracak.YUkarıdaki verdiğim kodlarla oluyor ama bir kere çalışıyor. Quote Link to comment Share on other sites More sharing options...
MostWanted Posted March 5, 2012 Share Posted March 5, 2012 Bir kere çalışıyor derken?Zaten bi tane komut yolluyosun onu yazıyo kapatıyor kendini.Eğer söylemek istediğin şey yazıyor fakat önceki yazılanları siliyor diyorsan küçük bir örneğim var. [code]Global Const $FO_OVERWRITE = 2 If Not $CmdLine[0] = 0 Then For $i = 1 To $CmdLine[0] Local $szDrive, $szDir, $szFName, $szExt Local $TestPath =_PathSplit($CmdLine[$i],$szDrive, $szDir,$szFName, $szExt) Local $Targetpath = $TestPath[1] & $TestPath[2] & $TestPath[3] & $TestPath[4] Local $aDetails = FileGetShortcut(@StartupDir & $Targetpath) __FileWriteToLine(@TempDir & "\text.txt", "deneme") Next endif Func __FileWriteToLine($sFile, $sText, $fOverWrite = 0) If Not IsString($sText) Then $sText = String($sText) If $sText = "" Then Return SetError(6, 0, 0) EndIf If $fOverWrite <> 0 And $fOverWrite <> 1 Then Return SetError(5, 0, 0) If Not FileExists($sFile) Then Return SetError(2, 0, 0) Local $sRead_File = FileRead($sFile) Local $aSplit_File = StringSplit(StringStripCR($sRead_File), @LF) Local $iEncoding = FileGetEncoding($sFile) Local $hFile = FileOpen($sFile, $iEncoding + $FO_OVERWRITE) If $hFile = -1 Then Return SetError(3, 0, 0) $sRead_File = "" For $i = 1 To $aSplit_File[0] $sRead_File &= $aSplit_File[$i] & @CRLF Next $sRead_File &= $sText FileWrite($hFile, $sRead_File) FileClose($hFile) Return 1 EndFunc ;==>_FileWriteToLine Func _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt) ; Set local strings to null (We use local strings in case one of the arguments is the same variable) Local $drive = "" Local $dir = "" Local $fname = "" Local $ext = "" Local $pos ; Create an array which will be filled and returned later Local $array[5] $array[0] = $szPath; $szPath can get destroyed, so it needs set now ; Get drive letter if present (Can be a UNC server) If StringMid($szPath, 2, 1) = ":" Then $drive = StringLeft($szPath, 2) $szPath = StringTrimLeft($szPath, 2) ElseIf StringLeft($szPath, 2) = "\\" Then $szPath = StringTrimLeft($szPath, 2) ; Trim the \\ $pos = StringInStr($szPath, "\") If $pos = 0 Then $pos = StringInStr($szPath, "/") If $pos = 0 Then $drive = "\\" & $szPath; Prepend the \\ we stripped earlier $szPath = ""; Set to null because the whole path was just the UNC server name Else $drive = "\\" & StringLeft($szPath, $pos - 1) ; Prepend the \\ we stripped earlier $szPath = StringTrimLeft($szPath, $pos - 1) EndIf EndIf ; Set the directory and file name if present Local $nPosForward = StringInStr($szPath, "/", 0, -1) Local $nPosBackward = StringInStr($szPath, "\", 0, -1) If $nPosForward >= $nPosBackward Then $pos = $nPosForward Else $pos = $nPosBackward EndIf $dir = StringLeft($szPath, $pos) $fname = StringRight($szPath, StringLen($szPath) - $pos) ; If $szDir wasn't set, then the whole path must just be a file, so set the filename If StringLen($dir) = 0 Then $fname = $szPath $pos = StringInStr($fname, ".", 0, -1) If $pos Then $ext = StringRight($fname, StringLen($fname) - ($pos - 1)) $fname = StringLeft($fname, $pos - 1) EndIf ; Set the strings and array to what we found $szDrive = $drive $szDir = $dir $szFName = $fname $szExt = $ext $array[1] = $drive $array[2] = $dir $array[3] = $fname $array[4] = $ext Return $array EndFunc ;==>_PathSplit [/code] Kodların uzun olduğuna bakma sadece kütüphaneleri eklemektense fonksiyonları aldım.Kolay gelsin. Quote Link to comment Share on other sites More sharing options...
El-Arabi Posted March 5, 2012 Author Share Posted March 5, 2012 Mostwanted yardım ettiğin için çok sagol yine olmadı durumu tekrar açıklayayım.Başlangıç klasörüne attığım bir kısayol var Gears Of War.lnk diye ben Autoit ile yaptıgım exeyi örn: x.exe /Gears Of War.lnk şeklinde cmd ekranında çalıştırdıgımda program bunu zaten @StartupDir kodu ile startupda buluyor fakat bunun alındıgı kısayolun tamyolu lazım.Yani ben şu şekilde çalıştırdığımda x.exe /Gears Of War.lnk bana tempte text.txt ye C:\Program Files\Gears Of War\gears.exe şeklinde yazdırsın istiyorum benim kodlar birkere çalışıyor dedim şöyle yani yaptıgım exe ilk başta çalışıyor sıkıntı yok ama bir kaç kez kullandıktan sonra artık hiçbirini algılamıyor.O yüzden birkere çalışıyor dedim.Valla yardım edersen çok makbule geçecek. Quote Link to comment Share on other sites More sharing options...
El-Arabi Posted March 5, 2012 Author Share Posted March 5, 2012 İlgilenen ilgilenmeyen herkeze teşekkürler farklı birşekilde çözdüm olayı.bir dll sayesinde. Quote Link to comment Share on other sites More sharing options...
MostWanted Posted March 5, 2012 Share Posted March 5, 2012 [code]Global Const $FO_OVERWRITE = 2 If Not $CmdLine[0] = 0 Then For $i = 1 To $CmdLine[0] $filename=$CmdLine[$i] Local $aDetails = FileGetShortcut(@StartupDir & "\" &$filename) if not @error Then __FileWriteToLine(@DesktopDir & "\text.txt", $aDetails[0]) EndIf Next endif Func __FileWriteToLine($sFile, $sText, $fOverWrite = 0) If Not IsString($sText) Then $sText = String($sText) If $sText = "" Then Return SetError(6, 0, 0) EndIf If $fOverWrite <> 0 And $fOverWrite <> 1 Then Return SetError(5, 0, 0) If Not FileExists($sFile) Then Return FileWrite($sFile, "") Local $sRead_File = FileRead($sFile) Local $aSplit_File = StringSplit(StringStripCR($sRead_File), @LF) Local $iEncoding = FileGetEncoding($sFile) Local $hFile = FileOpen($sFile, $iEncoding + $FO_OVERWRITE) If $hFile = -1 Then Return SetError(3, 0, 0) $sRead_File = "" For $i = 1 To $aSplit_File[0] $sRead_File &= $aSplit_File[$i] & @CRLF Next $sRead_File &= $sText FileWrite($hFile, $sRead_File) FileClose($hFile) Return 1 EndFunc ;==>_FileWriteToLine[/code] Kodu yazayım da elimde kalmasın bari.Başkaları bakar Quote Link to comment Share on other sites More sharing options...
El-Arabi Posted March 5, 2012 Author Share Posted March 5, 2012 Allah razı olsun kardeşim yardım ettiğin için sagolasın. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.