Advertisement
Najeebsk

RUNNER.ahk

Aug 5th, 2022 (edited)
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; <COMPILER: v1.1.32.00>
  2. #NoEnv
  3. #SingleInstance, Force
  4. SendMode Input
  5. SetWorkingDir %A_ScriptDir%\DATA\DOC\
  6. SetTitleMatchMode, 3
  7. Menu, tray, icon, %A_ScriptDir%\DATA\1.ico
  8. #KeyHistory 0
  9. Changed=1 ; used to check if the active file list was changed by the user
  10. ReadIni() ; Check & Read INI file, merged into one function
  11. ;DBFile=%Default%
  12. Hotkey, %GUIStartKey%, GUIStart
  13. return
  14. GUIStart:
  15. WinGetActiveTitle, ActiveWindowTitle
  16. ; [] seem to be illegal characters, remove them from the string
  17. StringReplace, ActiveWindowTitle, ActiveWindowTitle, [, -, All
  18. StringReplace, ActiveWindowTitle, ActiveWindowTitle, ], -, All
  19. ; k++ addition, if the active file list was changed by the user, changed = 1
  20. If Changed = 1 
  21.     {
  22.         ;DBFile=%Default% ; if we don't reset the default here the one from loop below will become the 'default', but we only want that in case there was no manual selection
  23.        
  24.         ; check if the ActiveWindowTitle matches a trigger if so change DBFile accordingly
  25.         Loop, %NumberOfLists%
  26.         {
  27.             Trigger := Trigger%A_Index%
  28.             File := File%A_Index%
  29.             IfInString, ActiveWindowTitle, %Trigger%, SetEnv, DBFile, %File%
  30.         }
  31.     }
  32.  
  33. ;Read lines from active file
  34. ReadDBFile(DBFile, Separator)
  35. StartList := MakeStartList()
  36.  
  37. ; Get Active Window ID and Active Control
  38. CursorIn := GetActiveControl()
  39. ActiveWindow := GetActiveWindow()
  40.  
  41. ; Will prevent error message when the window is already active in the background
  42.     IfWinExist, %GUITitle%
  43.     {
  44.     IfWinNotActive, %GUITitle%
  45.  
  46.     {
  47.         WinMinimize , %GUITitle%
  48.         WinActivate , %GUITitle%
  49.     }
  50.     ;Gui destroy
  51.     }
  52. else
  53. {
  54. Gui -Caption +ToolWindow +Border +LastFound +AlwaysOnTop
  55. CustomColor = 884488
  56. Gui, Color, %CustomColor%
  57. ;Gui,Font,S14 Bold,Verdana ;Calibri
  58. Gui,Font,S14 Bold,Calibri
  59. ; k++ (re)moved some buttons, added DropDownList
  60. Gui, Add, Text, x20 y20 w60 h22, &Search:-
  61. Gui, Add, Edit, gEingabe vEingabe x100 y20 w600 h22 +Left,
  62. Gui, Add, Text, x20 y50 w60 h22, &S-Files:-
  63. Gui, Add, DropDownList, x100 y50 w600 h22 gChangeActiveFile R7 SORT vDBFileChange, SOFT.txt|CMD.txt|FOL.txt|AHK.txt|NIR.txt|VBS.txt|URL.txt|LIST.TXT|SCRIPT.txt|BASH.txt|CLIP.txt|CODE.txt|TEXT.txt|REG.txt|HTML.txt|
  64. Gui, Add, ListBox, x20 y90 w750 h300 gChoice vChoice altsubmit ,%StartList%
  65. Gui,Font,S16 Bold,Verdana
  66. Gui, Add, Edit, x20 y380 w750 h135 vReadOnly,
  67. Gui, Font, s12, Arial
  68. Gui, Add, Button, x710 y20 w55 h22 Default, &OK
  69. Gui, Add, Button, x20 y535 w65 h22 , &Edit
  70. Gui, Add, Button, x100 y535 w65 h22 , &Add
  71. Gui, Add, Button, x180 y535 w75 h22, O&ptions
  72. Gui, Add, Button, x270 y535 w65 h22, &Reset
  73. Gui, Add, Button, x350 y535 w65 h22, &Run
  74. Gui, Add, Button, x430 y535 w65 h22, &R-Cmd
  75. Gui, Add, Button, x510 y535 w65 h22, &R-Com
  76. Gui, Add, Button, x590 y535 w65 h22, &R-AHK
  77. Gui, Add, StatusBar,,
  78. SB_SetParts(140)
  79. SB_SetText(DBFile,1) ; show active file in statusbar
  80. SB_SetText(LineCount . "/" LineCount,2) ; show how many hits / total lines there are in the active file
  81. ;Gui, Show, x353 y55 h520 w420,%GUITitle%
  82. Gui, Add, Text, x-10 y2 w40 h20 CYellow gGuiMove 0x1, >
  83. Gui, Show, x0 y30 w800 h600 Center,%GUITitle%
  84. WinSet, Region, 0-0 W800 H600 R20-20,
  85. WinMove, 0, 0
  86.  
  87. ; Creates a Hitlist and a Hitlist-Array, so that at GUIStart the lines can be shown in Edit2
  88. Choice=1
  89.         loop, %LineCount%
  90.         {
  91.             Hitlist=%Hitlist%|%A_Index%
  92.             Hitlist_%A_Index%=%A_Index%
  93.         }
  94.  
  95. ModeNr=1
  96. Direction=0
  97.     ;Anzeige(ViewOrder,ModeNr,Direction)
  98. Show()
  99. }
  100. Return
  101. GuiMove:
  102.  PostMessage, 0xA1, 2,,, A
  103. Return
  104.  
  105. #IfWinActive, Kollektor++ ahk_class AutoHotkeyGUI   ; Hotkeys only work in the just created GUI
  106. Up::
  107. ControlGetFocus, CheckEdit, %GUITitle%
  108. If (CheckEdit="Edit1") {
  109.     ControlSend, ListBox1, {Up}, %GUITitle%
  110.     }
  111. If (CheckEdit="ComboBox1") {
  112.     ControlSend, ComboBox1, {Up}, %GUITitle%
  113.     }
  114. return
  115.  
  116. Down::
  117. ControlGetFocus, CheckEdit, %GUITitle%
  118. If (CheckEdit="Edit1") {
  119.     ControlSend, ListBox1, {Down}, %GUITitle%
  120.     }
  121. If (CheckEdit="ComboBox1") {
  122.     ControlSend, ComboBox1, {Down}, %GUITitle%
  123.     }
  124. return
  125.  
  126. ;Enter::
  127. ;Gosub ButtonOK
  128. ;Return
  129.  
  130. ;F1:: ; used to open a HTML help page
  131. ;Gosub ButtonHelp
  132. ;Return
  133.  
  134. #IfWinActive
  135.  
  136. ; k++ If you press ALT-A or click the ADD button, you can add the marked text to the currently active file
  137. ButtonAdd:
  138. ClipSaved := ClipboardAll ; Save clipboard
  139. send, ^c
  140. StringLeft, ShowClip, Clipboard, 450 ; We need to trim text because MsgBox might become to large to fit on screen
  141. MsgBox, 4, ADD to file?, Do you want to add the text below to %DBFile%`n`n%ShowClip% ...
  142. IfMsgBox Yes
  143.     {
  144.     StringReplace, clipboard, clipboard, `r`n,%Separator%, All ;Replaces CR LF by %Separator%
  145.     FileAppend, %Clipboard%`n, %DBFile%
  146.     }
  147. Clipboard := ClipSaved ; Restore the original clipboard.
  148. ClipSaved =            ; Free the memory ^
  149. ShowClip =
  150. GUI destroy
  151. Return 
  152.  
  153. Return
  154.  
  155. ButtonOK:       ; Insert the selected/found text in the active window
  156.     ClipSaved := ClipboardAll ; Save clipboard
  157.     ControlGetText, Clipboard ,Edit2, %GUITitle%
  158.     GUI destroy ; Before sending the contents of the clipboard, the GUI must be removed because many windows will not accept ControlSend when the window is active in the background
  159.     ControlSend, %CursorIn%,{Control down}v{Control up}, AHK_ID%ActiveWindow%   ; On some systems only {Control down}v{Control up} works correcly and not ^v
  160.     Clipboard := ClipSaved ; Restore the original clipboard.
  161.     ClipSaved = ; Free the memory
  162. Return
  163.  
  164. GuiEscape:      ; Gui dissappears, program remains active in memory
  165.     GUI destroy    
  166. Return
  167.  
  168. GuiClose:       ; Programm is closed
  169.     ExitApp
  170.  
  171. ; K++ addition, new function to load new file
  172. ChangeActiveFile:
  173.  Gui, Submit
  174.   DBFile = %DBFileChange%
  175.     GUI destroy
  176.     Changed=1 ; remember the active file was changed manually
  177.     Gosub GUIStart ; reload gui to load active file
  178. Return
  179.    
  180. ; --------------------------------------------------------------------------
  181.  
  182. ButtonOptions:
  183.     runwait, %Editor% KollektorPP.ini
  184.     sleep, 500
  185.     ReadIni()
  186.     Return
  187.  
  188. ;ButtonHelp:
  189. ;   run, .\Help\Kollektor_Hilfe.htm
  190. ;Return
  191.  
  192. ButtonEdit:
  193.     runwait, %Editor% %DBFile%
  194.     GUI destroy
  195.     Gosub GUIStart
  196.   Return
  197.    
  198. ButtonReset:
  199.     Changed=0 ; if you reload the app, forget manually selected file
  200.     GUI destroy
  201.     Gosub GUIStart
  202.   Return
  203. ButtonRun:
  204.     Runwait, %ReadOnly%
  205.     GUI destroy
  206.     Gosub GUIStart
  207.   Return
  208. ButtonR-Cmd:
  209. gui, submit, nohide
  210. Runwait,%comspec% /k %ReadOnly%
  211. return
  212. ButtonR-Com:
  213. gui, submit, nohide
  214. Runwait, C:\Windows\explorer.exe shell:%ReadOnly%
  215. return
  216. ButtonR-AHK:
  217. Gui, Submit, NoHide
  218. ;FileAppend, %ReadOnly% `n ^ESC::ExitApp, %A_ScriptDir%\TempTestCode.ahk
  219. FileAppend,
  220. (
  221. #NoEnv
  222. #persistent
  223. SetWorkingDir %A_ScriptDir%
  224. #SingleInstance force
  225. SetBatchLines, -1
  226. Menu, Tray, Icon, %A_ScriptDir%\DATA\2.ico
  227. %ReadOnly%
  228. #R::Reload  ;<--  ~ Reload Script ~
  229. #S::Suspend ;<--  ~ Suspend Script ~
  230. #P::Pause   ;<--  ~ Pause Script ~
  231. #M::WinMinimize, ;<--  ~ Minimize Script ~
  232. ESC::ExitApp     ;<--  ~ Exit Script ~
  233. ), %A_ScriptDir%\TempTestCode.ahk
  234. Run, %A_ProgramFiles%\AutoHotkey\AutoHotkey.exe "%A_ScriptDir%\TempTestCode.ahk"
  235. Sleep 2000
  236. FileDelete, %A_ScriptDir%\TempTestCode.ahk
  237. return
  238. ; --------------------------------------------------------------------------
  239.    
  240. EINGABE:
  241. ; Enter text to search for, show list of found items in listbox
  242. Gui, Submit, noHide
  243. SearchFor=
  244. Loop
  245. {   ; Sometimes you type to fast for the computer
  246.     If SearchFor=%Eingabe%
  247.         break
  248.     SearchFor=%Eingabe%
  249.  
  250.     ;Erstellen der Trefferliste
  251.     Hitlist := SearchDB(SearchFor,CaseSensitive,WholeWordCheck,WhichColumn,WordStart)
  252.     word=
  253.     wordlist=
  254.     ; K++ addition ; HowManyHits is used to show how many items were found in the Statusbar
  255.     HowManyHits =
  256.     loop, parse, Hitlist,|
  257.     {
  258.         Word := DB%A_LoopField%_1
  259.         Wordlist =%Wordlist%|%word%
  260.         Hitlist_%A_Index%=%A_LoopField%
  261.       ; K++ addition
  262.         HowManyHits := A_Index
  263.     }
  264.     ; K++ addition
  265.     HowManyHits-=1
  266.     SB_SetText(HowManyHits . "/" . LineCount,2)    
  267.    
  268.     ; Check if there is another entry
  269.     GUI, Submit, noHide
  270. }
  271.  
  272. ; Special cases
  273. If (Wordlist="")            ; Nothing found, empty the Listbox
  274.     Wordlist=|
  275.  
  276. If (SearchFor="")           ; Show start list when the input box is empty
  277.     {
  278.     Wordlist=|%StartList%
  279.     ; K++ addition, restore statusbar to start values
  280.         SB_SetText(LineCount . "/" . LineCount,2)          
  281.     }
  282.    
  283. ; Listbox with found items is shown
  284. GuiControl,, ListBox1, %wordlist%  
  285. Choice=1
  286. Direction=0
  287. ModeNr=1
  288. ;Anzeige(ViewOrder,ModeNr, Direction)
  289. Show()
  290. return
  291.  
  292. ; --------------------------------------------------------------------------
  293.  
  294. CHOICE:
  295. ; Used by navigation in the Listbox (up/down keys)
  296.  
  297. Gui, submit, NoHide
  298. Direction=0
  299. ModeNr=1
  300. ;Anzeige(ViewOrder,ModeNr,Direction)
  301. Show()
  302.  
  303. ; Doubleclick on item in the list, same as Button OK
  304. if A_GuiControlEvent = DoubleClick
  305.     Gosub ButtonOK
  306. return
  307.  
  308. Show()
  309. ; Shows the lines in the preview window, correcting any linebreaks (separator)
  310. {
  311.     global  Hitlist, Choice,
  312.     Treffer := Hitlist_%Choice%         ; "Treffer" is the number of the selected item in the list
  313.     Line := DBLine_%Treffer%
  314.     StringReplace, ToShow, Line, ¤, `n, All
  315.     GuiControl,, Edit2, %ToShow%
  316.     return
  317. }
  318.  
  319.  
  320. Anzeige(ViewOrder,ModeNr, Direction)
  321. {
  322.     global ColCount, Hitlist, Choice
  323.    
  324.     Treffer := Hitlist_%Choice%         ; "Treffer" is the number of the selected item in the list
  325.  
  326.     ModeNr := ModeNr+Direction
  327.        
  328.     ViewModeCount=0
  329.     loop, parse,ViewOrder,|
  330.         {
  331.             ViewModeCount := ViewModeCount + 1      ;Zählt die Anzeigen-Modi
  332.             a=%A_Index%
  333.             ToShow_%a% =
  334.    
  335.             Loop, Parse,A_LoopField,-
  336.             {
  337.                 If A_LoopField is integer
  338.                 {
  339.                     ToShow_%a% := ToShow_%a% . DB%Treffer%_%A_LoopField% . "`n"
  340.                 }              
  341.  
  342.                 else
  343.                 {
  344.                     FieldNr := LeaveOnlyNumbers(A_LoopField)            ; Nur die Feldnummer bleibt übrig, alle anderen Zeichen werden entfernt
  345.                     if (Instr(A_LoopField,",_")>0)                            ; Komma Unterstrich für Komma, Leerzeichen,kein Zeilenumbruch
  346.                         ToShow_%a% := ToShow_%a% . DB%Treffer%_%FieldNr% . "," . A_Space                   
  347.                     else if (Instr(A_LoopField,"_")>0)                      ;Unterstrich für, Leerzeichen,kein Zeilenumbruch
  348.                         ToShow_%a% := ToShow_%a% . DB%Treffer%_%FieldNr% . A_Space
  349.                     else
  350.                         ToShow_%a% := ToShow_%a% . DB%Treffer%_%FieldNr% . "`n"     ;Alle weiteren Nicht-Integers werden ignoriert             
  351.                 }  
  352.                    
  353.             }
  354.         }
  355.  
  356.     ; Am Listenende: Sprung an den Anfang/ Am Listenanfang: Sprung ans Ende der Liste
  357.     If (ModeNr<1)
  358.         ModeNr= %ViewModeCount%
  359.     If (ModeNr>ViewModeCount)
  360.         ModeNr=1
  361.        
  362.     ;Anzeige des gewählten Modus  
  363.     GuiControl,, Edit2, % ToShow_%ModeNr%
  364.    
  365.     ;Rückgabe der ModusNummer
  366.     Return ModeNr
  367. }
  368.  
  369. ; --------------------------------------------------------------------------
  370.  
  371. MakeStartList()
  372. ;erstellt eine Liste aller Items, die beim Programmstart angezeigt wird
  373. {
  374.     global LineCount
  375.     Startlist=
  376.     Loop, %LineCount%
  377.     {
  378.         word := DB%A_Index%_1
  379.         Startlist =%Startlist%%word%|
  380.     }
  381.     return StartList
  382. }
  383.  
  384. SearchDB(SearchFor,CaseSensitive,WholeWordCheck,WhichColumn,WordStart)
  385. {
  386.     global LineCount, ColCount         
  387.     ;global counter
  388.     ;Counter := counter+1
  389.    
  390.     ; FEHLERBEHANDLUNG
  391.     If (WhichColumn>ColCount and WhichColumn<>"ALL")            ;Suche in einer nicht existierenden Spalte
  392.         {
  393.             ;msgbox, Die Tabelle enthält nur %ColCount% Spalten.`nDie %WhichColumn%. Spalte kann also nicht durchsucht werden.`nDie Anwendung wird beendet.
  394.             msgbox, The Table only contains %ColCount% columns.`nThe %WhichColumn% column can not be searched.`nThe search will be stopped.
  395.             exitapp
  396.         }
  397.        
  398.     ; SUCHE
  399.     Loop, %LineCount%
  400.     {
  401.         L_Index=%A_Index%               ;L_Index: Zeilennummer
  402.        
  403.         Loop, %ColCount%
  404.         {
  405.             ;In welchen Spalten?
  406.             If WhichColumn=ALL          ;Alle Spalten werden durchsucht
  407.                 C_Index=%A_Index%       ;C_Index: Spaltennummer
  408.             Else   
  409.                 C_Index=%WhichColumn%   ;nur die spezifizierte Spalte wird durchsucht
  410.            
  411.             SearchIn :=  DB%L_Index%_%C_Index%
  412.             Position := InStr( SearchIn,SearchFor,CaseSensitive )       ;Position des Suchbegriffes. O= Suchbegriff nicht gefunden. >=1 Treffer irgendwo in SearchIn. =1 Treffer steht am Anfang
  413.            
  414.             If (Position = 0)      
  415.                 continue
  416.            
  417.             ;Bedingungen abfragen
  418.             If (Position=1 AND WholeWordCheck="ON" AND WordStart="ON")      ;Es wird nach ganzem Wort am Zellanfang gesucht
  419.             {
  420.                 WholeWord := IsWholeWord(SearchIn,SearchFor)
  421.                 If WholeWord=1
  422.                 {
  423.                     Hitlist=%Hitlist%%L_Index%|
  424.                     break
  425.                 }
  426.             }
  427.            
  428.             If (Position>=1 AND WholeWordCheck="ON" AND WordStart="OFF")    ;Es wird nach ganzem Wort irgendwo in der Zelle gesucht
  429.             {
  430.                 WholeWord := IsWholeWord(SearchIn,SearchFor)
  431.                 If WholeWord=1
  432.                 {
  433.                     Hitlist=%Hitlist%%L_Index%|
  434.                     break
  435.                 }
  436.             }
  437.  
  438.             If (Position=1 AND WholeWordCheck="OFF" AND WordStart="ON") ;der Zelleninhalt beginnt mit dem Suchbegriff
  439.             {
  440.                 Hitlist=%Hitlist%%L_Index%|
  441.                 break
  442.             }
  443.  
  444.             If (Position>=1 AND WholeWordCheck="OFF" AND WordStart="OFF")   ;Suchbegriff hat beliebige Position
  445.             {
  446.                 Hitlist=%Hitlist%%L_Index%|
  447.                 Break
  448.             }
  449.             If (WhichColumn<>"ALL")     ;Beendt die Suche nach einer Spalte, wenn nur eine durchsucht werden soll  
  450.             {
  451.                 Break
  452.             }          
  453.         }
  454.     }
  455.     return Hitlist
  456. }
  457. ReadDBFile(DatabaseFile,Separator)
  458. {
  459.     global                          ;Alle Variablen dieser Funktion sind global
  460.     local L_Index                   ;Diese Variablen sind lokal (gelten nur innerhalb der Funktion)
  461.     LineCount = 0
  462.     ColCount = 0
  463.    
  464.     IfNotExist, %DBFile%
  465.         DBLine_1 =
  466.        
  467.    
  468.     Loop, read, %DBFile%
  469.     {
  470.         DBLine_%A_Index%=%A_LoopReadLine%
  471.         L_Index=%A_Index%
  472.         %L_Index%ColCount = 0
  473.         LineCount += 1
  474.         ;Loop, parse, A_LoopReadLine, %Separator% ;This is the original line in the script
  475.         Loop, parse, A_LoopReadLine,`n
  476.         {
  477.             DB%L_Index%_%A_Index% = %A_LoopField%
  478.             %L_Index%ColCount += 1          ;Die Variable %L_Index%ColCount ist NICHT identisch mit ColCount!
  479.             if( ColCount < %L_Index%ColCount )
  480.             ColCount := %L_Index%ColCount
  481.         }
  482.     }
  483. }
  484.  
  485.  
  486. ;*******************************************************************************************************
  487.  
  488. IsWholeWord(SearchIn,SearchFor)
  489. ; Überprüft ob der zu suchenden Begriff "SearchFor" als eigenes vollständiges Wort in "SearchIn"
  490. ; vorkommt.
  491. ; Wenn ja, wird WholeWord=1 zurückgegeben, wenn nicht WholeWord=0
  492.  
  493. {
  494.     BorderChar=,,,.,%A_Space%,%A_Tab%,-,:               ;Liste von Zeichen, die vor oder nach einem Wort stehen können. Reihenfolge der Liste ist wichtig!
  495.     SearchLength := StrLen(SearchFor)
  496.     FieldLength := StrLen( SearchIn)
  497.     Position := InStr( SearchIn, SearchFor)
  498.    
  499.     if SearchLength = %FieldLength%                 ;SearchIn enthält nur das Suchwort
  500.     {
  501.         WholeWord=1
  502.     }
  503.    
  504.     else if Position=1                              ;SearchIn beginnt mit dem Suchwort                                 
  505.     {
  506.         StringMid, TailChar, SearchIn, % Position+SearchLength, 1   ;TailChar: erstes Zeichen nach "SearchFor"
  507.         if TailChar contains %BorderChar%          
  508.         {
  509.             WholeWord=1
  510.         }
  511.         else
  512.          {
  513.             WholeWord=0
  514.          }
  515.     }
  516.    
  517.     else if (Position+SearchLength-1=FieldLength)   ;SearchIn endet mit dem Suchwort
  518.     {
  519.         StringMid, LeadChar, SearchIn, % Position - 1, 1
  520.         if LeadChar contains %BorderChar%
  521.         {
  522.             WholeWord=1
  523.         }
  524.         else
  525.         {
  526.             WholeWord=0
  527.         }
  528.     }
  529.    
  530.     else                                            ;SearchFor steht mitten in SearchIn
  531.     {
  532.         StringMid, LeadChar, SearchIn, % Position - 1, 1
  533.         if LeadChar contains %BorderChar%
  534.         {
  535.             StringMid, TailChar, SearchIn, % Position+SearchLength, 1   ;TailChar: erstes Zeichen nach "SearchFor"
  536.             if TailChar contains %BorderChar%          
  537.             {
  538.                 WholeWord=1
  539.             }
  540.             else
  541.             {
  542.                 WholeWord=0
  543.             }
  544.         }
  545.         else
  546.         {
  547.             WholeWord=0
  548.         }
  549.     }  
  550.     return WholeWord
  551. }
  552.  
  553. LeaveOnlyNumbers(String)
  554. ;Entfernt alle Zeichen außer den Ziffern aus dem String
  555. {
  556.     stringlen, Laenge, String
  557.     stringsplit, Stringarray, string
  558.     Loop, %Laenge%
  559.     {
  560.     if stringarray%A_Index% is not integer
  561.         {
  562.         Stringarray%A_Index%=
  563.         }
  564.         x:= stringarray%A_Index%
  565.         NewString=%NewString%%x%
  566.     }
  567.     String=%NewString%
  568.     Return %String%
  569. }
  570.  
  571. ; --------------------------------------------------------
  572.  
  573. CharacterCount(String, Character)
  574. ;Zählt, wie oft das Zeichen "Character" im String vorkommt und gibt diese Anzahl zurück
  575. {
  576.     x=0
  577.     StringLen, Laenge, String
  578.     StringSplit, Stringarray, string
  579.     Loop, %Laenge%
  580.     {
  581.     if stringarray%A_Index% contains %Character%
  582.         {
  583.         x := x+1
  584.         }
  585.     }
  586.     Return x
  587. }
  588.  
  589. ; --------------------------------------------------------
  590.  
  591. GetActiveControl()
  592. ;Gibt den Namen der aktiven Control zurück
  593. {
  594. WinGet, Active_Window_ID, ID, A                
  595. ControlGetFocus, ActiveControl, A,
  596. Return,  ActiveControl
  597. }
  598.  
  599. ; --------------------------------------------------------
  600.  
  601. GetActiveWindow()
  602. ; Gibt die ID-Nummer des gerade aktiven Fensters zurück
  603. {
  604. WinGet, Active_Window_ID, ID, A                
  605. return, Active_Window_ID
  606. }
  607.  
  608. ; --------------------------------------------------------
  609.  
  610. ; k++ completely new function
  611. ReadIni()
  612. {
  613. global
  614. ; check if there is an ini file, if not create one
  615. IfNotExist,KollektorPP.ini
  616.     {
  617.         ini=
  618. (
  619. [SETTINGS]
  620. GUITitle=Kollektor++
  621. GUIStartKey=F1
  622. Editor=notepad.exe
  623.  
  624. [SEARCH]
  625. CaseSensitive=0
  626. WholeWordCheck=OFF
  627. WordStart=OFF
  628. WhichColumn=1
  629. Separator=¤
  630.  
  631. [VIEW]
  632. ViewOrder=1
  633. ModeNr=1
  634. Direction=0
  635.  
  636. [LISTS]
  637. Def=SOFT.txt
  638. Cmd=CMD.txt
  639. Fol=FOL.txt
  640. Ahk=AHK.txt
  641. Nir=NIR.txt
  642. )
  643.   FileAppend,%ini%,KollektorPP.ini
  644.   ini=
  645.     }
  646.  
  647. ; read general settings
  648. IniRead,GUITitle,KollektorPP.ini,SETTINGS,GUITitle,Kollektor++
  649. IniRead,GUIStartKey,KollektorPP.ini,SETTINGS,GUIStartKey,F1
  650. IniRead,Editor,KollektorPP.ini,SETTINGS,Editor,notepad
  651.  
  652. ; read search settings
  653. IniRead,CaseSensitive,KollektorPP.ini,SEARCH,CaseSensitive,0
  654. IniRead,WholeWordCheck,KollektorPP.ini,SEARCH,WholeWordCheck,OFF
  655. IniRead,WordStart,KollektorPP.ini,SEARCH,WordStart,OFF
  656. IniRead,WhichColumn,KollektorPP.ini,SEARCH,WhichColumn,1
  657. IniRead,Separator,KollektorPP.ini,SEARCH,Separator,¤
  658.  
  659. ; read view settings
  660. IniRead,ViewOrder,KollektorPP.ini,VIEW,ViewOrder,1
  661. IniRead,ModeNr,KollektorPP.ini,VIEW,ModeNr,1
  662. IniRead,Direction,KollektorPP.ini,VIEW,Direction,0
  663.  
  664. ; read default list
  665. IniRead,Def,KollektorPP.ini,LISTS,Def,SOFT.txt
  666. IniRead,Cmd,KollektorPP.ini,LISTS,Cmd,CMD.txt
  667. IniRead,Fol,KollektorPP.ini,LISTS,Fol,FOL.txt
  668. IniRead,Ahk,KollektorPP.ini,LISTS,Ahk,AHK.txt
  669. IniRead,Nir,KollektorPP.ini,LISTS,Nir,NIR.txt
  670. IniRead,Vbs,KollektorPP.ini,LISTS,Vbs,VBS.txt
  671. IniRead,Url,KollektorPP.ini,LISTS,Url,URL.txt
  672. IniRead,Lis,KollektorPP.ini,LISTS,Lis,LIST.txt
  673. IniRead,Script,KollektorPP.ini,LISTS,Script,SCRIPT.txt
  674. IniRead,Bash,KollektorPP.ini,LISTS,Bash,BASH.txt
  675. IniRead,Clip,KollektorPP.ini,LISTS,Clip,CLIP.txt
  676. IniRead,Code,KollektorPP.ini,LISTS,Code,CODE.txt
  677. IniRead,Text,KollektorPP.ini,LISTS,Text,TEXT.txt
  678. IniRead,Html,KollektorPP.ini,LISTS,Html,HTML.txt
  679. ; read triggers & associated files 
  680. FileList = %DBFileChange%
  681. Loop
  682.  {
  683.   NumberOfLists:=A_Index
  684.   IniRead,Trigger%NumberOfLists%,KollektorPP.ini,LISTS,Trigger%NumberOfLists%
  685.   IniRead,File,KollektorPP.ini,LISTS,File%NumberOfLists%
  686.   If (File = "ERROR") {
  687.       Break
  688.    }
  689.    File%NumberOfLists% := File
  690.    FileList .= "|" . File
  691.  }
  692. NumberOfLists-=1
  693. }
  694.  
  695. #R::Reload  ;<--  ~ Reload Script ~
  696. #S::Suspend ;<--  ~ Suspend Script ~
  697. #P::Pause   ;<--  ~ Pause Script ~
  698. #M::WinMinimize, ;<--  ~ Minimize Script ~
  699. ESC::ExitApp     ;<--  ~ Exit Script ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement