Monday, April 8, 2013

An updated script to change your gmail password to previous ones!

I lost my MotoACTV watch which I loved so much, and as a results I've changed my gmail and other passwords. But I just realized I could do better by installing programs like AndroidLost to maybe find the android watch.

The problem was I couldn't revert back to my previous password so I can install programs remotely on my android via Google Play Store.

So i searched the web and came into this great weblog.

The mentioned code had problems running, so I've changed it a little bit and I am putting it here for you!

look for "You should only edit these values" and change ???? into appropriate values.

save it into an .vbs file and then run
 
%windir%\SysWoW64\cmd.exe
cscript your file name.vbs 


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Declare Variables & Objects
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim oShell
Dim oAutoIt

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Initialise Variables & Objects
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Set oShell = WScript.CreateObject("WScript.Shell")
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

WScript.Echo "This script will reset your google password 100 times so you can use an old password."

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You should only edit these values
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

sUN = "myemail@gmail.com" ' Your Google username (email address)
curPW = "?????????" ' Replace with the Current password to your google account
oldPW = "?????????" ' Replace with the final password you want assigned to the account. The one you want to set the account's password *back to*. 

' If your password has a quote in it ("), then use "" in its place.
' For example, let's say your password was 
' MyPass"word!-55
'
' The proper VBScript way to put that into a variable would look like this
' curPW = "MyPass""word!-55"
'
' See Microsoft's website for more detail

' An easy way to find this is to right click the Chrome shortcut and copy the value in Target.
' Click Start, type Chrome, right click Google Chrome, click Properties, copy *everything* in Target, and put it here.
ChromeEXE = "C:\Users\??????\AppData\Local\Google\Chrome\Application\chrome.exe" ' Where is the Chrome executable? Replace this with its location.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You should not have to edit anything after this
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Start of Script
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


'Some of this code uses the AutoIT com object. See their documentation for more details.

oShell.Run ChromeEXE, 1, False

' Wait for the Notepad window to become active
oAutoIt.WinWaitActive "New Tab - Google Chrome", ""
oAutoIt.Sleep 4000

WScript.Echo "Entering Loop"
' Enter the loop, change the password 99 more times
tCurPw = curPW

    oAutoIt.Send "!d"
    oAutoIt.Sleep 250    
    oAutoIt.Send "https://accounts.google.com/Login{ENTER}"
    oAutoIt.Sleep 5000


For x = 1 To 99
    WScript.Echo "Step " & x
    WScript.Echo "Current PW: " & tCurPw
    tNewPW = curPW & x
    WScript.Echo "Setting the password to: " & tNewPW
    
    GLogin sUN, tCurPw
    GEditPW
    oAutoIt.Send tCurPw & "{TAB} {TAB}"
    oAutoIt.Sleep 250
    oAutoIt.Send tNewPW & "{TAB}"
    oAutoIt.Sleep 250
    oAutoIt.Send tNewPW & "{TAB}"
    oAutoIt.Sleep 250
    oAutoIt.Send "{ENTER}"
    oAutoIt.Sleep 2500
    
    tCurPw = tNewPW

    GLogout
Next 

WScript.Echo "Final Change"
GLogin sUN, tCurPw
GEditPW

oAutoIt.Send tCurPw & "{TAB}"
oAutoIt.Sleep 250
oAutoIt.Send oldPW & "{TAB}"
oAutoIt.Sleep 250
oAutoIt.Send oldPW & "{TAB}"
oAutoIt.Sleep 250
oAutoIt.Send "{ENTER}"
oAutoIt.Send "https://www.google.com/accounts/Logout{ENTER}"
oAutoIt.Sleep 4000
WScript.Echo "Password reset"




WScript.Quit

Function GLogin(un, pw) ' Opens the Google Login page, enters the supplied Username (un) and Password (pw), and presses Enter.
    WScript.Echo "Logging in: " & un & ", " & pw
    'oAutoIt.Send "!d"
    'oAutoIt.Sleep 550    
    'oAutoIt.Send "https://accounts.google.com/Login{ENTER}"
    'oAutoIt.Sleep 4000
    oAutoIt.Send un & "{TAB}"
    oAutoIt.Send pw & "{ENTER}"
    oAutoIt.Sleep 5000

End Function

Function GEditPW() ' Opens the Google Change Password web page
    oAutoIt.Send "!d"
    oAutoIt.Send "!d"
    oAutoIt.Sleep 250
    oAutoIt.Send "https://accounts.google.com/b/0/EditPasswd{ENTER}"
    oAutoIt.Sleep 3000
End Function

