Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- #include <GUIConstants.au3>
- #include <ButtonConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <GUIListBox.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- #include <Array.au3>
- global $DefaultDir="H:\Home"
- If FileExists($DefaultDir) =0 Then
- global $DefaultDir="C:"
- EndIf
- $shortcuts=IniReadSection($DefaultDir&"\settings.ini","links")
- If not IsArray($shortcuts) Then
- If MsgBox(1,"Error",$DefaultDir&"\settings.ini nicht gefunden. Soll eine erstellt werden?") = 2 Then
- Exit
- EndIf
- Do
- $linkpath=FileOpenDialog("Choose Application",$DefaultDir,"Executables (*.exe)",3)
- If @error=0 Then
- $linkexe=StringSplit($linkpath,"\")
- $i = 0
- While $i = 0
- $linkname=Inputbox("Name Shortcut"," ",$linkexe[$linkexe[0]],"",1,1)
- If @error=0 Then
- If $linkname="" Then
- MsgBox(0,"Error","Gib einen Namen ein.")
- Else
- $i=1
- EndIf
- EndIf
- WEnd
- IniWrite($DefaultDir&"\settings.ini","links",$linkpath,$linkname)
- EndIf
- Until MsgBox(4,"Erfolg!","App hinzugefügt! Wars das?") = 6
- $shortcuts=IniReadSection($DefaultDir&"\settings.ini","links")
- EndIf
- Local $button[$shortcuts[0][0]+1]
- Local $lenght = 0
- For $i = 1 to $shortcuts[0][0] Step 1
- If StringLen($shortcuts[$i][1]) > $lenght then $lenght = StringLen($shortcuts[$i][1])
- Next
- $Gui=GUICreate("4ppz", 28+7*$lenght, 18*$shortcuts[0][0]+23, -1, -1,-1,0x00000080+0x00000008)
- For $i=1 to $shortcuts[0][0] Step 1
- $button[$i]=GUICtrlCreateButton($shortcuts[$i][1], 24, 18*$i-14, 4+7*$lenght,16)
- GUICtrlCreateIcon($shortcuts[$i][0],-1,4,18*$i-14,16,16)
- Next
- $button_edit=GUICtrlCreateButton("Bearbeiten...",4,$shortcuts[0][0]*18+4,24+7*$lenght,16)
- HotKeySet("!{F1}","gui")
- If $CmdLineRaw = "edited" then
- ToolTip("Einstellungen übernommen.")
- Else
- ToolTip("4ppz erfolgreich gestartet! Hotkey: Alt+F1")
- EndIf
- sleep(3000)
- ToolTip("")
- While 1
- sleep(1000)
- WEnd
- Func gui()
- ToolTip("")
- $winy = MouseGetpos(1)
- $winx = MouseGetpos(0)
- If (@DesktopHeight-18*($shortcuts[0][0]+1)-22-MouseGetpos(1)) < 0 Then $winy = @DesktopHeight-18*($shortcuts[0][0]+1)-22
- If (@DesktopWidth-110-MouseGetpos(0)) < 0 Then $winx = @DesktopWidth-110
- WinMove($GUI,"",$winx,$winy)
- GUISetState(@SW_SHOW)
- Do
- $msg = GUIGetMsg()
- For $i=1 to $shortcuts[0][0] Step 1
- if $msg = $button[$i] then
- ShellExecute($shortcuts[$i][0])
- $msg = 1
- endif
- Next
- If $msg = $button_edit then
- GUISetState(@SW_HIDE)
- edit()
- $msg = 1
- EndIf
- If WinActive($Gui) = 0 then $msg = 1
- Until $msg = $GUI_EVENT_CLOSE or $msg = 1
- GUISetState(@SW_HIDE)
- EndFunc
- Func edit()
- Local $pos
- $gui_edit = GUICreate("Appz - Edit", 251, 193)
- $Group1 = GUICtrlCreateGroup("Appz", 8, 8, 233, 145)
- $list_appz = GUICtrlCreateList("", 16, 24, 169, 123,BitOr(0x1,0x200000,0x800000))
- Local $shortcutnames[$shortcuts[0][0]+1]
- $shortcutnames[0] = $shortcuts[0][0]
- For $i= 1 to $shortcuts[0][0] Step 1
- $shortcutnames[$i] = $shortcuts[$i][1]
- Next
- GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
- $button_up = GUICtrlCreateButton("Up", 192, 24, 41, 25, $WS_GROUP)
- $button_down = GUICtrlCreateButton("Down", 192, 56, 41, 25, $WS_GROUP)
- $button_add = GUICtrlCreateButton("Add", 192, 88, 41, 25, $WS_GROUP)
- $button_delete = GUICtrlCreateButton("Delete", 192, 120, 41, 25, $WS_GROUP)
- GUICtrlCreateGroup("", -99, -99, 1, 1)
- $button_ok = GUICtrlCreateButton("OK", 48, 160, 65, 25, $WS_GROUP)
- $button_cancel = GUICtrlCreateButton("Abbrechen", 128, 160, 65, 25, $WS_GROUP)
- GUISetState(@SW_SHOW)
- Do
- $msg_edit = GUIGetMsg()
- Switch $msg_edit
- Case $button_ok
- If (UBound($shortcuts)-1)>$shortcuts[0][0] then Redim $shortcuts[$shortcuts[0][0]+1][2]
- IniWriteSection($Defaultdir&"\settings.ini","links",$shortcuts)
- ShellExecute(@Scriptfullpath,"edited")
- Exit
- Case $button_add
- Local $linkpath=FileOpenDialog("Choose Application",$DefaultDir,"Executables (*.exe)",3)
- If @error=0 Then
- Local $linkexe=StringSplit($linkpath,"\")
- $i = 0
- While $i = 0
- Local $linkname=Inputbox("Name Shortcut"," ",$linkexe[$linkexe[0]],"",1,1)
- If @error=0 Then
- If $linkname="" Then
- MsgBox(0,"Error","Gib einen Namen ein.")
- Else
- $i=1
- EndIf
- EndIf
- WEnd
- If (UBound($shortcuts)-2)<$shortcuts[0][0] then ReDim $shortcuts[$shortcuts[0][0]+2][2]
- $shortcuts[$shortcuts[0][0]+1][0] = $linkpath
- $shortcuts[$shortcuts[0][0]+1][1] = $linkname
- $shortcuts[0][0] = $shortcuts[0][0]+1
- If (UBound($shortcutnames)-2)<$shortcutnames[0] then ReDim $shortcutnames[$shortcutnames[0]+2]
- $shortcutnames[$shortcutnames[0]+1] = $linkname
- $shortcutnames[0] = $shortcutnames[0]+1
- GUICtrlSetData($list_appz, "")
- GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
- EndIf
- Case $button_delete
- $pos = _arraysearch($shortcutnames,GuiCtrlRead($list_appz),1)
- If $shortcutnames[0] > 1 Then
- _ArrayDelete($shortcutnames,$pos)
- $shortcutnames[0] = $shortcutnames[0]-1
- For $i = $pos to ($shortcuts[0][0]-1) Step 1
- $shortcuts[$i][0] = $shortcuts[$i+1][0]
- $shortcuts[$i][1] = $shortcuts[$i+1][1]
- Next
- $shortcuts[0][0] = $shortcuts[0][0]-1
- GUICtrlSetData($list_appz, "")
- GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
- EndIf
- Case $button_up
- $pos = _arraysearch($shortcutnames,GuiCtrlRead($list_appz),1)
- If $pos > 1 Then
- _ArraySwap($shortcutnames[$pos],$shortcutnames[$pos-1])
- _ArraySwap($shortcuts[$pos][0],$shortcuts[$pos-1][0])
- _ArraySwap($shortcuts[$pos][1],$shortcuts[$pos-1][1])
- GUICtrlSetData($list_appz, "")
- GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
- _GUICtrlListBox_ClickItem($list_appz,$pos-2)
- EndIf
- Case $button_down
- $pos = _arraysearch($shortcutnames,GuiCtrlRead($list_appz),1)
- If $pos < $shortcutnames[0] Then
- _ArraySwap($shortcutnames[$pos],$shortcutnames[$pos+1])
- _ArraySwap($shortcuts[$pos][0],$shortcuts[$pos+1][0])
- _ArraySwap($shortcuts[$pos][1],$shortcuts[$pos+1][1])
- GUICtrlSetData($list_appz, "")
- GuiCtrlSetData($list_appz,_arraytostring($shortcutnames,"|",1))
- _GUICtrlListBox_ClickItem($list_appz,$pos)
- EndIf
- EndSwitch
- Until $msg_edit = $GUI_EVENT_CLOSE or $msg_edit = $button_cancel
- GuiDelete($Gui_edit)
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement