Guest User

Untitled

a guest
Feb 10th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 8.71 KB | None | 0 0
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_icon=miner.ico
  3. #AutoIt3Wrapper_outfile=mINe.exe
  4. #AutoIt3Wrapper_UseX64=n
  5. #AutoIt3Wrapper_Res_Comment=For generating bitcoins in the Imagine Nation UO Pool
  6. #AutoIt3Wrapper_Res_Description=Automatially sets up the .bat and .exe files to mine @ Deepbit.net for IN-UO
  7. #AutoIt3Wrapper_Res_Fileversion=1.0.0.6
  8. #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
  9. #AutoIt3Wrapper_Res_LegalCopyright=eru@in-uo.com
  10. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  11. #cs ----------------------------------------------------------------------------
  12.  
  13.  AutoIt Version: 3.3.6.1
  14.  Author:         myName
  15.  
  16.  Script Function:
  17.     Template AutoIt script.
  18.  
  19. #ce ----------------------------------------------------------------------------
  20.  
  21. ; Script Start - Add your code below here
  22.  
  23. #include <GUIConstantsEX.au3>
  24. #include <WindowsConstants.au3>
  25. #include <Constants.au3>
  26. AutoItSetOption("TrayAutoPause",0)
  27. AutoItSetOption("TrayMenuMode",1)
  28. AutoItSetOption("TrayOnEventMode",1)
  29. TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN,"Toggle")
  30. TraySetState()
  31. Global $SourcePath = "C:\Users\Eremite\Dropbox\Imagine Nation\mining\"
  32. Global $BatFile = @TempDir & "\mINe.bat"
  33. Global $GUIStyle = BitOr($WS_POPUP,$WS_MINIMIZEBOX)
  34. Global $Running = False, $Minimized = False
  35. Global $IniFile = @ScriptDir & "\Settings.ini"
  36.  
  37.  
  38. $GUI = GUICreate("mINer",200,100,-1,-1,$GUIStyle,0x00000008)
  39. GUISetBkColor(0x000000,$GUI)
  40. FileInstall("C:\Users\Eremite\Dropbox\Imagine Nation\mining\inlogo.gif",@TempDir & "\inlogo.gif")
  41. GUICtrlCreatePic(@TempDir & "\inlogo.gif",147,10,53,53,-1,0x00100000)
  42. $INLabel = GUICtrlCreateLabel("Imagine Nation",1,1,135,20)
  43. GUICtrlSetColor($INLabel,0xF5EC95)
  44. GUICtrlSetFont($INLabel,14,1000,-1,"Lucida")
  45. $WorkerStatus = GUICtrlCreateLabel("Updating Worker Stats",1,21,147,12)
  46. GUICtrlSetColor($WorkerStatus,0xF5EC95)
  47. $PayoutStatus = GUICtrlCreateLabel("Updating Payout Stats",1,33,147,12)
  48. GUICtrlSetColor($PayoutStatus,0xF5EC95)
  49. $HSpacer = GUICtrlCreateLabel("",1,46,147,3)
  50. GUICtrlSetBkColor($HSpacer,0xF5EC95)
  51. $GPUCPU = GUICtrlCreateRadio("",1,51,12,12)
  52. $CPUGPULabel = GUICtrlCreateLabel("GPU+CPU",15,50,57,12)
  53. GUICtrlSetColor($CPUGPULabel,0xF5EC95)
  54. $GPUOnly = GUICtrlCreateRadio("",1,63,12,12)
  55. $GPUOnlyLabel = GUICtrlCreateLabel("GPU Only",15,62,57,12)
  56. GUICtrlSetColor($GPUOnlyLabel,0xF5EC95)
  57. $CPUOnly = GUICtrlCreateRadio("",1,75,12,12)
  58. $CPUOnlyLabel = GUICtrlCreateLabel("CPU Only",15,74,57,12)
  59. GUICtrlSetColor($CPUOnlyLabel,0xF5EC95)
  60. $CPUCoreLabel1 = GUICtrlCreateLabel("Use",1,87,18,12)
  61. GUICtrlSetColor($CPUCoreLabel1,0xF5EC95)
  62. $CPUCores = GUICtrlCreateInput(IniRead($IniFile,"Settings","CPUCores",""),20,85,22,15)
  63. GUICtrlSetColor($CPUCores,0x000000)
  64. GUICtrlSetBkColor($CPUCores,0xF5EC95)
  65. $CPUCoreLabel2 = GUICtrlCreateLabel("cores",42,87,25,12)
  66. GUICtrlSetColor($CPUCoreLabel2,0xF5EC95)
  67. $VSpace = GUICtrlCreateLabel("",78,49,3,50)
  68. GUICtrlSetBkColor($VSpace,0xF5EC95)
  69. $MiningStart = GUICtrlCreateButton("mINe",83,51,67,30)
  70. GUICtrlSetColor($MiningStart,0x000000)
  71. GUICtrlSetBkColor($MiningStart,0xF5EC95)
  72. $Hidden = GUICtrlCreateCheckbox("",83,81,15,19)
  73. $HiddenLabel = GUICtrlCreateLabel("Hidden",98,83,52,19)
  74. GUICtrlSetColor($HiddenLabel,0xF5EC95)
  75. $User = GUICtrlCreateInput(IniRead($IniFile,"Settings","User","anon"),150,61,47,18)
  76. GUICtrlSetBkColor($User,0xF5EC95)
  77. GUICtrlSetColor($User,0x000000)
  78. $Help = GUICtrlCreateButton("Help",150,80,50,20)
  79. GUICtrlSetBkColor($Help,0xF5EC95)
  80. GUICtrlSetColor($Help,0x000000)
  81. $Exit = GUICtrlCreateButton("X",185,0,15,10)
  82. GUICtrlSetBkColor($Exit,0xF5EC95)
  83. GUICtrlSetColor($Exit,0x000000)
  84. $Minimize = GUICtrlCreateButton("-",170,0,15,10)
  85. GUICtrlSetColor($Minimize,0x000000)
  86. GUICtrlSetBkColor($Minimize,0xF5EC95)
  87. $Mode = IniRead($IniFile,"Settings","Mode","GPUCPU")
  88. If $Mode = "GPUCPU" Then
  89.     GUICtrlSetState($GPUCPU,$GUI_Checked)
  90. ElseIf $Mode = "GPUOnly" Then
  91.     GUICtrlSetState($GPUOnly,$GUI_Checked)
  92. Else
  93.     GUICtrlSetState($CPUOnly,$GUI_Checked)
  94. EndIf
  95. If IniRead($IniFile,"Settings","Hidden","False") = "True" Then GUICtrlSetState($Hidden,$GUI_Checked)
  96. If ProcessExists("bitcoin-miner.exe") Then
  97.     GUICtrlSetData($MiningStart,"STOP")
  98.     $Running = True
  99. EndIf
  100. GUISetState(@SW_SHOW)
  101. $Update = Timerinit()
  102. UpdateStats()
  103.  
  104. While 1
  105.     $Msg = GUIGetMsg()
  106.     Select
  107.         Case $Msg = $GUI_Event_Close Or $Msg = $Exit
  108.             IniWrite($IniFile,"Settings","User",GUICtrlRead($User))
  109.             If GUICtrlRead($GPUCPU) = 1 Then $Mode = "GPUCPU"
  110.             If GUICtrlRead($GPUOnly) = 1 Then $Mode = "GPUOnly"
  111.             If GUICtrlRead($CPUOnly) = 1 Then $Mode = "CPUOnly"
  112.             IniWrite($IniFile,"Settings","Mode",$Mode)
  113.             If GUICtrlRead($Hidden) = 1 Then
  114.                 IniWrite($IniFile,"Settings","Hidden","True")
  115.             Else
  116.                 IniWrite($IniFile,"Settings","Hidden","False")
  117.             EndIf
  118.             IniWrite($IniFile,"Settings","CPUCores",GUICtrlRead($CPUCores))
  119.             Exit
  120.         Case $Msg = $Minimize
  121.             GUISetState(@SW_HIDE,$GUI)
  122.         Case $Msg = $MiningStart
  123.             If $Running = False Then
  124.                 StartMiner()
  125.             Else
  126.                 StopMiner()
  127.             EndIf
  128.         Case $Msg = $Help
  129.             MsgBox(0,"What do?!","This will automatically create the batch file and add the programs you need to start mining.  Files are placed in the %temp% directory and are overwritten every time you start the program." & @CRLF & @CRLF & _
  130.                 "Select whether you want to use CPU, GPU or both on the left.  GPU gives much higher returns usually." & @CRLF & "If you are using CPU, you can set the number of cores to use at the bottom left." & @CRLF & _
  131.                 "If you check the 'Hidden' checkbox, then it will run the miner in the background without a console window." & @CRLF & @CRLF & "Enter your miner's username in the right-hand side above help." & @CRLF & _
  132.                 "If you don't have a username, PM Eru on the forums to get one added." & @CRLF & @CRLF & "Once everything is configured, press the 'mINe' button to start, then 'STOP' to quit mining." & @CRLF & @CRLF & _
  133.                 "Stats are displayed at the top of the screen and update once per minute." & @CRLF & @CRLF & "                       Happy Mining!" & @CRLF & "                                   -eru")
  134.     EndSelect
  135.     Sleep(100)
  136.     If TimerDiff($Update) > 60000 Then UpdateStats()
  137. WEnd
  138.  
  139. Func StartMiner() ; active = 1 inactive = 4
  140.     FileInstall("C:\Users\Eremite\Dropbox\Imagine Nation\mining\bitcoin-miner.exe",@TempDir & "\bitcoin-miner.exe")
  141.     FileDelete($BatFile)
  142.     Local $Variables = '-a 5 -o http://[email protected]_' & GUICtrlRead($User) & ':[email protected]:8332'
  143.     If GUICtrlRead($GPUCPU) = 1 And GUICtrlRead($CPUCores) <> "" Then $Variables = $Variables & " -t " & GUICtrlread($CPUCores)
  144.     If GUICtrlRead($CPUOnly) = 1 Then
  145.         $Variables = $Variables & " -g no"
  146.         If GUICtrlRead($CPUCores) <> "" Then
  147.             $Variables = $Variables & " -t " & GUICtrlRead($CPUCores)
  148.         EndIf
  149.     EndIf
  150.     If GUICtrlRead($GPUOnly) = 1 Then $Variables = $Variables & " -t 0"
  151.     If GUICtrlRead($Hidden) = 1 Then
  152.         FileInstall("C:\Users\Eremite\Dropbox\Imagine Nation\mining\hide.exe",@TempDir & "\hide.exe")
  153.         FileWrite($BatFile,'start /D "' & @TempDir & '\" hide "' & @TempDir & '\bitcoin-miner.exe ' & $Variables & '"')
  154.     Else
  155.         FileWrite($BatFile,'start /D "' & @TempDir & '\" bitcoin-miner.exe ' & $Variables)
  156.     EndIf
  157.     ShellExecute($BatFile)
  158.     GUICtrlSetData($MiningStart,"STOP")
  159.     $Running = True
  160. EndFunc
  161.  
  162. Func StopMiner()
  163.     Do
  164.         ProcessClose("bitcoin-miner.exe")
  165.         Sleep(500)
  166.     Until Not ProcessExists("bitcoin-miner.exe")
  167.     GUICtrlSetData($MiningStart,"mINe")
  168.     $Running = False
  169. EndFunc
  170.  
  171. Func Toggle()
  172.     If $Minimized = False Then
  173.         GUISetState(@SW_HIDE,$GUI)
  174.         $Minimized = True
  175.     Else
  176.         GUISetState(@SW_SHOW,$GUI)
  177.         $Minimized = False
  178.     EndIf
  179. EndFunc
  180.  
  181. Func UpdateStats()
  182.     $JSON = GetJSON()
  183.     $TotalReward = StringRegExpReplace($JSON,'{"confirmed_reward":([0-9]*\.[0-9]*).*',"$1")
  184.     $TotalPayouts = StringRegExpReplace($JSON,'.*,"payout_history":(.*),"workers":.*',"$1")
  185.     $HashRate = StringRegExpReplace($JSON,'.*hashrate":(.*),"ipa":.*',"$1")
  186.     $JSON = StringRegExpReplace($JSON,'{"confirmed.*workers":{(.*)}}',",$1")
  187.     $JSON = StringTrimLeft(StringRegExpReplace($JSON,',"[email protected]_',"|",0),1)
  188.     Global $TotalWorkers = StringSplit($JSON,"|")
  189.     Global $ActiveWorkers = 0
  190.     For $i = 1 To UBound($TotalWorkers) - 1 Step 1
  191.         If StringRegExpReplace($TotalWorkers[$i],'.*{"alive":(.*),"shares.*}',"$1") = "true" Then $ActiveWorkers = $ActiveWorkers + 1
  192.     Next
  193.     GUICtrlSetData($WorkerStatus,$ActiveWorkers & "/" & $TotalWorkers[0] & " @ " & $HashRate & " Mhash/s")
  194.     GUICtrlSetData($PayoutStatus,"Gen:"& StringTrimRight($TotalReward,4) & " -=- Paid" & $TotalPayouts)
  195.     $Update = Timerinit()
  196. EndFunc
  197.  
  198. Func GetJSON()
  199.     InetGet("http://deepbit.net/api/4e9b6b9b06917228d7000000_667F4B01C3",@TempDir & "\JSON.txt",1)
  200.     Local $Return = FileReadLine(@TempDir & "\JSON.txt",1)
  201.     FileDelete(@TempDir & "\JSON.txt")
  202.     Return $Return
  203. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment