Advertisement
BizzKeryear

MarketAutoScreenshotTaker.ahk

Dec 26th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Copyright by BiZZ Keryear under CC by-sa 3.0 http://creativecommons.org/licenses/by-sa/3.0/
  2. ;BiZZ Keryear aka MrMegaPussyPlayer
  3. ;each copy must contain these three credits lines
  4. if A_AhkVersion < 1.1.16.05
  5. {
  6.     msgbox ,16,! ! ! ! ! ! ! ! ! Error: Wrong Version of AHK ! ! ! ! ! ! ! ! !, You are using an outdated version of AHK!`n`n`nPlease grab the correct one:`t`tv1.1.16.05 (or later but before 2.x)`n`n`tfrom:`thttp://ahkscript.org/download/`n`nScript will exit after you click ok.
  7.     ExitApp
  8. }
  9. else if A_AhkVersion => 2.
  10. {
  11.     msgbox ,16,! ! ! ! ! ! ! ! ! Error: Wrong Version of AHK ! ! ! ! ! ! ! ! !, You are using a wrong version of AHK!`nThis script is not compatible with the experimental 2.x or later`n`nPlease grab the correct one:`t`tv1.1.16.05 (or later but before 2.x)`n`n`tfrom:`thttp://ahkscript.org/download/`n`nScript will exit after you click ok.
  12.     ExitApp
  13. }
  14. EnvGet, PROGRAMFILESX86, PROGRAMFILES(X86)
  15. ifexist %PROGRAMFILES%\MiniCap\MiniCap.exe
  16. {
  17.     minicap=%PROGRAMFILES%\MiniCap
  18. }
  19. else ifnotexist %PROGRAMFILESX86%\MiniCap\MiniCap.exe
  20. {
  21.     msgbox ,16,! ! ! ! ! ! ! ! ! Error: MiniCap not found ! ! ! ! ! ! ! ! !, This programm needs MiniCap to work`n`nPlease go and grab it @ http://www.donationcoder.com/Software/Mouser/MiniCap/index.html`nThis script is only searching for MiniCap in the default folder`n`nScript will restart after you click ok.
  22.     reload
  23. }
  24. else
  25.     minicap=%PROGRAMFILESX86%\MiniCap
  26. screens:=20 ;pages to shot
  27. maxscreens:=20 ;max pages to shot
  28. DefaultPicturePath= %USERPROFILE%\Pictures\Frontier Developments\Elite Dangerous
  29.  
  30. Menu, TRAY, Tip , Elite Dangerous Market Auto Screenshot Taker Beta 0.5
  31. Menu, TRAY, NoStandard
  32. Menu, TRAY, Add , Exit Script , ExitSub
  33. Menu, TRAY, Add , Reload Script , ReloadSub
  34. Menu, TRAY, Add
  35. Menu, TRAY, Add , Change Settings, SettingsGui
  36. Menu, TRAY, Default , Change Settings
  37.  
  38. ;----------------------Mainprogram-----------------
  39. IfNotExist ScreenGrab.ini
  40. {
  41.     gosub reset
  42.     sleep 100
  43.     gosub settingsgui
  44.     /*
  45.     to do:
  46.     write errorhandler
  47.     */
  48. }
  49. else
  50. {
  51.     ;IniRead, OutputVar, Filename [, Section, Key, Default]
  52.     IniRead, hotkey, ScreenGrab.ini , Keysettings , Hotkey
  53.     IniRead, Win, ScreenGrab.ini , Keysettings , Win
  54.     IniRead, PicturePath, ScreenGrab.ini , PathSettings , PicturePath
  55.     gosub parsekey
  56.     Hotkey , %ParsedKey% , ScreenLoop , On
  57. }
  58.  
  59. ;-------------Functions----------------------
  60. dummy:
  61. return
  62.  
  63. SettingsGui:
  64.     Gui, 1:Add, Text, x36 y7 w586 h190 , ED Market Auto Screenshot Taker:`n`tTakes Screenshots of all Comodities availible in the current Market.`n`n`tUsage:`n`t`tSet up here. (Setup is later availble from the Tray icon context menu or by double clicking the tray icon)`n`t`tPress Hotkey while in ED Comodity Market abd wait for all the shoots to happen.`n`t`tPress OK, save and make the Hotkey active`n`n`tImportant! Keep hands of controls while the grabing is happen.`n`n`t`t`t"Change Settings" will bring up this menu`n`t`t`tThe rest of Menu should be selfexplaining`nTo Do: Implementing reading ED control settings for more comfort. `t Writing Errorhandlers for more stability`nCopyright by BiZZ Keryear under CC by-sa 3.0 http://creativecommons.org/licenses/by-sa/3.0/
  65.     Gui, 1:Add, Text, x6 y207 w110 h20 , Assigned Hotkey:
  66.     Gui, 1:Add, Checkbox, x126 y207 h20 vWin Checked%Win%, Win key+
  67.     Gui, 1:Add, Hotkey, x190 y207 w230 h20 vhotkey, %hotkey%
  68.     Gui, 1:Add, Text, x430 y202 w230 h40, (field can contain any key, but win key.`nWin key has to be assigned with checkbox)
  69.     Gui, 1:Add, Text, x6 y237 w110 h20 , Save Screenshots to:
  70.     Gui, 1:Add, Text, x126 y237 w470 h20 , %PicturePath%
  71.     Gui, 1:Add, Button, x606 y237 w60 h20 gChange, Change
  72.     Gui, 1:Add, Button, x190 y267 w100 h30 Default ,&OK
  73.     Gui, 1:Add, Button, x410 y267 w100 h30 gResetd ,&Reset to default
  74.     Gui, 1:Show,, ED Market Auto Screenshot Taker Beta 0.5 -- Settings:
  75. Return
  76.  
  77. Change:
  78.     inputbox , nPicturePath , Change Path to Screenshoots, Type or Paste in here the path where the screenshots shall be saved:,,800,120,,,,,%PicturePath%
  79.     if Errorlevel
  80.         Errorlevel =
  81.     else
  82.     {
  83.         PicturePath := nPicturePath
  84.         nPicturePath =
  85.     }
  86.     gui , 1:destroy
  87.     gosub SettingsGui
  88. return
  89.  
  90. ButtonOK:
  91.     Gui, 1:submit
  92.     gosub WriteSettings
  93.     reload
  94. return
  95.  
  96. parsekey:
  97.     if Win = 1
  98.         ParsedKey=#
  99.     else
  100.         ParsedKey=
  101.     ParsedKey=%ParsedKey%%hotkey%
  102. return
  103.  
  104. resetd:
  105.     gosub reset
  106.     gosub WriteSettings
  107.     Gui, 1:destroy
  108.     gosub SettingsGui
  109. return
  110.  
  111. reset:
  112.     PicturePath:=DefaultPicturePath
  113.     hotkey=y
  114.     Win:=1
  115. return
  116.  
  117. ScreenLoop:
  118.     SetKeyDelay , 0 , 80 ; set key delay so down key will be fetched
  119.     loop %screens%
  120.     {
  121.         gosub EliteAction
  122.         if TestEnd = 1
  123.         {
  124.             screens := A_Index
  125.             break ;, down
  126.         }
  127.  
  128.     }
  129.     SetKeyDelay , -1 , -1 ; reset key delay
  130.     screens=maxscreens ;cleanup
  131. return
  132.  
  133. WriteSettings:
  134.     IniWrite, 0.5 , ScreenGrab.ini, Version , Version
  135.     IniWrite, %hotkey% , ScreenGrab.ini, Keysettings , Hotkey
  136.     IniWrite, %Win% , ScreenGrab.ini, Keysettings , Win
  137.     IniWrite, %PicturePath% , ScreenGrab.ini, PathSettings , PicturePath
  138. return
  139.  
  140. EliteAction:
  141.     CoordMode , Mouse , Window
  142.     WinActivate , Elite - Dangerous (CLIENT) ahk_class FrontierDevelopmentsAppWinClass
  143.     WinwaitActive , Elite - Dangerous (CLIENT) ahk_class FrontierDevelopmentsAppWinClass
  144.     MouseMove , 1218, 895 ,5 ;mouse in market second last row to make it scroll
  145.     MouseMove , 1218, 920 ,5 ;place to last row so last row is active no matter what
  146.     if A_Index = 1
  147.     {
  148.         loop 100 ; scroll to top
  149.         {
  150.             Send {WheelUp}
  151.             Sleep 10
  152.         }
  153.     Sleep 100 ; make sure program catches up
  154.     }
  155.     else
  156.     {
  157.         loop 4 ; scroll a page down
  158.         {
  159.             Send {WheelDown}
  160.             sleep 300
  161.         }
  162.         Send s
  163.        
  164.     }
  165.     sleep 100 ; give it a moment to appear
  166.     loop 3 ; improve regonition by test more than once ... 10 took too long three will have to do
  167.     {
  168.         PixelSearch,,, 233, 963, 268, 989, 0x35A5FF , 35 ;color may vary so high tollerance
  169.         if !ErrorLevel
  170.             TestEnd:=1
  171.         ;sleep 10 ; give it a very little time ... took too long reliable but too slow has to work this way
  172.     }
  173.     Mousemove , 1596, 360 , 5 ; Side pannnel = clears highlight
  174.     SoundPlay, %minicap%\CAMERA.WAV ; feedback shot is taken
  175.     runwait , %minicap%\MiniCap.exe -closeapp -exit -captureactivewin -save "%PicturePath%\Screenshot_$uniquenum0$.png" -compress 10 , %minicap% ,, miniid ;use Hide in empty space if things are working out
  176. return
  177.  
  178. ExitSub:
  179.     ExitApp
  180. return
  181.  
  182. ReloadSub:
  183.     reload
  184. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement