Jump to content
Sign in to follow this  
Svrij22

Admob Desktop Widget

Recommended Posts

Svrij22

Hello Autoit,

I recently made a cool little program that I wanted to share with you guys. I don't know if any of you has Admob, but if you do, this program automatically logs all your data and estimates how much you will make this day or month.

Current Features:

*Writes Log

*Average per Hour

*Estimated Month

*Estimated Day

Here's how it works: It opens an IE page, then reads all the text and splits it in an array, then filters the numbers and then calculates all the estimations.

 

I hope some of you will use this

 

Code:

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Date.au3>
#Include <GuiEdit.au3>
HotKeySet ("^g", "show")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Admob Widget", 430, 230, 0, 0)
$Label1 = GUICtrlCreateLabel("Today:", 8, 8, 80, 17)
$Label2 = GUICtrlCreateLabel("Yesterday", 8, 24, 80, 17)
$Label3 = GUICtrlCreateLabel("This Month:", 8, 40, 80, 17)
$Label4 = GUICtrlCreateLabel("Previous Month:", 8, 56, 80, 17)
$Label4 = GUICtrlCreateLabel("Estimated Today:", 8, 72, 185, 17)
$Label4 = GUICtrlCreateLabel("Estimated Month:", 8, 88, 185, 17)
$Label4 = GUICtrlCreateLabel("Average/Hour:", 8, 104, 185, 17)
$state = GUICtrlCreateLabel("State: Logging In", 8, 194, 185, 17)
$sleep = GUICtrlCreateCheckbox("Slow mode", 90, 150, 90, 17)
$Label4 = GUICtrlCreateLabel("Graph Height:", 8, 152, 80, 17)
$Input1 = GUICtrlCreateInput("100", 8, 168, 121, 21)
$Label22 = GUICtrlCreateLabel("v3.8", 140, 174, 121, 21)
$Label5 = GUICtrlCreateLabel("???", 112, 8, 100, 17)
$Label6 = GUICtrlCreateLabel("???", 112, 24, 100, 17)
$Label7 = GUICtrlCreateLabel("???", 112, 40, 100, 17)
$Label8 = GUICtrlCreateLabel("???", 112, 56, 100, 15)
$Label9 = GUICtrlCreateLabel("???", 112, 72, 100, 15)
$Label10 = GUICtrlCreateLabel("???", 112, 88, 100, 15)
$Label11 = GUICtrlCreateLabel("???", 112, 104, 100, 15)
$SmartAvg = GUICtrlCreateCheckbox("Smart Average", 8, 210, 100, 17)
$Button1 = GUICtrlCreateButton("View Log", 8, 120, 75, 25)
$Button2 = GUICtrlCreateButton("Hide", 90, 120, 75, 25)

$editctrl = GUICtrlCreateEdit("", 185, 8, 240, 215, $ES_AUTOVSCROLL + $ES_AUTOHSCROLL)
GUISetState(@sw_SHOW)

#EndRegion ### END Koda GUI section ###

;Starting Log
$NowTime = string (_NowCalc())
$hFileOpen = FileOpen("Log.txt", $FO_APPEND)
FileWrite($hFileOpen,$NowTime & " <--- Started (Widget by Svrij22)--->" & @crlf)

$Ai = 0
$Aval = 0
$Avalp = 0

global $log = ""

CheckLogin()
Refresh()

$i=0
$imax = 300

While 1

$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$sTxtFileDir = @scriptdir & "\Log.txt"
Run ( "notepad.exe " & $sTxtFileDir, @windowsdir, @sw_MAXIMIZE )
Case $Button2
MsgBox ("","","Press CTRL-G To show again")
GUISetState(@sw_hide)
EndSwitch
sleep (60)
$i+=1
if $i>$imax Then
Refresh()
$i=0
EndIf
GUICtrlSetData ($state, "State: Idle "&$i)

if GUICtrlRead($sleep) = $GUI_CHECKED Then
$imax = 900
Else
$imax = 300
EndIf

WEnd

func show()
GUISetState(@sw_SHOW)
EndFunc



Func CheckLogin()
Local $oIE = _IECreate("apps.admob.com", 0, 0, 0)
_IELoadWait($oIE)
sleep (4000)
Local $sText = _IEBodyReadText($oIE)
if StringInStr ($sText,"MONETIZE") Then
GUICtrlSetData ($state, "State: Logged In Succesfully")
sleep (150)
Else
MsgBox ("","","Failed to Retrieve Data. Please Login to your Admob account on Internet Explorer")
$oIE = _IECreate("apps.admob.com",0,1,1)
_IELoadWait($oIE)
WinClose($Form1)
GUICtrlSetData ($state, "State: Error 403")
EndIf
EndFunc

Func Refresh()
GUICtrlSetData ($state, "State: Connecting")
Local $oIE = _IECreate("apps.admob.com", 0, 0, 0)
_IELoadWait($oIE)
sleep (4000)
GUICtrlSetData ($state, "State: Getting Data")
Local $sText = _IEBodyReadText($oIE)
If StringInStr ($sText,"Yesterday") Then ; TEST CONNECTION
$sText = StringRegExpReplace($sText, " ", "")
$sText = StringRegExpReplace($sText, "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]", "")
$sText = StringRegExpReplace($sText, @crlf, "")
$sText = StringRegExpReplace($sText, @cr, "")
$sText = StringRegExpReplace($sText, @lf, "")
$aSplit = StringSplit($sText, "€")
_IEQuit($oIE)
;setdata
$sToday = $aSplit[2]
$sYes = $aSplit[3]
$sTM = $aSplit[4]
$sPM = $aSplit[5]
$sPM = StringTrimRight ($sPM,29)
GUICtrlSetData ($Label5,$sToday&" € Euro")
GUICtrlSetData ($Label6,$sYes&" € Euro")
GUICtrlSetData ($Label7,$sTM&" € Euro")
GUICtrlSetData ($Label8,$sPM&" € Euro")


GUICtrlSetData ($state, "State: Getting Date")
sleep (150)
;Get Date
$sTime2 = string (_NowTime())
$sTime2 = StringTrimRight ($sTime2,3)
$sTime2 = StringReplace ($sTime2,":",".")
$sTime2 = Number ($sTime2)
if $sTime2 > 10 Then
$sDate = @mday
Else
$sDate = @mday-1
EndIf


GUICtrlSetData ($state, "State: Calculating Month Estimation")
sleep (150)
;Calculate Month Estimation
$sAvg = $sTM/$sDate
$sAvg = $sAvg*31
$sAvg = Round ($sAvg,2)
$sAvg = string ($sAvg)
GUICtrlSetData ($Label10,$sAvg&" € Euro")


GUICtrlSetData ($state, "State: Writing Ini for GM Graph")
sleep (150)
;Write ini for GM Graph
$hFileOpen = FileOpen("graph.txt", 2)
FileWrite($hFileOpen,"[graph]" & @crlf)
FileWrite($hFileOpen,"val="&$sToday& @crlf)
FileWrite($hFileOpen,"hei="& GUICtrlRead ($Input1) & @crlf)
FileWrite($hFileOpen,'date="'& string (_NowTime()) &'"'& @crlf)


GUICtrlSetData ($state, "State: Calculating Time")
sleep (150)
;Calculate Time again??
$sTime = string (_NowTime())
$sTime = StringTrimRight ($sTime,3)
$sTime = StringReplace ($sTime,":",".")
$sTime = Number ($sTime)

if $sTime > 10 Then
$sTime -= 10
Else
$sTime += 14
EndIf


GUICtrlSetData ($state, "State: Calculating Average/Hour")
sleep (150)
;Calculate Average/Hour
$sAvgT = $sToday/$sTime
$sAvgT = round ($sAvgT,2)
GUICtrlSetData ($Label11,$sAvgT&" € Euro")


GUICtrlSetData ($state, "State: Calculating Hours Passed")
sleep (150)
;Calculate hours passed
$sTime = string (_NowTime())
$sTime = StringTrimRight ($sTime,3)
$sTime = StringReplace ($sTime,":",".")
$sTime = Number ($sTime)

if $sTime > 10 Then
$sTime -= 10
Else
$sTime += 14
EndIf

GUICtrlSetData ($state, "State: Calculating Day Estimation")
sleep (150)
;Calculate Daily
$sToday = Number ($sToday)
$sEsti = ($sToday/$sTime)*24
$sEsti = round($sEsti,2)
GUICtrlSetData ($Label9,"~"+string($sEsti)&" € Euro")
$NowTime = string (_NowCalc())
$NowTime = string (_NowCalc())


GUICtrlSetData ($state, "State: Calculating Smart Average")
sleep (150)
;SmartAvg Begin
GUICtrlSetData ($state, "State: Calculating Smart Average")
sleep (600)
if GUICtrlRead($SmartAvg) = $GUI_CHECKED Then
$Aval += $sEsti
$Ai+=1
$Avalp = ($Aval/$Ai)*0.85
$sEsti = $Avalp
GUICtrlSetData ($Label9,$Avalp&" € Euro")
EndIf
;SmartAvg End

GUICtrlSetData ($state, "State: Writing Log")
sleep (150)
;Write Log
$hFileOpen = FileOpen("Log.txt", $FO_APPEND)
FileWrite($hFileOpen,$NowTime & " Earnings: " & $sToday & " Avg/Hour: " & $sAvgT & " Estimated Earnings: Today: " & $sEsti & " This month:" & $sAvg & @crlf)



GUICtrlSetData ($state, "State: Calculating GUI Log")
sleep (150)
;Calc gui log
$log=$log & string (_NowTime()) & " E: " & $sToday & " A/H: " & $sAvgT & " ET: " & $sEsti & @CRLF
GUICtrlDelete ($editctrl)
$editctrl = GUICtrlCreateEdit("", 185, 8, 240, 215, $ES_AUTOVSCROLL + $ES_AUTOHSCROLL)
_GUICtrlEdit_InsertText($editctrl,$log)

GUICtrlSetData ($state, "State: Closing IE")
sleep (150)
;Close IE
ProcessClose ("iexplore.exe")
ProcessClose ("iexplore.exe")


Else
GUICtrlSetData ($state, "State: Failed to Retrieve Data")
EndIf

GUICtrlSetData ($state, "State: Cleaning")
sleep (500)
GUICtrlSetData ($state, "State: Idle")
EndFunc

(Sorry if my code isn't so advanced and crappy)

Edited by Svrij22

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • greichert
      By greichert
      I am running an exe, that copies a seperate exe (test123.exe)from my computer and puts it onto a remote server "testserver". Everything  works fine up to this point. I need to run this copied exe (test123.exe) on "testserver" but it keeps running on my computer instead. The code I am using to run the exe is below. What am I doing wrong? How can I get this executable to run on the remote server and not my home computer?
      RunWait( "\\testserver.domain.com\c$\user1\greichert\Desktop\InstallEXE\InstallEXE\test123.exe","\\testserver.domain.com\c$\Users\user1\Desktop\InstallEXE\InstallEXE");run exe  
    • greichert
      By greichert
      I am trying to stop a windows service on a separate server than where my script is running. When I run the following script on the same server as the service I need to stop, it works fine. 
      RunWait(@ComSpec & " /c net stop FascetAgentfv2", @ScriptDir, @SW_HIDE);stop agent But when I change "@ScriptDir" to ""\\newserver\c$\Program Files\test\" and run it on my server nothing happens. I tried to error handle and all it was returning was "2". Any suggestions?
    • ufukreis1212
      By ufukreis1212
      Hello, I am new members. Help me please. I want vbs convert to au3 .
      This vbs code : 
      'deneme Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") strOSArch = GetObject("winmgmts:root\cimv2:Win32_OperatingSystem=@").OSArchitecture Set objNetwork = CreateObject("Wscript.Network") Set wshShell = CreateObject( "WScript.Shell" ) strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) Set oShell = WScript.CreateObject("WScript.Shell") proc_arch = oShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") Set oEnv = oShell.Environment("SYSTEM") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colMB = objWMIService.ExecQuery("Select * from Win32_BaseBoard") Set colCSes = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItemsx = objWMIService.ExecQuery( _ "SELECT * FROM Win32_VideoController",,48) '------------------------------------------------------------------- Set obj = GetObject("winmgmts:").InstancesOf("Win32_PhysicalMemory") i = 1 For Each obj2 In obj memTmp1 = obj2.capacity / 1024 / 1024 TotalRam = TotalRam + memTmp1 i = i +1 Next '-------------------------------------------------------------------- Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select Architecture from Win32_Processor") For Each objItem in colItems if objItem.Architecture = 0 then strArchitecture = "x86" end if if objItem.Architecture = 9 then strArchitecture = "x64" end if next '-------------------------------------------------------------------- strComputer = "." ' Local computer strMemory = "" i = 1 set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory") For Each objItem In colItems if strMemory <> "" then strMemory = strMemory & vbcrlf strMemory = strMemory & "Bank" & i & " : " & (objItem.Capacity /1024 /1024) & " Mb" i = i + 1 Next installedModules = i - 1 Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray") For Each objItem in colItems totalSlots = objItem.MemoryDevices Next '---------------------------------------------------------------------- Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" ) Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem" ) For Each objItem in colItems strComputerDomain = objItem.Domain Next for each System in SystemSet For Each objItem in colItemsx For Each objProcessor in colProcessors For Each bbType In colMB MbVendor = bbType.Manufacturer MbModel = bbType.Product MsgBox "İşletim Sistemi : " & System.Caption & vbNewLine & _ "İşletim Sistemi Versionu : " & + System.Version & vbNewLine & _ "Windows Mimari Yapısı: " & strOSArch & vbNewLine & _ "Kullanıcı isminiz: " & objNetwork.UserName & vbNewLine & _ "Bilgisayar ismi: " & strComputerName & vbNewLine & _ "Çalışma Grubu: " & strComputerDomain & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Anakart: " & MbVendor & " " & "[" & MbModel & "]" & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Grafik Kartı: " & objItem.Caption & vbNewLine & _ "Driver Version: " & objItem.DriverVersion & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "İşlemci Üreticisi: " & objProcessor.Manufacturer & vbNewLine & _ "İşlemci İsmi: " & objProcessor.Name & vbNewLine & _ "CPU Mimarisi: " & strArchitecture & vbNewLine & _ "İşlemci Çekirdek sayısı: " & oEnv("NUMBER_OF_PROCESSORS") & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Toplam RAM: " & TotalRam & " MB" & vbNewLine & _ "Toplam Slot: " & totalSlots & vbNewLine & _ "Boş Slot: " & (totalSlots - installedModules) & vbNewLine & _ "Ramlerin bulunduğu slotlar:" & vbcrlf & strMemory,0,"deneme" Next Next Next Next please help me , thanks.
    • JuanFelipe
      By JuanFelipe
       
      Hello friends, I have a query, it happens that I have a matrix nxn, the first column of this contains each cell a number with 21 digits, when I pass this matrix to Excel I obviously write that number as 1,10016E + 20, I solved it by adding a * at the end of each cell, but I want it to be written as a text so that I do not have to remove that *, I searched in Google but could not find an effective solution, thanks in advance. 
    • Puls3
      By Puls3
      Hi, This is my first post on the AutoIt Forums, I most of the time was able to get help from this community by merely searching though google and have been able to solve hundreds of problems this way, though in this case I was incapable of finding a solution to my problem. I am quite confident that it is a user error (And my fault) but I haven't been able to determine what I did wrong, any and all help would be greatly appreciated! I have uploaded my whole script pardon passwords to provide as much information as possible.
      I declared a global array at the top of the script and am having issues when I try to set it's value, and I fail to understand why.
      Error Message:
      "D:\Projects\AutoIt\Arena\Base.au3" (270) : ==> Subscript used on non-accessible variable.:
      $ExpMax[$i] = IniRead($TempSavePath, "Combatant" & $i, "ExpMax", $ExpMax[0])
      $ExpMax^ ERROR
      ConsoleWrite Log:
      Ran.
      Checking launch parameters.
      No launch parameters.
      Initiating load.
      Checking for save file.
      Save file not found.
      Load canceled.
      Loading or creating Combatant 1
      Base.au3
×