Jump to content

Help


Recommended Posts

Here is the code

HotKeySet("{F2}", "_Pause")
Func _Pause()
    Dim $Paused
    $Paused = 1
    Return $Paused
    GUISetState($GUI,@SW_SHOW)
EndFunc

And This part is in my main while 1 and select case loop

Case $msg = $button_Run
        GUISetState($GUI,@SW_HIDE)
        Dim $count_items, $Get_text, $b, $Paused
        $Paused = 0
        Do
            $count_items = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
            For $b = 0 To $count_items - 1
            $Get_text = ControlListView("MyGUI","",$Block_List_view,"GetText",$b)
            ProcessClose($Get_text)
            Next
        
        Until $Paused = 1

I want it to stop doing all that stuff when I press the F2 key and Show the gui. Like do until I press the F2 key then show the gui. I will be very thankfull to any help.

.

Link to comment
Share on other sites

could you post the change? so I'm on the same page?

<{POST_SNAPBACK}>

Case $msg = $button_Run
        GUISetState(@SW_HIDE,$GUI)
        Dim $count_items, $Get_text, $b, $Paused
        $Paused = 0
        Do
            $count_items = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
            For $b = 0 To $count_items - 1
            $Get_text = ControlListView("MyGUI","",$Block_List_view,"GetText",$b)
            ProcessClose($Get_text)
            Next
        
        Until $Paused = 1

HotKeySet("{F2}", "_Pause")
Func _Pause()
    Dim $Paused
    $Paused = 1
    Return $Paused
    GUISetState(@SW_SHOW,$GUI)
EndFunc

.

Link to comment
Share on other sites

$Paused_execute = HotKeySet("{F2}", "_Pause")
Func _Pause()
    Dim $Paused
    $Paused = 1
    Return $Paused
    GUISetState(@SW_SHOW,$GUI)
EndFunc  

Case $msg = $button_Run
        GUISetState(@SW_HIDE,$GUI)
        Dim $count_items, $Get_text, $b, $Paused
        $Paused = 0
        Do
            $count_items = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
            For $b = 0 To $count_items - 1
            $Get_text = ControlListView("MyGUI","",$Block_List_view,"GetText",$b)
            ProcessClose($Get_text)
            Next
        
        Until $Paused_execute = 1

try that...

Edit: nevermind...Hotkeyset returns only 0 or 1

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

$Paused_execute = HotKeySet("{F2}", "_Pause")
Func _Pause()
    Dim $Paused
    $Paused = 1
    Return $Paused
    GUISetState(@SW_SHOW,$GUI)
EndFunc  

Case $msg = $button_Run
        GUISetState(@SW_HIDE,$GUI)
        Dim $count_items, $Get_text, $b, $Paused
        $Paused = 0
        Do
            $count_items = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
            For $b = 0 To $count_items - 1
            $Get_text = ControlListView("MyGUI","",$Block_List_view,"GetText",$b)
            ProcessClose($Get_text)
            Next
        
        Until $Paused_execute = 1

try that...

<{POST_SNAPBACK}>

Nope that dont work either. I think it is not getting the F2 keystoke because it is in a loop. I just don't know how to make it get the keystoke.

.

Link to comment
Share on other sites

try a different looping structure, like select/case

<{POST_SNAPBACK}>

I try this too but no luck.

Case $msg = $button_Run
        GUISetState(@SW_HIDE,$GUI)
       While 1
       Dim $count_items, $Get_text, $b, $Paused, $Paused_execute
       
            $count_items = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
            For $b = 0 To $count_items - 1
            $Get_text = ControlListView("MyGUI","",$Block_List_view,"GetText",$b)
            ProcessClose($Get_text)
                If $Paused_execute = 1 Then
                ExitLoop 2
                EndIf
            Next
        WEnd

This is like the last thing I need in this script. I am thinking of leaving it out.

.

Link to comment
Share on other sites

Case $msg = $button_Run
        GUISetState(@SW_HIDE,$GUI)
       While Not $Paused = 1
       Dim $count_items, $Get_text, $b, $Paused, $Paused_execute
       
            $count_items = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
            For $b = 0 To $count_items - 1
            $Get_text = ControlListView("MyGUI","",$Block_List_view,"GetText",$b)
            ProcessClose($Get_text)
            Next
        WEnd

different traps require different strategies...

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

Still not working. Have a look at the whole script. I figure with you helping this much I might as well show you all I have and it is almost done except for this little part, script cleaning and maybe adding more user friendly options such as a save process list.

; AutoIt Version: 3.0
; Language:    English
; Platform:    Win98 2nd edition, May work on other windows
;In order to work under Windows NT 4.0, requires the file 
;PSAPI.DLL (included in the AutoIt installation directory).
; Author:        Quick_sliver007
;
; Script Function:
;   To Block unwanted processes like spyware and adware
#include <GuiConstants.au3>

$GUI = GuiCreate("MyGUI", 565, 409,(@DesktopWidth-565)/2, (@DesktopHeight-409)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Block_List_view = GUICtrlCreateListView("Block", 340, 30, 220, 370)
$Label_Process = GuiCtrlCreateLabel("Process List", 10, 10, 220, 20)
$Label_Block = GuiCtrlCreateLabel("Block List", 340, 10, 220, 20)
$Label_Add = GuiCtrlCreateLabel("Add To Block List", 240, 30, 90, 20)
$Button_Add = GuiCtrlCreateButton("-------->", 240, 50, 90, 30)
$Button_Delete = GuiCtrlCreateButton("<--------", 240, 130, 90, 30)
$Label_Delete = GuiCtrlCreateLabel("Delete From List", 240, 110, 90, 20)
$Button_Reset = GuiCtrlCreateButton("Reset", 240, 270, 90, 50)
$Button_Run = GuiCtrlCreateButton("Block", 240, 190, 90, 50)
$Button_Exit = GuiCtrlCreateButton("Exit", 240, 350, 90, 50)
;---------------------------------------


$Process_List_View = GUICtrlCreateListView ("Processes", 1, 30, 220, 370)
func _processlist()
$Process= ProcessList ()
For $i= 1 to $Process[0][0]
$items= GUICtrlCreateListViewItem ($Process[$i][0], $Process_List_View)
next
EndFunc
_processlist()
;------------------

GUISetState()
While 1
    Dim $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_Add
        GUICtrlCreateListViewItem (GUICtrlRead(GUICtrlRead($Process_List_View)),$Block_List_view)
    Case $msg = $button_Delete
        Dim $LVM_DELETEITEM, $b,$ItemCount
        $LVM_DELETEITEM = 0x1008
        $ItemCount = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
        For $b = 0 To $ItemCount - 1
        If ControlListView("MyGUI","",$Block_List_view,"IsSelected",$b) Then 
        GuiCtrlSendMsg($Block_List_view, $LVM_DELETEITEM,$b,0)
        $b = $b - 1
        EndIf
        Next
    Case $msg = $button_Run
        GUISetState(@SW_HIDE,$GUI)
        Dim $count_items, $Get_text, $b, $Paused, $Paused_execute
       While Not $Paused = 1
       Dim $count_items, $Get_text, $b, $Paused, $Paused_execute
       
            $count_items = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
            For $b = 0 To $count_items - 1
            $Get_text = ControlListView("MyGUI","",$Block_List_view,"GetText",$b)
            ProcessClose($Get_text)
            Next
        WEnd
        
    Case $msg = $button_Reset
        Do
        Dim $LVM_DELETEITEM, $b,$ItemCount2
        $LVM_DELETEITEM = 0x1008
        $ItemCount2 = ControlListView("MyGUI","",$Process_List_View,"GetItemCount")
        For $b = 0 To $ItemCount2 - 1
            GuiCtrlSendMsg($Process_List_View, $LVM_DELETEITEM,$b,0)
        Next
        Until $ItemCount2 = 0
        _processlist()
    ;;;;;;;;;;;;;;;;;;;;;
        Do
        Dim $LVM_DELETEITEM, $b,$ItemCount
        $LVM_DELETEITEM = 0x1008
        $ItemCount = ControlListView("MyGUI","",$Block_List_view,"GetItemCount")
        For $b = 0 To $ItemCount - 1
        GuiCtrlSendMsg($Block_List_view, $LVM_DELETEITEM,$b,0)
        Next
        Until $ItemCount = 0
    Case $msg = $button_Exit
        Exit
        
        
    EndSelect
WEnd
Exit
Dim $Paused_execute
$Paused_execute = HotKeySet("{F2}", "_Pause")
Func _Pause()
    Dim $Paused
    $Paused = 1
    Return $Paused
    GUISetState(@SW_SHOW,$GUI)
EndFunc

Maybe after I learn more In Autolt, I will make it able to remove the processes completely from the system.

.

Link to comment
Share on other sites

This what you need?

Global $i = 1
HotKeySet("{esc}", "stop")

While $i <> 0
    Sleep(10)
WEnd

MsgBox ( 0, "", "While canceled")

Func Stop()
    $i = 0
EndFunc

You could also make it go back to that while by making it a function and calling the function every time you need it.

Edited by killaz219
Link to comment
Share on other sites

Dim $count_items, $Get_text, $b, $Paused, $Paused_execute
       While Not $Paused = 1
Dim $count_items, $Get_text, $b, $Paused, $Paused_execute

That hurt my brain:

1) Why are you using Dim(I see others doing this too, if its not an array) vs. using Local

2) You are doing it inside the loop and before the loop

Func _Pause()
    Dim $Paused
    $Paused = 1
    Return $Paused
    GUISetState(@SW_SHOW,$GUI)
EndFunc

1) Which $Paused are you modifing This one or the One in the loop?

2) GUISetState() cannot be executed

*Edit*

Read my own sig, I guess I see why one uses Dim on nonarrays to do whacky Local/Global checks of a variable, just seems like most people arent doing that.

Edited by Ejoc
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Link to comment
Share on other sites

Dim $count_items, $Get_text, $b, $Paused, $Paused_execute
       While Not $Paused = 1
Dim $count_items, $Get_text, $b, $Paused, $Paused_execute

That hurt my brain:

1) Why are you using Dim(I see others doing this too, if its not an array) vs. using Local

2) You are doing it inside the loop and before the loop

Func _Pause()
    Dim $Paused
    $Paused = 1
    Return $Paused
    GUISetState(@SW_SHOW,$GUI)
EndFunc

1) Which $Paused are you modifing This one or the One in the loop?

2) GUISetState() cannot be executed

*Edit*

Read my own sig, I guess I see why one uses Dim on nonarrays to do whacky Local/Global checks of a variable, just seems like most people arent doing that.

<{POST_SNAPBACK}>

You can say whacky Local/Global checks of a variable again. LOL

I plan on removing the dim the second time when I clean the script up. Thank you for the reply, I needed some one to tell me how to declare variables better. I finally got that part fixed but thank you for the help. I will take all the help I get. Check out Working version of this script

.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...