Advertisement
Najeebsk

RUN-SCRIPT-DIRECTLY.ahk

Apr 17th, 2023 (edited)
1,719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*   INFO
  2.    NAJEEB RUN SCRIPT DIRECTLY
  3.    Written by: Najeeb Shah Khan (najeebshahkhan@gmail.com)
  4.    Last Modified: 3-25-2023
  5. */
  6. ;#warn
  7. #NoEnv
  8. #SingleInstance
  9. ;#NoTrayIcon
  10. SetWorkingDir, %A_WorkingDir% ;%A_ScriptDir%
  11. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  12. FileCreateDir, %A_ScriptDir%\DATA
  13. FileInstall , RUN-SCRIPT-DIRECTLY.ahk, %A_ScriptDir%\DATA\RUN-SCRIPT-DIRECTLY.ahk, 1
  14. FileSetAttrib +HS, %A_ScriptDir%\DATA\RUN-SCRIPT-DIRECTLY.ahk, 2
  15. FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
  16. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  17. ClipSaved =
  18. ScriptText =
  19.  
  20. F1::      ; F1 only: Run highlighted text
  21.   ControlGetText, URL, Edit1, ahk_class IEFrame
  22.   ClipSaved := ClipboardAll
  23.   Send, ^c
  24.   ifExist AHKscript.ahk
  25.     FileDelete AHKscript.ahk
  26.   ScriptText = `; %URL%`r`n`; `r`n%Clipboard%
  27.   FileAppend, %ScriptText%`r`n, AHKscript.ahk
  28.   Clipboard := ClipSaved
  29.   ClipSaved =
  30.   ScriptText =
  31.   run, AHKscript.ahk
  32. Return
  33.  
  34. F2::     ; F2: Edit then run
  35.   ControlGetText, URL, Edit1, ahk_class IEFrame
  36.   ClipSaved := ClipboardAll
  37.   Send, ^c
  38.   ifExist AHKscript.ahk
  39.     FileDelete AHKscript.ahk
  40.   ScriptText = `; %URL%`r`n`; `r`n%Clipboard%
  41.   FileAppend, %ScriptText%`r`n, AHKscript.ahk
  42.   Clipboard := ClipSaved
  43.   ClipSaved =
  44.   ScriptText =
  45.   runwait, edit AHKscript.ahk
  46.   run, AHKscript.ahk
  47. Return
  48.  
  49. F3::     ; F3: Save last script
  50. IfExist AHKscript.ahk
  51. {
  52.   FileSelectFile, destination, S16, %A_Desktop%, Save Script:, Autohotkey Scripts (*.ahk)
  53.   If ERRORLEVEL
  54.     Msgbox, Script not saved.
  55.   Else
  56.   {
  57.     IfNotInString, destination, .ahk
  58.       destination = %destination%.ahk    
  59.     FileCopy, AHKscript.ahk, %destination%, 1
  60.   }
  61. }
  62. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement