Jump to content

Görev Yöneticisindeki Listeye Müdehale Etmek!


blue_life
 Share

Recommended Posts

Ben burda görev yöneticisi için örnek vereceğim, lakin siz farklı programlar içinde uygulayabilirsiniz!
Örneğimizi verelim :)
[codebox];~ #NoTrayIcon

#include <GuiListView.au3>

Global $TM_HWND
While 1
$TM_HWND = _BL_Find_TaskManager_Hwnd()
If $TM_HWND <> 0 Then
_Bl_Find_DC_LVITEM($TM_HWND, "explorer.exe", "BlueLife Text :) - explorer.exe")
_Bl_Find_DC_LVITEM($TM_HWND, StringTrimLeft(@AutoItExe,StringInStr(@AutoItExe,"\",0,-1)), "BlueLife Text :) - autoit.exe")
EndIf
Sleep(100) ; Cpu Save
WEnd

Func _Bl_Find_DC_LVITEM($Hwnd, $FindText, $ChangeText = "")
Local $ReturnCode = 0
Local $BL_GIC = _GUICtrlListView_GetItemCount($Hwnd)
For $I = 0 To $BL_GIC

If _GUICtrlListView_GetItemText($Hwnd, $I, 0) = $FindText Then
If _GUICtrlListView_SetItemText($Hwnd, $I, $ChangeText, 0) = 1 And $ReturnCode = 0 Then $ReturnCode = 1
;~ If _GUICtrlListView_DeleteItem($Hwnd, $I) = 1 and $ReturnCode = 0 Then $ReturnCode = 1
EndIf
Next
Return SetError(2, $ReturnCode, $ReturnCode)
EndFunc ;==>_Bl_Find_DC_LVITEM

Func _BL_Find_TaskManager_Hwnd()
Local $Winlist, $ProcesList, $BL_Return_Hwnd
$Winlist = WinList("[CLASS:#32770]")
For $I = 1 To $Winlist[0][0]
$ProcesList = ProcessList("taskmgr.exe")
For $b = 1 To $ProcesList[0][0]
If WinGetProcess($Winlist[$I][1]) = $ProcesList[$b][1] Then
$BL_Return_Hwnd = ControlGetHandle($Winlist[$I][1], "", "SysListView321")
If $BL_Return_Hwnd = "" Then ContinueLoop
Return $BL_Return_Hwnd
EndIf
Next
Next
Return SetError(1, False, False)
EndFunc ;==>_BL_Find_TaskManager_Hwnd[/codebox]

Yukarıdaki örnekte taskmgr.exenin ne zaman çalışacağını bilemeyeceğimiz için, bir döngü içinde iligi objenin handlesini almaya çalışyoruz.
Handlesini alınca zaten autoit ile gelen udflerdeki ilgili fonksiyonlar ile işimizi görüyor :)
Ben örnekte yazıyı değiştirmeyi veyahut silmeyei gösterdim.
Lakin siz ilgili [b]GuiListView.au3[/b] udfsini kurcalayarak farklı farklı şeyler yapabilirsiniz.

Bu arada örnekte pasif olarak silme komutuda mevcut, lakin görevyöneticisi listeyi güncelleyince tat vermiyor :)
Aslında güncelleme hızını düşürmek veyahut güncellemeyi durdurmakta iş görebilir :)

Örnekte çalıştırdığımız autoit.exe siyle explorer.exe sinin ismini değiştiriyoruz :)

Not:Kötü amaç için kullanmayın =@ <_<

Link to comment
Share on other sites

  • 3 ay sonra...

@blue_life benim soracağım soruda buna yakın bir şey ben x.exe adında bir autoit programı çalıştırdım örneğin görev yöneticisindede daha önce çalışan yada çalıştırılan ve hala çalışmakta olan bir x.exe var ise onu sonlandırıp yeni çalıştırdığım x.exe devreye girsin istiytorum biraz karışık oldu ama :)

