couincouin

Calculator with hidden functions to load tc volume and launch browser.

2 posts in this topic

hello, i'm new to autoit and i've made a script to mount a truecrypt volume and launch a browser.

I wanted to share the script in the other section but it seem that i don't have the right to =)

 

What it do ?

If the truecrypt volume is already mounted Then 
  It launch Chrome using custom user-data-dir
Else
  It launch a normal calculator
  If the Inputext is greater than 4 chars, is not only numbers and Enter is pressed Then
    It use it as password to mount a TC volume & once tc volume is mounted it launch Chrome using custom user-data-dir 

Write "conf" to open options or edit them in the script.

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icon_1.ico
#AutoIt3Wrapper_Outfile=calc.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Res_Description=VAT Calculator
#AutoIt3Wrapper_Res_Fileversion=0.2.0.0
#EndRegion  ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("TrayIconHide", 0)
Opt('GUIOnEventMode', '1')
#include <MsgBoxConstants.au3>
#include <GUIConstants.au3>
#include <Crypt.au3>
$settingskey = DriveGetSerial(@HomeDrive & "\")

If FileExists("history.ini") = 1 Then
    $drive = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "4", ""), $settingskey, $CALG_AES_128))
    $browspath = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "3", ""), $settingskey, $CALG_AES_128))
    $profiledir = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "5", ""), $settingskey, $CALG_AES_128))
    $browser = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "6", ""), $settingskey, $CALG_AES_128))
Else
    $drive = "z"
    $browspath = "C:\Program Files (x86)\Google\Chrome\Application\"
    $profiledir = "\profile\"
    $browser = "chrome"
EndIf

If FileExists($drive & ":/") = 0 Then
    If FileExists("history.ini") = 1 Then
        $hidepass = Binary(_Crypt_DecryptData(IniRead("history.ini", "history", "7", ""), $settingskey, $CALG_AES_128))
        $tcpath = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "1", ""), $settingskey, $CALG_AES_128))
        $file = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "2", ""), $settingskey, $CALG_AES_128))
    Else
        $hidepass = 1
        $tcpath = "C:\Program Files (x86)\TrueCrypt\"
        $file = "C:\file"
    EndIf

    Global $Display_String = '', $Real_String = '', $hid, $1, $2, $3, $5, $4, $6, $7

    $gui = GUICreate("VAT Calculator 2.0", 317, 400, 278, 166)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')
    $Display = GUICtrlCreateInput("0", 24, 32, 265, 35, $ES_RIGHT)
    GUICtrlSetState($Display, $GUI_SHOW)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent(-1, "go")

    _Set_Text()
    GUISetState(@SW_SHOW)

    While ('1')
        Sleep('350')
        If $hidepass = 1 Then
            $pass = GUICtrlRead($Display)
            If StringLen($pass) > 4 And StringIsDigit($pass) = 0 And $hid = 0 And StringInStr($pass, " + ") = 0 And StringInStr($pass, " - ") = 0 And StringInStr($pass, " × ") = 0 And StringInStr($pass, " ÷ ") = 0 And StringInStr($pass, " +VAT ") = 0 And StringInStr($pass, " . ") = 0 Then
                GUICtrlDelete($Display)
                $Display = GUICtrlCreateInput($pass, 24, 32, 265, 35, $ES_PASSWORD + $ES_RIGHT)
                GUICtrlSetFont(-1, 14, 800, 0, "Arial")
                GUICtrlSetOnEvent(-1, "go")
                ControlClick($gui, "", $Display, "left", 1, 260)
                $hid = 1
            EndIf
            If StringLen($pass) < 5 Or StringIsDigit($pass) = 1 And $hid = 1 Then
                GUICtrlDelete($Display)
                $Display = GUICtrlCreateInput($pass, 24, 32, 265, 35, $ES_RIGHT)
                GUICtrlSetFont(-1, 14, 800, 0, "Arial")
                GUICtrlSetOnEvent(-1, "go")
                ControlClick($gui, "", $Display, "left", 1, 260)
                $hid = 0
            EndIf
        EndIf
    WEnd
EndIf
brows()

Exit

Func options()
    GUICtrlSetData($Display, "")
    GUISetState(@SW_DISABLE, $gui)
    GUICreate("Config", 317, 400, 598, 166, $WS_CAPTION)
    GUICtrlCreateLabel("TC path", 5, 22)
    GUICtrlCreateLabel("Volume", 5, 47)
    GUICtrlCreateLabel("Browser path", 5, 72)
    GUICtrlCreateLabel("Drive", 5, 97)
    GUICtrlCreateLabel("Profile path", 5, 122)
    GUICtrlCreateLabel("Browser", 5, 147)
    $1 = GUICtrlCreateInput($tcpath, 70, 20, 240, 20)
    $2 = GUICtrlCreateInput($file, 70, 45, 240, 20)
    $3 = GUICtrlCreateInput($browspath, 70, 70, 240, 20)
    $4 = GUICtrlCreateInput($drive, 70, 95, 240, 20)
    GUICtrlSetLimit(-1, 1)
    $5 = GUICtrlCreateInput($profiledir, 70, 120, 240, 20)
    $6 = GUICtrlCreateCombo($browser, 70, 145, 240, 20)
    $7 = GUICtrlCreateCheckbox("Hide password", 70, 170, 240, 20)
    If $hidepass = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
    GUICtrlCreateButton("Cancel", 110, 240)
    GUICtrlSetOnEvent(-1, "cancelopt")
    GUICtrlCreateButton("Save", 160, 240)
    GUICtrlSetOnEvent(-1, "saveopt")
    GUISetState(@SW_SHOW)
EndFunc    ;==>options

Func cancelopt()
    GUISetState(@SW_HIDE)
    GUISetState(@SW_ENABLE, $gui)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>cancelopt

Func saveopt()
    $tcpath = GUICtrlRead($1)
    $file = GUICtrlRead($2)
    $browspath = GUICtrlRead($3)
    $drive = GUICtrlRead($4)
    $profiledir = GUICtrlRead($5)
    $browser = GUICtrlRead($6)
    $hidepass = GUICtrlRead($7)
    IniWrite("history.ini", "history", "1", _Crypt_EncryptData($tcpath, $settingskey, $CALG_AES_128))
    IniWrite("history.ini", "history", "2", _Crypt_EncryptData($file, $settingskey, $CALG_AES_128))
    IniWrite("history.ini", "history", "3", _Crypt_EncryptData($browspath, $settingskey, $CALG_AES_128))
    IniWrite("history.ini", "history", "4", _Crypt_EncryptData($drive, $settingskey, $CALG_AES_128))
    IniWrite("history.ini", "history", "5", _Crypt_EncryptData($profiledir, $settingskey, $CALG_AES_128))
    IniWrite("history.ini", "history", "6", _Crypt_EncryptData($browser, $settingskey, $CALG_AES_128))
    IniWrite("history.ini", "history", "7", _Crypt_EncryptData($hidepass, $settingskey, $CALG_AES_128))
    GUISetState(@SW_HIDE)
    GUISetState(@SW_ENABLE, $gui)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>saveopt

Func go()
    $pass = GUICtrlRead($Display)
    If $pass = "conf" Then options()
    If StringLen($pass) > 5 And StringIsDigit($pass) = 0 And StringInStr($pass, " + ") = 0 And StringInStr($pass, " - ") = 0 And StringInStr($pass, " × ") = 0 And StringInStr($pass, " ÷ ") = 0 And StringInStr($pass, " +VAT ") = 0 And StringInStr($pass, " . ") = 0 Then
        If FileExists($tcpath) = 1 Then
            Run($tcpath & "TrueCrypt.exe /v " & $file & " /l" & $drive & " /p " & $pass & " /a /q background", @SystemDir, @SW_SHOW)
            Do
                Sleep(200)
            Until FileExists($drive & ":/") = 1
            brows()
            Exit
        Else
;~              TrayTip("", "tc path invalid", 15, 2)
        EndIf
    EndIf
EndFunc    ;==>go

Func brows()
    If $browser = "chrome" Then
        If FileExists($browspath) = 1 Then
            Run($browspath & "chrome.exe --user-data-dir=" & $drive & ":" & $profiledir, @SystemDir, @SW_SHOW)
        Else
;~              TrayTip("", "browser path invalid", 15, 2)
        EndIf
    EndIf
;~  If $browser = "firefox" Then

