Jump to content

Sadece Ilgili Pencere Açıksa Otomatik Çalışma


persmash
 Share

Recommended Posts

S.A. Arkadaşlar,

 

Outlook'da her mail gönder al yaptığımda sunucu ayarlarından dolayı çıkan güvenlik penceresine Evet demem gerekiyor. Ben AutoIt ile bu pencereye Evet dedirtebiliyorum. Hatta arka planda da çalıştırabiliyorum bunu aşağıdaki kod ile ama çok fazla CPU tüketiyor. 

 

Bunun için daha pratik bir tavsiyede bulunabilir misiniz acaba?

 

Teşekkürler...

 

While 1=1
	If WinExists ("Internet Security Warning", "") Then
	ControlClick("Internet Security Warning", "", "Button2" )
EndIf
TraySetState(2)
Wend

 

 

Link to comment
Share on other sites

@persmash
 
Döngüde Sleep komutuyla bekleme yapmalısın.
 
While 1
    If WinExists ("Internet Security Warning", "") Then
        ControlClick("Internet Security Warning", "", "Button2" )
    EndIf
    Sleep(50) ;Cpu save (süreyi artırabilirsin)
Wend

Link to comment
Share on other sites

@persmash
 
Döngüde Sleep komutuyla bekleme yapmalısın.
 
While 1
    If WinExists ("Internet Security Warning", "") Then
        ControlClick("Internet Security Warning", "", "Button2" )
    EndIf
    Sleep(50) ;Cpu save (süreyi artırabilirsin)
Wend

 

Çok teşekkürler hocam, tam olarak aradığım şey buydu. :)

 

CPU kullanımı %0'da düştü.

 

Son birşey daha sormak istiyorum. Programın 2 kere açılmasını nasıl engelleyebilirim. Yani program açıksa tekrar çalıştırmasın aynı .exe'yi.

 

Tekrar teşekkürler...

Link to comment
Share on other sites

_Singleton()

While 1
If WinExists ("Internet Security Warning", "") Then
ControlClick("Internet Security Warning", "", "Button2" )
EndIf
Sleep(50) ;Cpu save (süreyi artırabilirsin)
Wend

;istersen @ScriptName yerine farklı sabit bir şey yazabilirsin
Func _Singleton($sOccurenceName = @ScriptName)
Local Const $ERROR_ALREADY_EXISTS = 183

Local $handle = DllCall("kernel32.dll", "ptr", "CreateMutexW", "int", 0, "long", 1, "wstr", $sOccurenceName)
;~ Local $handle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", 0, "bool", 1, "wstr", $sOccurenceName)
If @error Then Return SetError(@error, @extended, 0)
Local $lastError = DllCall("kernel32.dll", "dword", "GetLastError")
If @error Then Return SetError(@error, @extended, 0)
If $lastError[0] = $ERROR_ALREADY_EXISTS Then
Exit -1
EndIf
Return $handle[0]
EndFunc ;==>_Singleton

Link to comment
Share on other sites

Son birşey daha sormak istiyorum. Programın 2 kere açılmasını nasıl engelleyebilirim. Yani program açıksa tekrar çalıştırmasın aynı .exe'yi.

 

ayrıca bir kod daha denemek istersen 

bu kodu programın başına koymanız yeterli

iki kere çalışmaya engelleyecektir.

 If UBound(ProcessList(@ScriptName)) > 2 Then Exit 



yada

 If UBound(ProcessList(@ScriptName)) > 2 Then
    MsgBox(16, "Hata!", "Zaten çalışan bir program mevcut!", 5)
    Exit 0
EndIf
Edited by mesale0077
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...