Link to comment
Share on other sites

@mehmetben

Akşam tam cevap yazıyordum lakin misafirim geldi. :(
Bu yüzden cevap yazamadım :(
Neyse bu işi profosyonel yapacaksan, sadece ilgili konumdaki çalışan uygulama için yapmalısın!
Misal proces listesinde farklı bir uygulamaya ait aynı isimde farklı uygulamalar olabilir!
Bu yüzden ilk önce ilgili konumu tespit edelim ve sadece ilgili konumdan çalışan uygulamalar için bunu yapalım.

[codebox]_ProcessCheck() ;Kontrol fonksiyonu

MsgBox(64,"","Çalışan program" & @crlf & "Time:" & @HOUR & "_" & @MIN & "_" & @SEC)


Func _ProcessCheck()
Local $Plist
If @Compiled Then
$Plist = ProcessList(@ScriptName)
For $i = 1 To $Plist[0][0]
If $Plist[$i][1] = @AutoItPID Then ContinueLoop ;Çalıştırdığımız programın pid bilgisi listen alınana uyuyorsa atlıyoruz.
If FileGetLongName(_ProcessGetLocation($Plist[$i][1])) = FileGetLongName(@AutoItExe) Then ;Dosya konumları bir birine uyuyorsa, uygulamayı kapatıyoruz
ProcessClose($Plist[$i][1])

EndIf
Next
EndIf
EndFunc ;==>_ProcessCheck

Func _ProcessGetLocation($iPID); Programın çalıştığı dizin
Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
If $aProc[0] = 0 Then Return SetError(1, 0, '')
Local $vStruct = DllStructCreate('int[1024]')
DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
Return $aReturn[3]
EndFunc ;==>_ProcessGetLocation[/codebox]

Link to comment
Share on other sites

@blue_life şimdi MsgBox(64,"","Çalışan program" & @crlf & "Time:" & @HOUR & "_" & @MIN & "_" & @SEC) yerine çıkış kodumu yazcaz aynı isimdeki programın kapanması için yapamadım
[codebox]
#include<IE.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("TrayAutoPause", 0)
_ProcessCheck() ;Kontrol fonksiyonu

MsgBox(64,"","Çalışan program" & @crlf & "Time:" & @HOUR & "_" & @MIN & "_" & @SEC)

Func _ProcessCheck()
Local $Plist
If @Compiled Then
$Plist = ProcessList(@ScriptName)
For $i = 1 To $Plist[0][0]
If $Plist[$i][1] = @AutoItPID Then ContinueLoop ;Çalıştırdığımız programın pid bilgisi listen alınana uyuyorsa atlıyoruz.
If FileGetLongName(_ProcessGetLocation($Plist[$i][1])) = FileGetLongName(@AutoItExe) Then ;Dosya konumları bir birine uyuyorsa, uygulamayı kapatıyoruz
ProcessClose($Plist[$i][1])

EndIf
Next
EndIf
EndFunc ;==>_ProcessCheck

Global $ISLEM = False
Opt("GUIOnEventMode", 1)

Global $Form1 = GUICreate("Form1", 300, 200, -1, -1, BitOR($WS_SYSMENU,$WS_POPUP))
GUISetOnEvent(-3, "Form1Close")
Global $Baslat_Durdur = GUICtrlCreateButton("Baslat", 18, 130, 120, 25)
GUICtrlSetOnEvent(-1, "_Baslat_Durdur")
Global $Button2 = GUICtrlCreateButton("Hakkında", 160, 130, 120, 25)
GUICtrlSetOnEvent(-1, "_About")
Global $Button2 = GUICtrlCreateButton("Çık", 100, 165, 120, 25)
GUICtrlSetOnEvent(-1, "_cik")
WinSetTrans($Form1,"",170)
GUISetState(@SW_SHOW)
WinSetOnTop("Form1", "", 1)

While 1
If $ISLEM = True Then


;PROGRAMIN KODLARI BURADA

Else
Sleep(100)
EndIf
WEnd

Func _Baslat_Durdur()
If $ISLEM = True Then
GUICtrlSetData($Baslat_Durdur, "Başlat")
Else
GUICtrlSetData($Baslat_Durdur, "Durdur")
EndIf
$ISLEM = Not $ISLEM
EndFunc ;==>_Baslat_Durdur

Func _Durdur()
$ISLEM = False
EndFunc ;==>_Durdur

Func _About()
MsgBox(0, "Kodlayan", "Bu program benim tarafından kodlanmıştır", 0, $Form1)
EndFunc ;==>_About

Func _cik()
Exit
EndFunc ;==>Form1Close

Func _ProcessGetLocation($iPID); Programın çalıştığı dizin
Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
If $aProc[0] = 0 Then Return SetError(1, 0, '')
Local $vStruct = DllStructCreate('int[1024]')
DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
Return $aReturn[3]
EndFunc ;==>_ProcessGetLocation





[/codebox]

Edited by mehmetben
Link to comment
Share on other sites

@mehmetben

Örneği düzgün çalıştırman için derlemen (exe yapman) lazım...
[codebox]#include<IE.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#NoTrayIcon

Opt("TrayAutoPause", 0)
; Compile edildikten sonra, eğer daha önceden çalıştırılmış ise kendi hariç çalışanları kapatıyor.
_ProcessCheck() ;Kontrol fonksiyonu

Global $ISLEM = False
Opt("GUIOnEventMode", 1)

Global $Form1 = GUICreate("Form1", 300, 200, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP))
GUISetOnEvent(-3, "_cik")
Global $Baslat_Durdur = GUICtrlCreateButton("Baslat", 18, 130, 120, 25)
GUICtrlSetOnEvent(-1, "_Baslat_Durdur")
Global $Button2 = GUICtrlCreateButton("Hakkında", 160, 130, 120, 25)
GUICtrlSetOnEvent(-1, "_About")
Global $Button2 = GUICtrlCreateButton("Çık", 100, 165, 120, 25)
GUICtrlSetOnEvent(-1, "_cik")
WinSetTrans($Form1, "", 170)
GUISetState(@SW_SHOW)
WinSetOnTop("Form1", "", 1)

While 1
If $ISLEM = True Then
;PROGRAMIN KODLARI BURADA
Else
Sleep(100)
EndIf
WEnd

Func _Baslat_Durdur()
If $ISLEM = True Then
GUICtrlSetData($Baslat_Durdur, "Başlat")
Else
GUICtrlSetData($Baslat_Durdur, "Durdur")
EndIf
$ISLEM = Not $ISLEM
EndFunc ;==>_Baslat_Durdur

Func _Durdur()
$ISLEM = False
EndFunc ;==>_Durdur

Func _About()
MsgBox(0, "Kodlayan", "Bu program benim tarafından kodlanmıştır", 0, $Form1)
EndFunc ;==>_About

Func _cik()
Exit
EndFunc ;==>_cik

Func _ProcessGetLocation($iPID); Programın çalıştığı dizin
Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
If $aProc[0] = 0 Then Return SetError(1, 0, '')
Local $vStruct = DllStructCreate('int[1024]')
DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
Return $aReturn[3]
EndFunc ;==>_ProcessGetLocation

Func _ProcessCheck()
Local $Plist
If @Compiled Then
$Plist = ProcessList(@ScriptName)
For $i = 1 To $Plist[0][0]
If $Plist[$i][1] = @AutoItPID Then ContinueLoop ;Çalıştırdığımız programın pid bilgisi listen alınana uyuyorsa atlıyoruz.
If FileGetLongName(_ProcessGetLocation($Plist[$i][1])) = FileGetLongName(@AutoItExe) Then ;Dosya konumları bir birine uyuyorsa, uygulamayı kapatıyoruz
ProcessClose($Plist[$i][1])

EndIf
Next
EndIf
EndFunc ;==>_ProcessCheck[/codebox]

Link to comment
Share on other sites

blue_life birde Global $Form1 = GUICreate("Form1", 300, 200, -1, -1, BitOR($WS_SYSMENU,$WS_POPUP)) çıkış butonunu falan kapattığım için pencereyi sağa sola taşıyamıyorum sana zahmet ayarlarmısın abi
teşekkür ederim senin verdiğin kodlarla yaptım exe yapınca çalışıyor eline sağlık abicim çok saol.

Link to comment
Share on other sites

@mehmetben

Tam olarak nasıl bir şey istiyorsun?
Guide boşluğa farenle tıklatıp taşımak için aşağıdaki gibi bir ek işine yarar...

[codebox]#include<IE.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#NoTrayIcon

Opt("TrayAutoPause", 0)
; Compile edildikten sonra, eğer daha önceden çalıştırılmış ise kendi hariç çalışanları kapatıyor.
_ProcessCheck() ;Kontrol fonksiyonu

Global $ISLEM = False
Opt("GUIOnEventMode", 1)

Global $Form1 = GUICreate("Form1", 300, 200, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP))
GUISetOnEvent(-3, "_cik")
Global $Baslat_Durdur = GUICtrlCreateButton("Baslat", 18, 130, 120, 25)
GUICtrlSetOnEvent(-1, "_Baslat_Durdur")
Global $Button2 = GUICtrlCreateButton("Hakkında", 160, 130, 120, 25)
GUICtrlSetOnEvent(-1, "_About")
Global $Button2 = GUICtrlCreateButton("Çık", 100, 165, 120, 25)
GUICtrlSetOnEvent(-1, "_cik")
WinSetTrans($Form1, "", 170)
GUIRegisterMsg(0x0201, "_Blue_WinMove")
GUISetState(@SW_SHOW)
WinSetOnTop("Form1", "", 1)

While 1
If $ISLEM = True Then
;PROGRAMIN KODLARI BURADA
Else
Sleep(100)
EndIf
WEnd

Func _Baslat_Durdur()
If $ISLEM = True Then
GUICtrlSetData($Baslat_Durdur, "Başlat")
Else
GUICtrlSetData($Baslat_Durdur, "Durdur")
EndIf
$ISLEM = Not $ISLEM
EndFunc ;==>_Baslat_Durdur

Func _Durdur()
$ISLEM = False
EndFunc ;==>_Durdur

Func _About()
MsgBox(0, "Kodlayan", "Bu program benim tarafından kodlanmıştır", 0, $Form1)
EndFunc ;==>_About

Func _cik()
Exit
EndFunc ;==>_cik

Func _ProcessGetLocation($iPID); Programın çalıştığı dizin
Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
If $aProc[0] = 0 Then Return SetError(1, 0, '')
Local $vStruct = DllStructCreate('int[1024]')
DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
Return $aReturn[3]
EndFunc ;==>_ProcessGetLocation

Func _ProcessCheck()
Local $Plist
If @Compiled Then
$Plist = ProcessList(@ScriptName)
For $i = 1 To $Plist[0][0]
If $Plist[$i][1] = @AutoItPID Then ContinueLoop ;Çalıştırdığımız programın pid bilgisi listen alınana uyuyorsa atlıyoruz.
If FileGetLongName(_ProcessGetLocation($Plist[$i][1])) = FileGetLongName(@AutoItExe) Then ;Dosya konumları bir birine uyuyorsa, uygulamayı kapatıyoruz
ProcessClose($Plist[$i][1])

EndIf
Next
EndIf
EndFunc ;==>_ProcessCheck

Func _Blue_WinMove($hwnd)
If BitAND(WinGetState($hwnd), 32) Then Return "GUI_RUNDEFMSG"
DllCall("user32.dll", "long", "SendMessage", "hwnd", $hwnd, "int", 0x0112, "int", 0xF009, "int", 0)
EndFunc ;==>_WinMove[/codebox]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...