;~  EndIf
    $space = Round(DriveSpaceFree($drive & ":\"))
    If $space < "150" Then TrayTip("", "Only " & $space & " MB left on " & $drive & ":/ !!", 15, 2)
EndFunc    ;==>brows

Func _Set_Text()

    $Button1 = GUICtrlCreateButton("1", 32, 104, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button1, '_Set_1')

    $Button2 = GUICtrlCreateButton("2", 92, 104, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button2, '_Set_2')

    $Button3 = GUICtrlCreateButton("3", 152, 104, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button3, '_Set_3')

    $Button4 = GUICtrlCreateButton("4", 32, 164, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button4, '_Set_4')

    $Button5 = GUICtrlCreateButton("5", 92, 164, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button5, '_Set_5')

    $Button6 = GUICtrlCreateButton("6", 152, 164, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button6, '_Set_6')

    $Button7 = GUICtrlCreateButton("7", 32, 223, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button7, '_Set_7')

    $Button8 = GUICtrlCreateButton("8", 92, 223, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button8, '_Set_8')

    $Button9 = GUICtrlCreateButton("9", 152, 223, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button9, '_Set_9')

    $Button0 = GUICtrlCreateButton("0", 92, 282, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($Button0, '_Set_0')

    $ButtonADD = GUICtrlCreateButton("+", 231, 104, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($ButtonADD, '_Add')

    $ButtonMINUS = GUICtrlCreateButton("-", 231, 164, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($ButtonMINUS, '_Minus')

    $ButtonDIVIDE = GUICtrlCreateButton("÷", 231, 282, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($ButtonDIVIDE, '_Divide')

    $ButtonTIMES = GUICtrlCreateButton("x", 231, 223, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($ButtonTIMES, '_Times')

    $ButtonEqual = GUICtrlCreateButton("=", 231, 341, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($ButtonEqual, '_Equal')

    $ButtonDecimal = GUICtrlCreateButton(".", 152, 282, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($ButtonDecimal, '_Decimal')

    $ButtonVAT = GUICtrlCreateButton("+VAT", 32, 282, 49, 49)
    GUICtrlSetFont(-1, 8, 800, 0, "Arial")
    GUICtrlSetOnEvent($ButtonVAT, '_VAT')

    $ClearButton = GUICtrlCreateButton("C", 152, 341, 49, 49)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetOnEvent($ClearButton, '_Clear')
EndFunc    ;==>_Set_Text

Func _Set_0()
    _Set_Number('0')
EndFunc    ;==>_Set_0

Func _Set_1()
    _Set_Number('1')
EndFunc    ;==>_Set_1

Func _Set_2()
    _Set_Number('2')
EndFunc    ;==>_Set_2

Func _Set_3()
    _Set_Number('3')
EndFunc    ;==>_Set_3

Func _Set_4()
    _Set_Number('4')
EndFunc    ;==>_Set_4

Func _Set_5()
    _Set_Number('5')
EndFunc    ;==>_Set_5

Func _Set_6()
    _Set_Number('6')
EndFunc    ;==>_Set_6

Func _Set_7()
    _Set_Number('7')
EndFunc    ;==>_Set_7

Func _Set_8()
    _Set_Number('8')
EndFunc    ;==>_Set_8

Func _Set_9()
    _Set_Number('9')
EndFunc    ;==>_Set_9

Func _Clear()
    GUICtrlSetData($Display, '')
    $Real_String = ''
    $Display_String = ''
EndFunc    ;==>_Clear

Func _Divide()
    $Display_String = ($Display_String & ' ÷ ')
    $Real_String = ($Real_String & ' / ')
    GUICtrlSetData($Display, $Display_String)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Divide

Func _Times()
    $Display_String = ($Display_String & ' × ')
    $Real_String = ($Real_String & ' * ')
    GUICtrlSetData($Display, $Display_String)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Times

Func _Minus()
    $Display_String = ($Display_String & ' - ')
    $Real_String = ($Real_String & ' - ')
    GUICtrlSetData($Display, $Display_String)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Minus

Func _Add()
    $Display_String = ($Display_String & ' + ')
    $Real_String = ($Real_String & ' + ')
    GUICtrlSetData($Display, $Display_String)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Add

Func _VAT()
    $Display_String = ($Display_String & ' +VAT ')
    $Real_String = ($Real_String & ' * 1.175')
    GUICtrlSetData($Display, $Display_String)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_VAT

Func _Equal()
    $Equal = Execute($Real_String)
    GUICtrlSetData($Display, $Equal)
    $Display_String = ($Equal)
    $Real_String = ($Equal)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Equal

Func _Decimal()
    $Display_String = ($Display_String & ' . ')
    $Real_String = ($Real_String & ' ????? ')
    GUICtrlSetData($Display, $Display_String)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Decimal

Func _Set_Number($Number)
    $Display_String = ($Display_String & $Number)
    $Real_String = ($Real_String & $Number)
    GUICtrlSetData($Display, $Display_String)
    GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Set_Number

Func _Exit()
    Exit
EndFunc    ;==>_Exit

 

Share this post


Link to post
Share on other sites



i can't edit my message, i've used the calculator from here : 

 

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