Sign in to follow this  
Followers 0
epicfail

ProcessWait help freezes gui

29 posts in this topic

#1 ·  Posted (edited)

hello every1 how are we?

Well im new to forums i would like to say hi.

My Friend told me about Autoit so thought i would try it.

Ok i have a prob with ProcessWait i have made a checkbox, When its clicked it waits 4 the process to start, My problem is that i want to be able to do other stuff with my gui while its waiting for the process (as in move it aroud and click other tabs) but it dont let me do anything when it is waiting 4 the process to start. How would i make it so i can still use the check box and that waits 4 a process and be able to do other things with my gui at the same time?

.epicfail.

Edited by epicfail

Share this post


Link to post
Share on other sites



instead of useing ProccessWait, place something like this in your primary loop

if ProcessExists() and GUICtrlRead() = $GUI_CHECKED Then


There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I needed processWait cos i need it to wait till i open a program then it will inject a code into it.

Edited by epicfail

Share this post


Link to post
Share on other sites

Can you please give me a example? im new!

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("WinTitleMatchMode", 1)

GUICreate("My GUI",600,50)
$id_Checkbox_01 = GUICtrlCreateCheckbox('If I am Checked, Text will be inserted into a command window as soon as it is manually started.',20,20)
GUISetState(@SW_SHOW)


While 1 ; Run the GUI until the dialog is closed
    $msg = GUIGetMsg()
    if ProcessExists('cmd.exe') and GUICtrlRead($id_Checkbox_01) = $GUI_CHECKED Then
        ControlSend('C:\WINDOWS\','','','Inserted Text')
        GUICtrlSetState($id_Checkbox_01,$GUI_UNCHECKED ) ; ONLY Send ONCE
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()


There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Share this post


Link to post
Share on other sites

thankyou how wouldi add that to a case?

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("WinTitleMatchMode", 1)

GUICreate("My GUI",600,50)
$id_Checkbox_01 = GUICtrlCreateCheckbox('If I am Checked, Text will be inserted into a command window as soon as it is manually started.',20,20)
GUISetState(@SW_SHOW)


While 1 ; Run the GUI until the dialog is closed
    $msg = GUIGetMsg()
    if ProcessExists('cmd.exe') and GUICtrlRead($id_Checkbox_01) = $GUI_CHECKED Then
        ControlSend('C:\WINDOWS\','','','Inserted Text')
        GUICtrlSetState($id_Checkbox_01,$GUI_UNCHECKED ) ; ONLY Send ONCE
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

That dont work. i need to be able to click the check box before the exe starts then it injects the code indo the exe once it starts and still be able to move the gui when its waiting for the program. I tryed ProcessWait but that makes it so u cant move the gui or do anything with it why its waiting 4 the exe.

Share this post


Link to post
Share on other sites

I really think you shouldn't be doing code injection if you don't understand simple program flow.

thankyou how wouldi add that to a case?

Before or after the case.

Share this post


Link to post
Share on other sites

I really think you shouldn't be doing code injection if you don't understand simple program flow.

Before or after the case.

i worked that out it was just a dumb Q i didnt readit fully. im just trying to make a injector so that it injects the dll into a process. I have the injector working when i click a button and i got it working when i click a check box so it auto injects its just that i cant work out how to make it so i can move and click buttons in the gui when its still waiting 4 the process. Can u please help me?

Share this post


Link to post
Share on other sites

The answer has been given a few times. But maybe you need some more explanation or something.

So let's think how ProcessWait works.. I'll illustrate this with a code example:

Func _ProcessWait($pid)
   While Not ProcessExists($pid)
     Sleep(250)
   Wend
   Return 1
EndFunc

Now you want to add a GUI loop, and it should also wait for the process to exist. So your main loop now has 2 things to do:

While 1
    ; Handle GUI stuff
    ; Check for process
Wend

You implement it like this:

While 1
    ; Handle GUI stuff
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    if ProcessExists($pid) Then
        ; do stuff
    EndIf
WEnd

GUIDelete()

Are you beginning to see the bigger picture?

Share this post


Link to post
Share on other sites

Right:

While 1
    If ProcessExists($pid) Then
        ; do stuff
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ProcessClose("MrParo's Utility  2.exe")
            Exit
    EndSwitch
WEnd

Right:

While 1
    $nMsg = GUIGetMsg()
    If ProcessExists($pid) Then
        ; do stuff
    EndIf
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ProcessClose("MrParo's Utility  2.exe")
            Exit
    EndSwitch
WEnd

Right:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ProcessClose("MrParo's Utility  2.exe")
            Exit
    EndSwitch
    If ProcessExists($pid) Then
        ; do stuff
    EndIf
WEnd

Wrong:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        If ProcessExists($pid) Then
            ; do stuff
        EndIf
        Case $GUI_EVENT_CLOSE
            ProcessClose("MrParo's Utility  2.exe")
            Exit
    EndSwitch
WEnd

Wrong:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            If ProcessExists($pid) Then
                ; do stuff
            EndIf
            ProcessClose("MrParo's Utility  2.exe")
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

The basic idea is this:

While 1
    ; Handle GUI stuff
    ; Check for process
Wend

The case would be part of the "Handle GUI stuff". The "Check for process" comes after the GUI stuff.

This was supposed to be obvious.

Share this post


Link to post
Share on other sites

ok sweet thanks heaps 4 all your help.

Share this post


Link to post
Share on other sites

ok i still have the problem i put it where u said but as soon as i click the check box i cant do anything cos it is waiting 4 the process to start.

While 1
                 If GUICtrlRead($AutoInjectCheckbox) = $GUI_CHECKED Then
                ProcessWait("notepad.exe")
                $ProcessWait = ProcessExists("notepad.exe")
                    Sleep(5000)
                _InjectDll(GUICtrlRead($Inject_Input), $ProcessWait)
            If @error Then
                GUICtrlSetData($Inject_Label2, 'ERROR !')
                GUICtrlSetColor($Inject_Label2, 0xFF0000)
            Else
                GUICtrlSetData($Inject_Label2, 'DLL Injected !')
                GUICtrlSetColor($Inject_Label2, 0x00FF00)
                    Sleep(5000)
                GUICtrlSetState($AutoInjectCheckbox,4)
                GUICtrlSetData($Inject_Label2, 'Waiting To Inject')
                GUICtrlSetColor($Inject_Label2, 0xFFFFFF)
                EndIf
            EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Exit_Button
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

ok i still have the problem i put it where u said but as soon as i click the check box i cant do anything cos it is waiting 4 the process to start.

While 1
                 If GUICtrlRead($AutoInjectCheckbox) = $GUI_CHECKED Then
                ProcessWait("notepad.exe")
                $ProcessWait = ProcessExists("notepad.exe")
                    Sleep(5000)
                _InjectDll(GUICtrlRead($Inject_Input), $ProcessWait)
            If @error Then
                GUICtrlSetData($Inject_Label2, 'ERROR !')
                GUICtrlSetColor($Inject_Label2, 0xFF0000)
            Else
                GUICtrlSetData($Inject_Label2, 'DLL Injected !')
                GUICtrlSetColor($Inject_Label2, 0x00FF00)
                    Sleep(5000)
                GUICtrlSetState($AutoInjectCheckbox,4)
                GUICtrlSetData($Inject_Label2, 'Waiting To Inject')
                GUICtrlSetColor($Inject_Label2, 0xFFFFFF)
                EndIf
            EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Exit_Button
            Exit
    EndSwitch
WEnd

No is no way to fix this.

You will need to do GUI Event.

Search help file for GUI OnEvent Mode

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

The main reason we told you just use ProcessExist is because you can use it to recreate functionality of ProcessWait without blocking the script. Now you're still using ProcessWait. You're by far from ready for this kind of stuff. You lack basic programming skills and you miss a lot of common sense!

Edit: I'll reconsider fixing your epic fail if you provide a full working script which reproduces your issue. Don't just paste your stuff into the forum and expect us to fix it.

Edited by Manadar

Share this post


Link to post
Share on other sites

so there is no way to use processwait in a check box? with out disabling the gui controls?

Share this post


Link to post
Share on other sites

so there is no way to use processwait in a check box? with out disabling the gui controls?

What is wrong with your eyes?

First use ProcessExist and not ProcessWait.

If you want to use ProcessWait then you will need to change to GUI on Event mode

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