Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Opt("MustDeclareVars", 1)
- #Include <File.au3>
- ;~ Définition de la HotKey
- Dim $myHotKey = "{Esc}"
- ;~ Variables globales
- GLOBAL Const $GUI_EVENT_CLOSE = -3
- Global Const $GUI_EVENT_MINIMIZE = -4
- Global Const $GUI_EVENT_RESTORE = -5
- Global Const $GUI_EVENT_MAXIMIZE = -6
- Global Const $GUI_EVENT_PRIMARYDOWN = -7
- Global Const $GUI_EVENT_PRIMARYUP = -8
- Global Const $GUI_EVENT_SECONDARYDOWN = -9
- Global Const $GUI_EVENT_SECONDARYUP = -10
- Global Const $GUI_EVENT_MOUSEMOVE = -11
- Global Const $GUI_EVENT_RESIZED = -12
- Global Const $GUI_EVENT_DROPPED = -13
- Global Const $GUI_RUNDEFMSG = "GUI_RUNDEFMSG"
- Global Const $GUI_AVISTOP = 0
- Global Const $GUI_AVISTART = 1
- Global Const $GUI_AVICLOSE = 2
- Global Const $GUI_CHECKED = 1
- Global Const $GUI_INDETERMINATE = 2
- Global Const $GUI_UNCHECKED = 4
- Global Const $GUI_DROPACCEPTED = 8
- Global Const $GUI_NODROPACCEPTED = 4096
- Global Const $GUI_ACCEPTFILES = $GUI_DROPACCEPTED
- Global Const $GUI_SHOW = 16
- Global Const $GUI_HIDE = 32
- Global Const $GUI_ENABLE = 64
- Global Const $GUI_DISABLE = 128
- Global Const $GUI_FOCUS = 256
- Global Const $GUI_NOFOCUS = 8192
- Global Const $GUI_DEFBUTTON = 512
- Global Const $GUI_EXPAND = 1024
- Global Const $GUI_ONTOP = 2048
- Global Const $GUI_FONTITALIC = 2
- Global Const $GUI_FONTUNDER = 4
- Global Const $GUI_FONTSTRIKE = 8
- Global Const $GUI_DOCKAUTO = 1
- Global Const $GUI_DOCKLEFT = 2
- Global Const $GUI_DOCKRIGHT = 4
- Global Const $GUI_DOCKHCENTER = 8
- Global Const $GUI_DOCKTOP = 32
- Global Const $GUI_DOCKBOTTOM = 64
- Global Const $GUI_DOCKVCENTER = 128
- Global Const $GUI_DOCKWIDTH = 256
- Global Const $GUI_DOCKHEIGHT = 512
- Global Const $GUI_DOCKSIZE = 768
- Global Const $GUI_DOCKMENUBAR = 544
- Global Const $GUI_DOCKSTATEBAR = 576
- Global Const $GUI_DOCKALL = 802
- Global Const $GUI_DOCKBORDERS = 102
- Global Const $GUI_GR_CLOSE = 1
- Global Const $GUI_GR_LINE = 2
- Global Const $GUI_GR_BEZIER = 4
- Global Const $GUI_GR_MOVE = 6
- Global Const $GUI_GR_COLOR = 8
- Global Const $GUI_GR_RECT = 10
- Global Const $GUI_GR_ELLIPSE = 12
- Global Const $GUI_GR_PIE = 14
- Global Const $GUI_GR_DOT = 16
- Global Const $GUI_GR_PIXEL = 18
- Global Const $GUI_GR_HINT = 20
- Global Const $GUI_GR_REFRESH = 22
- Global Const $GUI_GR_PENSIZE = 24
- Global Const $GUI_GR_NOBKCOLOR = -2
- Global Const $GUI_BKCOLOR_DEFAULT = -1
- Global Const $GUI_BKCOLOR_TRANSPARENT = -2
- Global Const $GUI_BKCOLOR_LV_ALTERNATE = -33554432
- Global Const $GUI_WS_EX_PARENTDRAG = 1048576
- ;~ Si on a des arguments, on passe en mode Lanceur
- If $CmdLine[0] > 1 Then
- _LaunchExe()
- EndIf
- ;~ Sinon sélection de la fenêtre dont on veut mémoriser les paramètres
- ;~ Variables locales du programme
- Dim $LABELPARENTWINDOW, $LABELACTIVEWNDTITLE, $LABELHOTKEY, $WNDTITLE, $WNDPOSITION, $LABELACTIVEWNDTITLE, $LABELACTIVEWNDPROPERTIES
- ;~ Hotkey de création du raccourci
- HotKeySet ($myHotKey, "_SelectFile" )
- ;~ Fenêtre de sélection du programme et de création du raccourci
- Opt("GUIOnEventMode", 1)
- $LABELPARENTWINDOW = GUICreate("Sélectionnez l'application", 200, 50)
- $LABELACTIVEWNDTITLE = GUICtrlCreateLabel("Titre de la fenêtre", 0, 0, 400)
- $LABELACTIVEWNDPROPERTIES = GUICtrlCreateLabel("Propriétés", 0, 15, 400)
- $LABELHOTKEY = GUICtrlCreateLabel("Hotkey", 0, 30, 400)
- GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
- GUISetState(@SW_SHOW)
- WinSetOnTop($LABELPARENTWINDOW, "", 1)
- While 1
- Sleep(200)
- $WNDPOSITION = WinGetPos("")
- $WNDTITLE = WinGetTitle("")
- GUICtrlSetData($LABELACTIVEWNDPROPERTIES, $WNDPOSITION[0] & "," & $WNDPOSITION[1] & " - " & $WNDPOSITION[2] & "x" & $WNDPOSITION[3] )
- GUICtrlSetData($LABELACTIVEWNDTITLE, $WNDTITLE)
- GUICtrlSetData($LABELHOTKEY, "Hotkey : " & $myHotKey)
- WEnd
- Func CLOSE()
- Exit
- EndFunc
- Func _SelectFile()
- Local $message, $selectedFile
- $message = "Sélectionnez l'exécutable ou le raccourci de ce programme."
- $selectedFile = FileOpenDialog($message, @DesktopDir & "\", "All (*.*)", 1 )
- If @error Then
- MsgBox(4096,"","Aucun fichier n'a été sélectionné")
- Else
- _CreateShortCut($selectedFile)
- EndIf
- EndFunc
- Func _CreateShortCut($filename)
- If Not FileExists($filename) Then
- Return
- EndIf
- Local $szDrive, $szDir, $szFName, $szExt, $shortcutproperties
- _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)
- FileCreateShortcut ( @ScriptFullPath, @DesktopDir & "/" & $szFName & "-" & @ScriptName & ".lnk", "","""" & $filename & """ " & """" & $WNDTITLE & """ " & $WNDPOSITION[0] & " " & $WNDPOSITION[1] & " " & $WNDPOSITION[2] & " " & $WNDPOSITION[3], "", $filename)
- EndFunc
- Func _LaunchExe()
- Opt("WinTextMatchMode", 2)
- If $CmdLine[0] < 4 Then
- MsgBox(4096, "Usage", "Usage : Launchapp programme.exe Titre positionX positionY [tailleX] [tailleY]", 10)
- Exit 0
- EndIf
- If FileExists($CmdLine[1]) Then
- Run($CmdLine[1])
- Local $myHwnd
- $myHwnd = WinWaitActive($CmdLine[2])
- Switch $CmdLine[0]
- Case 4
- WinMove($myHwnd, "", $CmdLine[3], $CmdLine[4])
- Case 5
- WinMove($myHwnd, "", $CmdLine[3], $CmdLine[4],$CmdLine[5])
- Case 6
- WinMove($myHwnd, "", $CmdLine[3], $CmdLine[4],$CmdLine[5],$CmdLine[6])
- EndSwitch
- Else
- MsgBox(4096,"Erreur", "Impossible de trouver " & $CmdLine[1])
- Exit 0
- EndIf
- Exit 0
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement