Advertisement
Najeebsk

SEARCH-EXTENSION.ahk

Mar 30th, 2023 (edited)
1,488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  
  2. #Persistent
  3. #SingleInstance, Force
  4. #MaxMem 4095
  5. #MaxThreads 99999
  6. #MaxThreadsBuffer On
  7. SendMode, Input  
  8. SetWorkingDir, %A_ScriptDir%  
  9. Process, Priority,, H
  10. SetBatchLines, -1
  11. SetTitleMatchMode, 2
  12. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  13. FileCreateDir, %A_ScriptDir%\DATA
  14. FileInstall , SEARCH-EXTENSION.ahk, %A_ScriptDir%\DATA\SEARCH-EXTENSION.ahk, 1
  15. FileInstall , Milikymac.msstyles, %A_ScriptDir%\DATA\Milikymac.msstyles, 1
  16. FileInstall , USkin.dll, %A_ScriptDir%\DATA\USkin.dll, 1
  17. FileSetAttrib +HS, %A_ScriptDir%\DATA\SEARCH-EXTENSION.ahk, 2
  18. FileSetAttrib +HS, %A_ScriptDir%\DATA\Milikymac.msstyles, 2
  19. FileSetAttrib +HS, %A_ScriptDir%\DATA\USkin.dll, 2
  20. FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
  21. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  22. SkinForm(Apply, A_ScriptDir . "\DATA\USkin.dll", A_ScriptDir . "\DATA\Milikymac.msstyles")
  23. OnExit, GetOut
  24. sleep(period := 1, Mode := "P")
  25. {
  26.     static Frequency, MinSetResolution, PID
  27.     if (Mode = "P")
  28.     {
  29.         pBatchLines := A_BatchLines
  30.         SetBatchLines, -1
  31.         if !Frequency
  32.             DllCall("QueryPerformanceFrequency", "Int64*", Frequency)
  33.         DllCall("QueryPerformanceCounter", "Int64*", Start)
  34.         Finish := Start + ( Frequency * (period/1000))
  35.         loop
  36.             DllCall("QueryPerformanceCounter", "Int64*", Current)
  37.         until (Current >= Finish)
  38.         SetBatchLines, %pBatchLines%
  39.     }
  40.     return
  41. }
  42.  
  43. icon:="ICON.ico"
  44. iconURL:="http://www.iconarchive.com/download/i24880/mayosoft/azullustre-2/search-folder.ico"
  45.  
  46. if (!FileExist(A_Temp "\" icon))
  47.     URLDownloadToFile, % iconURL, %A_Temp%\%icon%
  48. Menu, Tray, Icon, %A_Temp%\%icon%
  49. Menu, Tray, NoStandard
  50. Menu, Tray, add, Search Extension, InputBox
  51. Menu, Tray, add, Created by: Najeeb Shah Khan, MenuHandler
  52. Menu, Tray, add, Exit, ExitHandler
  53.  
  54. FileToolz()
  55.  
  56. ;----------------------begin func
  57.  
  58. FileToolz() {
  59.    
  60. global Percent, tCount, sDir, EXTM, EXT
  61.  
  62. inputbox:
  63. InputBox, EXT, Najeeb Choose Extension,%a_space%%a_space%%a_space%Default is EXE if left blank.`n Format: JPG "*." not required.,, 200, 145
  64. EXT=%EXT%
  65. EXTM:=EXT "-LIST.txt"
  66. if EXT=
  67. {
  68.     EXT:="exe"
  69. }
  70.  
  71. dMaster:=A_ScriptDir "\" EXTM
  72. dTmp:=A_Temp "\" "temp.txt"
  73.  
  74. ;----------------------setting the search directory
  75.  
  76. sDir=%sDir%
  77. Thread, NoTimers
  78. FileSelectFolder, sDir, *C:, 3, Select Your Search Folder
  79. Thread, NoTimers, false
  80.  
  81. if sDir= ; blank
  82. {  
  83. SetTimer, ChangeButtonNames, 50
  84. MsgBox, 4, Nothing Selected, %A_UserName%,`n`nDo you know how to work a dialog box?
  85. IfMsgBox, No
  86.     return
  87. else
  88.     return
  89. return
  90. }
  91.  
  92. ;----------------------Checking for pre-existing files
  93.  
  94. list_check:
  95. if (!FileExist(dMaster)){
  96.     FileAppend,, % dMaster
  97. }if (FileExist(dTmp)){
  98.     FileDelete, % dTmp
  99. }
  100.  
  101. ;----------------------Nothing crucial going on here... taking file count before hand for progress bar
  102. SetTimer, WatchTip, 50
  103.  
  104. tCount := 0
  105. Loop, %sDir%*.%EXT%, ,1
  106. {
  107.     tCount++
  108. }
  109.  
  110. ;----------------------Again, just for show...
  111.  
  112. SetTimer, WatchTip, Off
  113. ToolTip ; <-destroys tooltip
  114.  
  115. Progress, b C0 w500 h55
  116.  
  117. ;----------------------; actual file count starts here
  118.  
  119. FileList =
  120. Counter := 0
  121. Loop, %sDir%*.%EXT%, , 1
  122. {
  123.     Counter++ ; generates a count for the percentage
  124.     Percent := Floor(Counter / tCount * 100)
  125.     FileList = %FileList%%A_LoopFileName%%A_Tab%%A_LoopFileFullPath%`n
  126.     gosub, ProgressBar ; updates progress bar
  127. }
  128.  
  129. Progress, off
  130.  
  131. ;----------------------sort files and append temp
  132.  
  133. TrayTip,, Creating temp file, 15
  134.  
  135. Sort, FileList
  136. Loop, parse, FileList, `n
  137. {
  138.     if A_LoopField =
  139.         break
  140.     FileAppend, %A_LoopField%`n, % dTmp
  141. }
  142.  
  143. TrayTip
  144.  
  145. ;----------------------read contents of master list and temp list
  146.  
  147. FileRead, mContent, % dMaster
  148. Sort, mContent, CL
  149. FileRead, tContent, % dTmp
  150. Sort, tContent, CL
  151.  
  152. ;----------------------compare temp to master
  153.  
  154. TrayTip,, Comparing Changes, 10
  155.  
  156. Loop, Read, % dTmp
  157. {
  158.     IfNotInString, mContent, %A_LoopReadLine%
  159.     FileAppend, %A_LoopReadLine%`n, % dMaster
  160. }
  161.  
  162. TrayTip
  163.  
  164. ;----------------------clear memory
  165.  
  166. FileContent1=
  167. FileContent2=
  168.  
  169. ;----------------------delete temp file & notify user of completion
  170.  
  171. TrayTip,, Doing some housekeeping..., 2
  172. Sleep, (2000)
  173. FileDelete, % dTmp
  174. TrayTip,, Done...
  175. Sleep, (1000)
  176. TrayTip
  177. return
  178.  
  179. WatchTip: ;----------------------Tooltip during file count
  180. ToolTip, Gathering *.%EXT% file count...`nCount: %tCount%
  181. Sleep (25)
  182. return
  183.  
  184. ;----------------------Progress bar updater
  185.  
  186. ProgressBar:
  187. P2:="["(A_Space)(percent)(A_Space)"%"(A_Space)"]"
  188. WinSet,Transparent, 210, %A_ScriptName% ; Transparency
  189. WinSet,ExStyle,+0x20, %A_ScriptName%    ; Click-through
  190. Progress, %Percent%, %P2%%A_Tab%%A_LoopFileName%,, %A_ScriptName%
  191. return
  192.  
  193. MenuHandler:
  194. SplashTextOn, 200, 25, Created by:, najeebshahkhan@gmail.com
  195. WinSet,Transparent, 210, Created by:
  196. Sleep, (2000)
  197. SplashTextOff
  198. return
  199.  
  200. ChangeButtonNames:
  201. IfWinNotExist, Nothing Selected
  202.     return  ; Keep waiting.
  203. SetTimer, ChangeButtonNames, off
  204. WinActivate
  205. ControlSetText, Button1, &No
  206. ControlSetText, Button2, &No
  207. return
  208.  
  209. ExitHandler:
  210. ExitApp
  211. return
  212. } ;---------------------- FUNC ENDS HERE
  213. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  214. GetOut:
  215. GuiClose:
  216. Gui, Hide
  217. SkinForm(0)
  218. ExitApp
  219. return
  220.  
  221. SkinForm(Param1 = "Apply", DLL = "", SkinName = ""){
  222.     if(Param1 = Apply){
  223.         DllCall("LoadLibrary", str, DLL)
  224.         DllCall(DLL . "\USkinInit", Int,0, Int,0, AStr, SkinName)
  225.     }else if(Param1 = 0){
  226.         DllCall(DLL . "\USkinExit")
  227.         }
  228. }
  229. ;=-=-=-=-=-=-=- END Script -=-=-=-=-=-=-=-=-
  230. #S::Suspend
  231. #P::Pause
  232. #R::Reload
  233. ESC::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement