Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: AutoIt  |  size: 5.19 KB  |  views: 61  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Opt("MustDeclareVars", 1)
  2. #Include <File.au3>
  3.  
  4. ;~ Définition de la HotKey
  5. Dim $myHotKey = "{Esc}"
  6.  
  7. ;~ Variables globales
  8.  
  9. GLOBAL Const $GUI_EVENT_CLOSE = -3
  10. Global Const $GUI_EVENT_MINIMIZE = -4
  11. Global Const $GUI_EVENT_RESTORE = -5
  12. Global Const $GUI_EVENT_MAXIMIZE = -6
  13. Global Const $GUI_EVENT_PRIMARYDOWN = -7
  14. Global Const $GUI_EVENT_PRIMARYUP = -8
  15. Global Const $GUI_EVENT_SECONDARYDOWN = -9
  16. Global Const $GUI_EVENT_SECONDARYUP = -10
  17. Global Const $GUI_EVENT_MOUSEMOVE = -11
  18. Global Const $GUI_EVENT_RESIZED = -12
  19. Global Const $GUI_EVENT_DROPPED = -13
  20. Global Const $GUI_RUNDEFMSG = "GUI_RUNDEFMSG"
  21. Global Const $GUI_AVISTOP = 0
  22. Global Const $GUI_AVISTART = 1
  23. Global Const $GUI_AVICLOSE = 2
  24. Global Const $GUI_CHECKED = 1
  25. Global Const $GUI_INDETERMINATE = 2
  26. Global Const $GUI_UNCHECKED = 4
  27. Global Const $GUI_DROPACCEPTED = 8
  28. Global Const $GUI_NODROPACCEPTED = 4096
  29. Global Const $GUI_ACCEPTFILES = $GUI_DROPACCEPTED
  30. Global Const $GUI_SHOW = 16
  31. Global Const $GUI_HIDE = 32
  32. Global Const $GUI_ENABLE = 64
  33. Global Const $GUI_DISABLE = 128
  34. Global Const $GUI_FOCUS = 256
  35. Global Const $GUI_NOFOCUS = 8192
  36. Global Const $GUI_DEFBUTTON = 512
  37. Global Const $GUI_EXPAND = 1024
  38. Global Const $GUI_ONTOP = 2048
  39. Global Const $GUI_FONTITALIC = 2
  40. Global Const $GUI_FONTUNDER = 4
  41. Global Const $GUI_FONTSTRIKE = 8
  42. Global Const $GUI_DOCKAUTO = 1
  43. Global Const $GUI_DOCKLEFT = 2
  44. Global Const $GUI_DOCKRIGHT = 4
  45. Global Const $GUI_DOCKHCENTER = 8
  46. Global Const $GUI_DOCKTOP = 32
  47. Global Const $GUI_DOCKBOTTOM = 64
  48. Global Const $GUI_DOCKVCENTER = 128
  49. Global Const $GUI_DOCKWIDTH = 256
  50. Global Const $GUI_DOCKHEIGHT = 512
  51. Global Const $GUI_DOCKSIZE = 768
  52. Global Const $GUI_DOCKMENUBAR = 544
  53. Global Const $GUI_DOCKSTATEBAR = 576
  54. Global Const $GUI_DOCKALL = 802
  55. Global Const $GUI_DOCKBORDERS = 102
  56. Global Const $GUI_GR_CLOSE = 1
  57. Global Const $GUI_GR_LINE = 2
  58. Global Const $GUI_GR_BEZIER = 4
  59. Global Const $GUI_GR_MOVE = 6
  60. Global Const $GUI_GR_COLOR = 8
  61. Global Const $GUI_GR_RECT = 10
  62. Global Const $GUI_GR_ELLIPSE = 12
  63. Global Const $GUI_GR_PIE = 14
  64. Global Const $GUI_GR_DOT = 16
  65. Global Const $GUI_GR_PIXEL = 18
  66. Global Const $GUI_GR_HINT = 20
  67. Global Const $GUI_GR_REFRESH = 22
  68. Global Const $GUI_GR_PENSIZE = 24
  69. Global Const $GUI_GR_NOBKCOLOR = -2
  70. Global Const $GUI_BKCOLOR_DEFAULT = -1
  71. Global Const $GUI_BKCOLOR_TRANSPARENT = -2
  72. Global Const $GUI_BKCOLOR_LV_ALTERNATE = -33554432
  73. Global Const $GUI_WS_EX_PARENTDRAG = 1048576
  74.  
  75. ;~ Si on a des arguments, on passe en mode Lanceur
  76. If $CmdLine[0] > 1 Then
  77.  
  78.                 _LaunchExe()
  79.                
  80.         EndIf
  81.        
  82. ;~ Sinon sélection de la fenêtre dont on veut mémoriser les paramètres
  83.  
  84.  
  85. ;~  Variables locales du programme
  86. Dim $LABELPARENTWINDOW, $LABELACTIVEWNDTITLE, $LABELHOTKEY, $WNDTITLE, $WNDPOSITION, $LABELACTIVEWNDTITLE, $LABELACTIVEWNDPROPERTIES
  87.  
  88. ;~ Hotkey de création du raccourci
  89. HotKeySet ($myHotKey, "_SelectFile" )
  90.  
  91.  
  92. ;~  Fenêtre de sélection du programme et de création du raccourci
  93. Opt("GUIOnEventMode", 1)
  94. $LABELPARENTWINDOW = GUICreate("Sélectionnez l'application", 200, 50)
  95. $LABELACTIVEWNDTITLE = GUICtrlCreateLabel("Titre de la fenêtre", 0, 0, 400)
  96. $LABELACTIVEWNDPROPERTIES = GUICtrlCreateLabel("Propriétés", 0, 15, 400)
  97. $LABELHOTKEY = GUICtrlCreateLabel("Hotkey", 0, 30, 400)
  98. GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
  99. GUISetState(@SW_SHOW)
  100. WinSetOnTop($LABELPARENTWINDOW, "", 1)
  101. While 1
  102.         Sleep(200)
  103.         $WNDPOSITION = WinGetPos("")
  104.         $WNDTITLE = WinGetTitle("")
  105.         GUICtrlSetData($LABELACTIVEWNDPROPERTIES, $WNDPOSITION[0] & "," & $WNDPOSITION[1] & " - " & $WNDPOSITION[2] & "x" & $WNDPOSITION[3] )
  106.         GUICtrlSetData($LABELACTIVEWNDTITLE, $WNDTITLE)
  107.         GUICtrlSetData($LABELHOTKEY, "Hotkey : " & $myHotKey)
  108. WEnd
  109.  
  110. Func CLOSE()
  111.         Exit
  112. EndFunc
  113.  
  114. Func _SelectFile()
  115.         Local $message, $selectedFile
  116.        
  117.         $message = "Sélectionnez l'exécutable ou le raccourci de ce programme."
  118.  
  119.         $selectedFile = FileOpenDialog($message, @DesktopDir & "\", "All (*.*)", 1 )
  120.  
  121.         If @error Then
  122.                 MsgBox(4096,"","Aucun fichier n'a été sélectionné")
  123.         Else
  124.                 _CreateShortCut($selectedFile)
  125.         EndIf
  126.  
  127. EndFunc
  128.  
  129.  
  130. Func _CreateShortCut($filename)
  131.         If Not FileExists($filename) Then
  132.                 Return
  133.         EndIf
  134.        
  135.         Local $szDrive, $szDir, $szFName, $szExt, $shortcutproperties
  136.        
  137.         _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)
  138.        
  139.  
  140.  
  141.         FileCreateShortcut ( @ScriptFullPath, @DesktopDir & "/" & $szFName & "-" & @ScriptName &  ".lnk", "","""" & $filename & """ " & """" & $WNDTITLE & """ " & $WNDPOSITION[0] & " " & $WNDPOSITION[1] & " " & $WNDPOSITION[2] & " " & $WNDPOSITION[3], "", $filename)
  142.                
  143.  
  144. EndFunc
  145.  
  146. Func _LaunchExe()
  147.         Opt("WinTextMatchMode", 2)
  148.  
  149.  
  150.         If $CmdLine[0] < 4 Then
  151.  
  152.                 MsgBox(4096, "Usage", "Usage : Launchapp programme.exe Titre positionX positionY [tailleX] [tailleY]", 10)
  153.                 Exit 0
  154.                
  155.         EndIf
  156.        
  157.        
  158.  
  159.         If FileExists($CmdLine[1]) Then
  160.                 Run($CmdLine[1])
  161.                
  162.                 Local $myHwnd
  163.                 $myHwnd = WinWaitActive($CmdLine[2])
  164.                
  165.                 Switch $CmdLine[0]
  166.                 Case 4
  167.                 WinMove($myHwnd, "", $CmdLine[3], $CmdLine[4])
  168.         Case 5
  169.                 WinMove($myHwnd, "", $CmdLine[3], $CmdLine[4],$CmdLine[5])
  170.         Case 6
  171.                 WinMove($myHwnd, "", $CmdLine[3], $CmdLine[4],$CmdLine[5],$CmdLine[6])
  172.         EndSwitch
  173.                        
  174.         Else
  175.                 MsgBox(4096,"Erreur", "Impossible de trouver " & $CmdLine[1])
  176.                 Exit 0
  177.         EndIf
  178.        
  179.         Exit 0
  180.        
  181. EndFunc
clone this paste RAW Paste Data