Sign in to follow this  
Followers 0
James

ProcessExists Password

5 posts in this topic

Hey,

Can anyone help me please? I am trying to make a password box appear if a process exists. If not then the progam wont run.

#include <GUIConstants.au3>
#include <GUIList.au3>
#include <String.au3>
#include <Constants.au3>
#NoTrayIcon

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

HotKeySet("{F9}", "pwatch")

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "SpecialEvent")

Global $Ini = @ScriptDir & '\db.ini', $myKey = "pppbarj16", $Tray = False

FirstRun()

$GUI = GUICreate("pProcess", 272, 340, -1, -1)

$ProList = GUICtrlCreateList("", 0, 0, 169, 318)

$AddProcess = GUICtrlCreateButton("Add Process", 176, 8, 91, 25, 0)
$RemoveProcess = GUICtrlCreateButton("Remove Process", 176, 40, 91, 25, 0)
$Update = GUICtrlCreateButton("Update List", 176, 72, 91, 25, 0)

GUICtrlCreateLabel("Created by:", 176, 136, 58, 17)
GUICtrlCreateLabel("James Brooks", 192, 152, 70, 17)

$File = GUICtrlCreateMenu("File")
$Help = GUICtrlCreateMenu("Help")

GUISetState(@SW_SHOW)

Start()

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $GUI_EVENT_MINIMIZE
            $Tray = True
            GUISetState(@SW_HIDE)
            TraySetState(1) ; show
            TraySetToolTip("pProcess - Click here to restore. Right click for options!")
        Case $nMsg = $AddProcess
            Add()
        Case $nMsg = $Update
            _GUICtrlListClear($ProList)
            Start()
    EndSelect
WEnd

Func FirstRun()
    RegRead("HKEY_CURRENT_USER\Software\pProcess\Settings", "FirstRun")
    If @error Then
        $Password = InputBox("pProcess", "Please enter a password", "", "*m")
        $Enc = _StringEncrypt(1, $Password, $myKey)
        RegWrite("HKEY_CURRENT_USER\Software\pProcess\Settings", "FirstRun", "REG_SZ", "Ranb4")
        RegWrite("HKEY_CURRENT_USER\Software\pProcess\Settings", "eh!2", "REG_SZ", $Enc)
    EndIf
EndFunc   ;==>FirstRun

Func Start()
    $list = ProcessList()
    For $i = 1 To $list[0][0]
        ; MsgBox(0, $list[$i][0], $list[$i][1])
        _GUICtrlListAddItem($ProList, $list[$i][0])
    Next
EndFunc   ;==>Start

Func Add()
    $ret = _GUICtrlListGetText($ProList, _GUICtrlListSelectedIndex($ProList))
    If ($ret == $LB_ERR) Then
        MsgBox(16, "pProcess", "Error reading process name.")
    Else
        $msg = MsgBox(4, "pProcess", "Are you sure you wish to add, " & $ret & "to the password process file?")
        If $msg = 6 Then
            IniWrite($Ini, "Process", StringTrimRight($ret, 4), $ret)
            MsgBox(0, "pProcess", "Process added")
        Else
            ;
        EndIf
    EndIf
EndFunc   ;==>Add

Func SpecialEvent()
    $Tray = False
    GUISetState(@SW_SHOW)
    TraySetState(2)
EndFunc   ;==>SpecialEvent

Func pwatch()
    MsgBox(0, "pProcess", "Watching processes")
    $iniRead = IniReadSection($Ini, "Process")
    $pe = ProcessExists($iniRead)
    If ProcessExists($iniRead) Then
        $state = WinSetState($pe, "", @SW_HIDE)
        $oPass = InputBox("pProcess", "Please enter your password to run the process", "", "*m")
        $dec = _StringEncrypt(0, $oPass, $myKey)
        If $oPass = $dec Then
            WinSetState($pe, "", @SW_SHOW)
            Run($iniRead, @ProgramFilesDir, @SW_SHOW)
        Else
            MsgBox(0, "pProcess", "Cannot run process. Wrong password.")
        EndIf
    EndIf
EndFunc   ;==>pwatch

-James

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

sry diden seen your whall srcipt

$iniRead = IniReadSection($Ini, "Process")
    $pe = ProcessExists($iniRead)
    If ProcessExists($iniRead) Then
        $state = WinSetState($pe, "", @SW_HIDE)

so if your ini line is

EXCEL=EXCEL.EXE

$iniRead = IniReadSection($Ini, "Process")
For $i = 1 To $iniRead[0][0]
MsgBox(4096, "", "Key: " & $iniRead[$i][0] & @CRLF & "Value: " & $iniRead[$i][1])
Next

$iniRead[$i][0] = EXCEL

$iniRead[$i][1] = EXCEL.EXE

r you trying to show/hide WinSetState($pe, "", @SW_HIDE) when the name of win probably isnt EXCEL.EXE?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

No. If a process starts lets notepad.exe then, it will hide the window until you put in the password.

but where do you store win name?

and still i dont see

While 1
    $nMsg = GUIGetMsg()
    Select
             Case $nMsg = $RemoveProcess

function on your script


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

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  
Followers 0