Function GLogout() ' Logs out from google. This is necessary for the password change to take effect. Trust me, I tried to do it without logging out. No luck.
    WScript.Echo "Logging out"
    oAutoIt.Send "!d"
    oAutoIt.Send "!d"
    oAutoIt.Sleep 250
    oAutoIt.Send "https://www.google.com/accounts/Logout{ENTER}"
    oAutoIt.Sleep 3000

End Function

Friday, March 29, 2013

My solution for HP Envy 14 Beat Edition overheating and shutdown!

I was having issues with my Envy 14, overheating and then shutting down (in Windows 7).
My temporary solution was to switch to Intel graphics card and never use my dedicated graphic card.
Whenever I switched to my dedicated graphic card (AMD Radeon HD) it would heat up in 20 minutes with great fan noise and eventually shutting down.

I've just discovered if you install newer AMD drivers on top of HP provided ones you can have switchable graphics card and also a working Radeon HD card. Also generally fan noise is greatly reduced.

Here are the links I've used :

Original HP drivers :
http://ftp.hp.com/pub/softpaq/sp50501-51000/sp50656.exe

AMD drivers I've installed on top of that:
http://www2.ati.com/Drivers/mobile/13-1_mobility_vista_win7_win8_64_dd_ccc_whql.exe

Sunday, December 30, 2012

Automatic numbering of equations in MS Word with help of a VBA Macro

Imagine you have to compile a report in Office Word format and you have many equations which need to equation numbering. Microsoft does not provide an automated solution for this as many Project formatting guidelines require you to have equation alignment on center and equation number aligned on rights side.

Thought Microsoft provided an VBA script in their online web site. The script did not work the way it should be so I modified it and improved it a little bit.

Select equations you want to be captioned, and run this script  Sometimes you need to have "Enter" pressed after the equation or 2 or more enters. If something went wrong just press undo.

I've assigned CTRL+SHIFT+X to this Macro, and in a minute you can have all your equations numbered.

Enjoy




Sub CaptionRight()

   Dim Align As Integer
   On Error GoTo Bye
   Dim rng As Range, rngNew As Range

    If Selection.Range = "" Then
        Selection.HomeKey Unit:=wdLine
        Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    End If

    Set rng = Selection.Range
    
' If insertion point is in a table, show message and end macro.
   If Selection.Information(wdWithInTable) Then
      MsgBox "You are in a table. Please move outside of the " _
         & "table to run this macro.", vbInformation
      GoTo Bye
   End If


   ' Ask whether to center or left align equation.
   Align = MsgBox("Would you like the Equation to be " & "centered? " _
      & "(Selecting No will left-align the " & "Equation.)", vbYesNoCancel)

   If Align > 2 Then
      Selection.InsertParagraphAfter
      Selection.Collapse Direction:=wdCollapseEnd
      W = Selection.Sections(1).PageSetup.PageWidth
      L = Selection.Sections(1).PageSetup.LeftMargin
      R = Selection.Sections(1).PageSetup.RightMargin
      RTMarg = W - R - L
      CaptionLabels.Add Name:="("

      If Align = 6 Then
         tblT1 = Selection.Tables.Add(Selection.Range, 1, 3)
      Else
         tblT1 = Selection.Tables.Add(Selection.Range, 1, 2)
      End If

      tblT1.Select

      With Selection
         ' Do this if Center-align selected.
         If Align = 6 Then
            .Columns(1).Cells.Width = 20
            .Columns(3).Cells.Width = 50.4
            .Columns(2).Cells.Width = RTMarg - (50.4 + 20)

            'Represents 1.5" in Points
         Else
         ' Do this if Left-align selected.
            .Columns(2).Cells.Width = 50.4
            .Columns(1).Cells.Width = RTMarg - 50.4
            'Represents .75" in Points
         End If

         .InsertCaption Label:="(", _
            Position:=wdCaptionPositionBelow, Title:=" )"
         .HomeKey Unit:=wdLine, Extend:=wdExtend
         .Cut
         .MoveRight Unit:=wdCharacter, Extend:=wdExtend
         .Delete
         .MoveLeft Unit:=wdCharacter, Count:=2
         .Paste
         .Rows(1).Select

        ' Set the table borders to None.
         For Each x In Selection.Borders
            x.LineStyle = wdLineStyleNone
         Next x

         .Borders.Shadow = False
         .Cells(9 - Align).Select
         .ParagraphFormat.Alignment = wdAlignParagraphRight
         .Cells(1).VerticalAlignment = wdCellAlignVerticalCenter
         .Font.Bold = True
         .Rows(1).Select

         If Align = 6 Then
            .Cells(2).Select
            .ParagraphFormat.Alignment = wdAlignParagraphCenter
         Else
            .Collapse
         End If
      End With
   End If

Bye:
Set rngNew = Selection.Range
rng.Select
rng.Cut
rngNew.Paste
End Sub