Advertisement
Najeebsk

BOOK-READER.ahk

Oct 3rd, 2022
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; <COMPILER: v1.1.34.3>
  2. #NoEnv
  3. #SingleInstance, Force
  4. SendMode Input
  5. SetWorkingDir %A_ScriptDir%\BOOKS
  6. Extensions := "txt,doc,bat,ahk,ls,vbs,reg,fm,ps1"
  7. Gui,Font,S14 Bold,Verdana ;Calibri
  8. Gui 1:Add, Button, Default gFindString, Search
  9. Gui 1:Add, Edit, w300 vfind
  10. Gui 1:Add, DropDownList, w600 vPFL gOP,
  11. Gui,Font,S12 Bold,Verdana ;Calibri
  12. Gui 1:Add, Edit, CGreen w1000 r24 vContent HSCROLL
  13. Gui 1:Add, Button, x15 y600 gNIR, NIR-RUN
  14. Gui 1:Add, Button,x120 y600 gAHK, AHK-RUN
  15. Gui 1:Add, Button,x225 y600 gBAT, BAT-RUN
  16. Gui 1:Add, Button,x330 y600 gBATS, BATS-RUN
  17. Gui 1:Add, Button,x445 y600 gDEL, DELETE
  18. Gui 1:Add, Button,x540 y600 gSAV, SAVE
  19. Gui 1:Add, Button,x610 y600 gSAVTO, SAVE-TO
  20. Gui,Font,S10 Bold,Verdana ;Calibri
  21. Gui 1:Add, StatusBar,, Najeeb Books , Ctrl+F to search in Text , F1 Open File , HELP  Enter Edit Win All Hotkeys
  22. SB_SetParts(640)
  23. GoSub, DDL
  24. GuiControl, Hide, Button1
  25. GuiControl, Hide, Edit1
  26. Gui 1:Show,, Najeeb Books Search Files Data
  27. WinGet ControlID, ID, Najeeb Books Search Files Data
  28.  
  29. Guicontrol,,Edit2, %PFL%
  30. return
  31. DDL:
  32. loop, *
  33. {
  34.     if A_LoopFileExt in %extensions%
  35.     GuiControl, , PFL, %A_LoopFileName%   ; this will add an entry to the DDL control
  36. }
  37. Return
  38. OP:
  39. Gui, Submit, NoHide
  40. ;MsgBox,%PFL%
  41. FileRead,LoadFile,%PFL%
  42. GuiControl,, Edit2, %LoadFile%
  43. Return
  44. F1::Run, %PFL%
  45. Return
  46. F2::Run, notepad.exe %PFL%
  47. Return
  48. FindString:
  49.   Gui, Submit, Nohide
  50.  
  51.    if (find != lastFind) {
  52.     offset = 0
  53.     hits = 0
  54.    }
  55.  
  56.    GuiControl 1:Focus, Content                           ; focus on main help window to show selection
  57.    SendMessage 0xB6, 0, -999, Edit2, ahk_id %ControlID%  ; Scroll to top
  58.    StringGetPos pos, Content, %find% ,,offset            ; find the position of the search string
  59.    if (pos = -1) {
  60.     if (offset = 0) {
  61.       SB_SetText("'" . find . "' not found", 1)
  62.       SB_SetText("", 2)
  63.     }
  64.     else {
  65.       SB_SetText("No more occurrences of '" . find . "'")
  66.       SB_SetText("", 2)
  67.       offset = 0
  68.       hits = 0
  69.     }
  70.     return
  71.    }
  72.    StringLeft __s, Content, %pos%                        ; cut off end to count lines
  73.    StringReplace __s,__s,`n,`n,UseErrorLevel             ; Errorlevel <- line number
  74.    addToPos=%Errorlevel%
  75.    SendMessage 0xB6, 0, ErrorLevel, Edit2, ahk_id %ControlID% ; Scroll to visible
  76.    SendMessage 0xB1, pos + addToPos, pos + addToPos + Strlen(find), Edit2, ahk_id %ControlID% ; Select search text
  77.    ; http://msdn.microsoft.com/en-us/library/bb761637(VS.85).aspx
  78.    ; Scroll the caret into view in an edit control:
  79.    SendMessage, EM_SCROLLCARET := 0xB7, 0, 0, Edit2, ahk_id %ControlID%
  80.    offset := pos + addToPos + Strlen(find)
  81.    lastFind = %find%
  82.    hits++
  83.    SB_SetText("'" . find . "' found in line " . addToPos + 1, 1)
  84.    SB_SetText(hits . (hits = 1 ? " hit" : " hits"), 2)
  85. Return
  86. cos_mousedrag_treshold := 20 ; pixels
  87. #IfWinNotActive ahk_class ConsoleWindowClass
  88. ~lButton::
  89.   MouseGetPos, cos_mousedrag_x, cos_mousedrag_y
  90.   keywait lbutton
  91.   mousegetpos, cos_mousedrag_x2, cos_mousedrag_y2
  92.   if (abs(cos_mousedrag_x2 - cos_mousedrag_x) > cos_mousedrag_treshold
  93.     or abs(cos_mousedrag_y2 - cos_mousedrag_y) > cos_mousedrag_treshold)
  94.   {
  95.     wingetclass cos_class, A
  96.     if (cos_class == "Emacs")
  97.       sendinput !w
  98.     else
  99.       sendinput ^c
  100.   }
  101.   return
  102.  ~Alt::
  103.   WinGetClass cos_class, A
  104.   if (cos_class == "Emacs")
  105.     SendInput ^y
  106.   else
  107.     SendInput ^v
  108.   return
  109.   #IfWinNotActive
  110. ;; clipx
  111. ::Help::
  112. ( LTrim
  113. 0:- SAVTO = SAVE TEXT FILE IN BOOK FOLDER
  114. 1:- LBUTTON = SELECT
  115. 2:- CTRL+F = SEARCH IN SELECTED TEXT
  116. 3:- AHK-RUN = AHK SELECTED SCRIPT TEXT SAVE & RUN(TempScript.ahk)
  117. 4:- INSERT = COPY CLIPBOARD DATA
  118. 5:- NIR-RUN = RUN NIRCMD COMMAND SELECTED TEXT
  119. 6:- SAVE = COPY TEXT CLIPBOARD DATA
  120. 7:- F1 = SELECTED OPEN FILE
  121. 9:- F2 = SELECTED OPEN FILE IN NOTEPAD (image)
  122. 9:- BAT-RUN = BATCH SELECTED RUN COMMAND
  123. 10:- BATS-RUN = BATCH SELECTED SCRIPT TEXT SAVE & RUN(TempScript.bat)
  124. 11:- DELETE = DELETE (TempScript.ahk) & (TempScript.bat)
  125. 12:- WIN+R = Reload
  126. 13:- WIN+S = Suspend
  127. 14:- WIN+P = Pause
  128. 15:- ALT = PASTE
  129. 16:- ESC = ExitApp
  130. )
  131. SAVTO:
  132. Gui, Submit, NoHide
  133. FileAppend, %Clipboard%, %PFL%
  134. Return
  135. INSERT::
  136. Run, nircmd.exe shellcopy "%clipboard%" "DATA\" yestoall noerrorui
  137. Return
  138. SAV:
  139. Gui, Submit, NoHide
  140. FileAppend, %Clipboard%;~*.*###############~*.*END SCRIPT~*.*###############*.*~, DATA\NajeebScript.txt
  141. Return
  142. NIR:
  143. Gui, Submit, NoHide
  144. Run, nircmd.exe %Clipboard%
  145. Return
  146. AHK:
  147. Gui, Submit, NoHide
  148. FileAppend, %Clipboard%, DATA\TempScript.ahk
  149. Run, DATA\TempScript.ahk
  150. Return
  151. BAT:
  152. Gui, Submit, NoHide
  153. Run, %comspec% /c %Clipboard%,,hide
  154. Return
  155. BATS:
  156. Gui, Submit, NoHide
  157. FileAppend, %Clipboard%, DATA\TempScript.bat
  158. Run, DATA\TempScript.bat
  159. Return
  160. DEL:
  161. Gui, Submit, NoHide
  162. FileDelete, DATA\TempScript.*
  163. Return
  164. ^f::
  165. GuiControl, Show, Button1
  166. GuiControl, Show, Edit1
  167. Sleep 100
  168. ControlFocus, Edit1, A
  169. Return
  170. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  171. #R::Reload  ;<--  ~ Reload Script ~
  172. #S::Suspend ;<--  ~ Suspend Script ~
  173. #P::Pause   ;<--  ~ Pause Script ~
  174. #M::WinMinimize, ;<--  ~ Minimize Script ~
  175. ESC::ExitApp     ;<--  ~ Exit Script ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement