Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 6.36 KB | None | 0 0
  1. #NoTrayIcon
  2. #include <GUIConstants.au3>
  3. #include <ButtonConstants.au3>
  4. #include <GUIConstantsEx.au3>
  5. #include <GUIListBox.au3>
  6. #include <StaticConstants.au3>
  7. #include <WindowsConstants.au3>
  8. #include <Array.au3>
  9.  
  10. global $DefaultDir="H:\Home"
  11. If FileExists($DefaultDir) =0 Then
  12.     global $DefaultDir="C:"
  13. EndIf
  14. $shortcuts=IniReadSection($DefaultDir&"\settings.ini","links")
  15. If not IsArray($shortcuts) Then
  16.     If MsgBox(1,"Error",$DefaultDir&"\settings.ini nicht gefunden. Soll eine erstellt werden?") = 2 Then
  17.         Exit
  18.     EndIf
  19.     Do
  20.     $linkpath=FileOpenDialog("Choose Application",$DefaultDir,"Executables (*.exe)",3)
  21.     If @error=0 Then
  22.         $linkexe=StringSplit($linkpath,"\")
  23.         $i = 0
  24.         While $i = 0
  25.             $linkname=Inputbox("Name Shortcut"," ",$linkexe[$linkexe[0]],"",1,1)
  26.             If @error=0 Then               
  27.                 If $linkname="" Then
  28.                     MsgBox(0,"Error","Gib einen Namen ein.")
  29.                 Else
  30.                     $i=1
  31.                 EndIf
  32.             EndIf
  33.         WEnd
  34.         IniWrite($DefaultDir&"\settings.ini","links",$linkpath,$linkname)
  35.     EndIf
  36.     Until MsgBox(4,"Erfolg!","App hinzugefügt! Wars das?") = 6
  37.     $shortcuts=IniReadSection($DefaultDir&"\settings.ini","links")
  38. EndIf
  39. Local $button[$shortcuts[0][0]+1]
  40. Local $lenght = 0
  41. For $i = 1 to $shortcuts[0][0] Step 1
  42.     If StringLen($shortcuts[$i][1]) > $lenght then $lenght = StringLen($shortcuts[$i][1])
  43. Next   
  44. $Gui=GUICreate("4ppz", 28+7*$lenght, 18*$shortcuts[0][0]+23, -1, -1,-1,0x00000080+0x00000008)
  45. For $i=1 to $shortcuts[0][0] Step 1        
  46.     $button[$i]=GUICtrlCreateButton($shortcuts[$i][1], 24, 18*$i-14, 4+7*$lenght,16)
  47.     GUICtrlCreateIcon($shortcuts[$i][0],-1,4,18*$i-14,16,16)
  48. Next
  49. $button_edit=GUICtrlCreateButton("Bearbeiten...",4,$shortcuts[0][0]*18+4,24+7*$lenght,16)
  50. HotKeySet("!{F1}","gui")
  51. If $CmdLineRaw = "edited" then
  52.     ToolTip("Einstellungen übernommen.")
  53. Else
  54.     ToolTip("4ppz erfolgreich gestartet! Hotkey: Alt+F1")
  55. EndIf
  56. sleep(3000)
  57. ToolTip("")
  58.  
  59. While 1
  60.     sleep(1000)
  61. WEnd
  62.  
  63. Func gui()
  64.     ToolTip("")
  65.     $winy = MouseGetpos(1)
  66.     $winx = MouseGetpos(0)
  67.     If (@DesktopHeight-18*($shortcuts[0][0]+1)-22-MouseGetpos(1)) < 0 Then $winy = @DesktopHeight-18*($shortcuts[0][0]+1)-22
  68.     If (@DesktopWidth-110-MouseGetpos(0)) < 0 Then $winx = @DesktopWidth-110
  69.     WinMove($GUI,"",$winx,$winy)
  70.     GUISetState(@SW_SHOW)
  71.     Do
  72.         $msg = GUIGetMsg()
  73.         For $i=1 to $shortcuts[0][0] Step 1
  74.             if $msg = $button[$i] then
  75.                 ShellExecute($shortcuts[$i][0])
  76.                 $msg = 1
  77.             endif
  78.         Next
  79.         If $msg = $button_edit then            
  80.             GUISetState(@SW_HIDE)
  81.             edit()
  82.             $msg = 1
  83.         EndIf
  84.         If WinActive($Gui) = 0 then $msg = 1
  85.     Until $msg = $GUI_EVENT_CLOSE or $msg = 1
  86.     GUISetState(@SW_HIDE)
  87. EndFunc
  88.  
  89. Func edit()
  90.     Local $pos
  91.     $gui_edit = GUICreate("Appz - Edit", 251, 193)
  92.     $Group1 = GUICtrlCreateGroup("Appz", 8, 8, 233, 145)
  93.     $list_appz = GUICtrlCreateList("", 16, 24, 169, 123,BitOr(0x1,0x200000,0x800000))
  94.     Local $shortcutnames[$shortcuts[0][0]+1]
  95.     $shortcutnames[0] = $shortcuts[0][0]
  96.     For $i= 1 to $shortcuts[0][0] Step 1
  97.         $shortcutnames[$i] = $shortcuts[$i][1]
  98.     Next
  99.     GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
  100.     $button_up = GUICtrlCreateButton("Up", 192, 24, 41, 25, $WS_GROUP)
  101.     $button_down = GUICtrlCreateButton("Down", 192, 56, 41, 25, $WS_GROUP)
  102.     $button_add = GUICtrlCreateButton("Add", 192, 88, 41, 25, $WS_GROUP)
  103.     $button_delete = GUICtrlCreateButton("Delete", 192, 120, 41, 25, $WS_GROUP)
  104.     GUICtrlCreateGroup("", -99, -99, 1, 1)
  105.     $button_ok = GUICtrlCreateButton("OK", 48, 160, 65, 25, $WS_GROUP)
  106.     $button_cancel = GUICtrlCreateButton("Abbrechen", 128, 160, 65, 25, $WS_GROUP)
  107.     GUISetState(@SW_SHOW)
  108.     Do
  109.         $msg_edit = GUIGetMsg()
  110.         Switch $msg_edit
  111.             Case $button_ok
  112.                 If (UBound($shortcuts)-1)>$shortcuts[0][0] then Redim $shortcuts[$shortcuts[0][0]+1][2]
  113.                 IniWriteSection($Defaultdir&"\settings.ini","links",$shortcuts)
  114.                 ShellExecute(@Scriptfullpath,"edited")
  115.                 Exit
  116.             Case $button_add               
  117.                 Local $linkpath=FileOpenDialog("Choose Application",$DefaultDir,"Executables (*.exe)",3)
  118.                 If @error=0 Then
  119.                     Local $linkexe=StringSplit($linkpath,"\")
  120.                     $i = 0
  121.                     While $i = 0
  122.                         Local $linkname=Inputbox("Name Shortcut"," ",$linkexe[$linkexe[0]],"",1,1)
  123.                         If @error=0 Then               
  124.                             If $linkname="" Then
  125.                                 MsgBox(0,"Error","Gib einen Namen ein.")
  126.                             Else
  127.                                 $i=1
  128.                             EndIf
  129.                         EndIf
  130.                     WEnd   
  131.                     If (UBound($shortcuts)-2)<$shortcuts[0][0] then ReDim $shortcuts[$shortcuts[0][0]+2][2]
  132.                     $shortcuts[$shortcuts[0][0]+1][0] = $linkpath              
  133.                     $shortcuts[$shortcuts[0][0]+1][1] = $linkname
  134.                     $shortcuts[0][0] = $shortcuts[0][0]+1
  135.                     If (UBound($shortcutnames)-2)<$shortcutnames[0] then ReDim $shortcutnames[$shortcutnames[0]+2]
  136.                     $shortcutnames[$shortcutnames[0]+1] = $linkname
  137.                     $shortcutnames[0] = $shortcutnames[0]+1
  138.                     GUICtrlSetData($list_appz, "")
  139.                     GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
  140.                 EndIf
  141.             Case $button_delete
  142.                 $pos = _arraysearch($shortcutnames,GuiCtrlRead($list_appz),1)
  143.                 If $shortcutnames[0] > 1 Then
  144.                     _ArrayDelete($shortcutnames,$pos)
  145.                     $shortcutnames[0] = $shortcutnames[0]-1
  146.                     For $i = $pos to ($shortcuts[0][0]-1) Step 1
  147.                         $shortcuts[$i][0] = $shortcuts[$i+1][0]
  148.                         $shortcuts[$i][1] = $shortcuts[$i+1][1]
  149.                     Next
  150.                     $shortcuts[0][0] = $shortcuts[0][0]-1
  151.                     GUICtrlSetData($list_appz, "")
  152.                     GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))        
  153.                 EndIf
  154.             Case $button_up
  155.                 $pos = _arraysearch($shortcutnames,GuiCtrlRead($list_appz),1)
  156.                 If $pos > 1 Then
  157.                     _ArraySwap($shortcutnames[$pos],$shortcutnames[$pos-1])
  158.                     _ArraySwap($shortcuts[$pos][0],$shortcuts[$pos-1][0])
  159.                     _ArraySwap($shortcuts[$pos][1],$shortcuts[$pos-1][1])
  160.                     GUICtrlSetData($list_appz, "")
  161.                     GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
  162.                     _GUICtrlListBox_ClickItem($list_appz,$pos-2)
  163.                 EndIf              
  164.             Case $button_down
  165.                 $pos = _arraysearch($shortcutnames,GuiCtrlRead($list_appz),1)
  166.                 If $pos < $shortcutnames[0] Then
  167.                     _ArraySwap($shortcutnames[$pos],$shortcutnames[$pos+1])
  168.                     _ArraySwap($shortcuts[$pos][0],$shortcuts[$pos+1][0])
  169.                     _ArraySwap($shortcuts[$pos][1],$shortcuts[$pos+1][1])
  170.                     GUICtrlSetData($list_appz, "")                 
  171.                     GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
  172.                     _GUICtrlListBox_ClickItem($list_appz,$pos)
  173.                 EndIf  
  174.         EndSwitch
  175.     Until $msg_edit = $GUI_EVENT_CLOSE or $msg_edit = $button_cancel
  176.     GuiDelete($Gui_edit)
  177. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement