JmZ 0 Posted April 18, 2010 How can i create a .url shortcut with au3? FileCreateShortcut cannot help me with a .url shortcut. Thanks Share this post Link to post Share on other sites
MHz 80 Posted April 18, 2010 Some COM code may help you. ; Example of creating a Url shortcut If _WshUrlShortcut(@DesktopDir & '\AutoIt3.url', 'http://www.autoitscript.com/autoit3') Then MsgBox(0, @ScriptName, 'Url shortcut created') EndIf Exit Func _WshUrlShortcut($sFilePath, $sUrl) ; Creates a Url shortcut Local $oUrlLink, $oWshShell $oWshShell = ObjCreate("WScript.Shell") If Not @error Then $oUrlLink = $oWshShell.CreateShortcut($sFilePath) If IsObj($oUrlLink) Then $oUrlLink.TargetPath = $sUrl $oUrlLink.Save If FileExists($sFilePath) Then Return True EndIf EndIf EndIf EndFunc Share this post Link to post Share on other sites
JmZ 0 Posted April 18, 2010 can we just use functions in au3 without com? Share this post Link to post Share on other sites
JmZ 0 Posted April 18, 2010 (edited) Some COM code may help you. ; Example of creating a Url shortcut If _WshUrlShortcut(@DesktopDir & '\AutoIt3.url', 'http://www.autoitscript.com/autoit3') Then MsgBox(0, @ScriptName, 'Url shortcut created') EndIf Exit Func _WshUrlShortcut($sFilePath, $sUrl) ; Creates a Url shortcut Local $oUrlLink, $oWshShell $oWshShell = ObjCreate("WScript.Shell") If Not @error Then $oUrlLink = $oWshShell.CreateShortcut($sFilePath) If IsObj($oUrlLink) Then $oUrlLink.TargetPath = $sUrl $oUrlLink.Save If FileExists($sFilePath) Then Return True EndIf EndIf EndIf EndFunc Thank you for the code! But, how to set "icon" and "hotkey" for .url ? I think maybe by this ? $oUrlLink.IconLocation = $sIcon & "," & $iIndex $oUrlLink.Hotkey = $sHotkey Edited April 18, 2010 by JmZ Share this post Link to post Share on other sites
MHz 80 Posted April 18, 2010 Thank you for the code! But, how to set "icon" and "hotkey" for .url ? I think maybe by this ? Seems as MSDN shows. I searched as you did not like the idea of COM. So, the below is what I come up with. _URLCreateShortcut('http://www.google.com/') Func _URLCreateShortcut($url, $iconindex = 0, $iconfile = '') $h_write = FileOpen('test1.url', 33); unicode write If $h_write <> -1 Then FileWrite($h_write, _ '[InternetShortcut]' & @CRLF & _ 'URL=' & $url & @CRLF & _ 'IconIndex=' & $iconindex & @CRLF & _ 'IconFile=' & $iconfile _ ) FileClose($h_write) Return True Else Return False EndIf EndFunc I did not find hotkey info, though more searching, perhaps local creation may reap results. Just view URL files by dropping on notepad to see contents. Share this post Link to post Share on other sites
JmZ 0 Posted April 18, 2010 Seems as MSDN shows. I searched as you did not like the idea of COM. So, the below is what I come up with. _URLCreateShortcut('http://www.google.com/') Func _URLCreateShortcut($url, $iconindex = 0, $iconfile = '') $h_write = FileOpen('test1.url', 33); unicode write If $h_write <> -1 Then FileWrite($h_write, _ '[InternetShortcut]' & @CRLF & _ 'URL=' & $url & @CRLF & _ 'IconIndex=' & $iconindex & @CRLF & _ 'IconFile=' & $iconfile _ ) FileClose($h_write) Return True Else Return False EndIf EndFunc I did not find hotkey info, though more searching, perhaps local creation may reap results. Just view URL files by dropping on notepad to see contents. Or just by IniWrite we can create .url easily... Thank you very much for your help! Share this post Link to post Share on other sites
picea892 6 Posted April 18, 2010 This link may also interest you Share this post Link to post Share on other sites