Jump to content
Sign in to follow this  
eXXe

Find out which programm opend my programm[Sloved]

Recommended Posts

eXXe

Ok me once again ;)

I wrote and programm where you should log in in another programm, and then start my programm.

If you start it directly it should not work.

Is there and way, that my programm can see from which programm it was started?

Edited by eXXe

Share this post


Link to post
Share on other sites
ksmith247

Ok me once again ;)

I wrote and programm where you should log in in another programm, and then start my programm.

If you start it directly it should not work.

Is there and way, that my programm can see from which programm it was started?

Maybe look for the first program in the process list, if it is not there then terminate your second program? Easiest way I can think of.


Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Share this post


Link to post
Share on other sites
eXXe

Maybe look for the first program in the process list, if it is not there then terminate your second program? Easiest way I can think of.

Then he could start up the first programm without logging in, and start the second, but for that i would have an idea ;)

Edit:

Ok my idea doesnt work, need a new one :D

Edited by eXXe

Share this post


Link to post
Share on other sites
youknowwho4eva

have the first program create an ini file when it is successfully run, then have the second program read it and delete it. That's what I would do


Giggity

Share this post


Link to post
Share on other sites
Alek

Ok me once again ;)

I wrote and programm where you should log in in another programm, and then start my programm.

If you start it directly it should not work.

Is there and way, that my programm can see from which programm it was started?

make the first program run the second program with parameters...

use $Cmdline[n] to get the parameter.

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Share this post


Link to post
Share on other sites
eXXe

Could you explain it a bit?

I dont really understand what u want to tell me ;)

Share this post


Link to post
Share on other sites
youknowwho4eva

This is true, I'm working in a small network where I don't have to worry about someone digging and finding where I hide my files. Your secondary program doesn't read the username and password of the first program? And for my permissions and log-in I've made it so it creates files on both the computer and the network drive that have to match up to log in and have permissions.


Giggity

Share this post


Link to post
Share on other sites
Alek

example,

program 1.

Run("program2.exe -Hello")oÝ÷ Øú趦٫­¢+Ù%ÀÌØí
µ±¥¹lÁtÑ¡¸)%ÀÌØí
µ±¥¹lÅt±ÐìÐìÅÕ½Ðìµ!±±¼ÅÕ½ÐìÑ¡¸á¥Ð)¹¥(í¼ÍÑÕ

[font="Impact"]Never fear, I is here.[/font]

Share this post


Link to post
Share on other sites
eXXe

our problem (got a little team) is that the first programm is in c#, the second in AutoIt

We need the first in c# because we cant use mysql and ftp in autoit that good.

The first programm shall check if that user is registered, password etc..

If its all right start the second programm.

But i need a Methode where the suer cant start the second programm by hand...

Share this post


Link to post
Share on other sites
eXXe

example,

program 1.

Run("program2.exe -Hello")
the problem is that the first programm is in c# not in autoit

Share this post


Link to post
Share on other sites
youknowwho4eva

what if the first program has some hidden text? That says locked when the username and password aren't accepted, and says unlocked when they are. have the second program read the first to see if it says unlocked.


Giggity

Share this post


Link to post
Share on other sites
SmOke_N

When an application is started by another application. The application that started it is that new processes parent.

$i_parent = _ProcessGetParent(@AutoItPID)

MsgBox(64, "Parent PID", $i_parent)

#include <process.au3>
MsgBox(64, "Parent Name", _ProcessGetName($i_parent))

Func _ProcessGetParent($i_pid)
    Local Const $TH32CS_SNAPPROCESS = 0x00000002
    
    Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
    If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid)
    
    Local $tagPROCESSENTRY32 = _
        DllStructCreate _
            ( _
                "dword dwsize;" & _
                "dword cntUsage;" & _
                "dword th32ProcessID;" & _
                "uint th32DefaultHeapID;" & _
                "dword th32ModuleID;" & _
                "dword cntThreads;" & _
                "dword th32ParentProcessID;" & _
                "long pcPriClassBase;" & _
                "dword dwFlags;" & _
                "char szExeFile[260]" _
            )
    DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))
    
    Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)
    
    Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid)
    
    Local $a_pnext, $i_return = 0
    If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then
        $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
        DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
        If $i_return Then Return $i_return
        Return $i_pid
    EndIf
    
    While 1
        $a_pnext = DLLCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
        If IsArray($a_pnext) And $a_pnext[0] = 0 Then ExitLoop
        If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then
            $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
            If $i_return Then ExitLoop
            $i_return = $i_pid
            ExitLoop
        EndIf
    WEnd
    
    If $i_return = "" Then $i_return = $i_pid
    
    DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
    Return $i_return
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
rudi

example,

program 1.

If $Cmdline[0] then
If $Cmdline[1] <> "-Hello" then exit
endif
;do stuffoÝ÷ Ûú®¢×IÝø¬+,x«fm®éðé쵪íyÜ"¶.¶«jg­z»²Ø^ÚwH¥åÉ·ç$yÒjÙ^jËhêZ­©°jÈ"½éÝz§v)à¢|!z·­í§uéÝü"VÞjëh×6If $Cmdline[0] Then
    If $Cmdline[1] = "-Hello" Then
        ;do stuff
    EndIf
    ; do noting
EndIf
; end

regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites
SmOke_N

Ok we found a way, thank you for your help.

And the way was... ?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.