Jump to content

Exit'ten Sonra Fonksiyon Çalıştırmak


Dj Demir

Recommended Posts

Exit'ten sonra bir fonksiyon çalıştırma gibi şansımız olamaz mı ?

veya ona benzer başka bir şey .

GuiDeLete ile yapıyorum benzerini ama

Bu seferde Tray'da iki tane görev oluşmuş oluyor .

Yani tamamen eski işlem kapatılmıyor .

Örnek:

 While 1
  $nMsg = GUIGetMsg()
  Switch $nMsg
   Case $ReWrite
    Exit
    _Fonksiyon()
   EndSwitch
 WEnd

Link to comment
Share on other sites

@Dj Demir

Autoitte Exit satırı uygulandıktan sonra script sonlanır.

Guidelete ile mevcut gui ekranı silinir.

Sen kısaca; Bir gui oluşturuyorum ve guidelete dedikten sonra gui silinmiyor. Traybarda çubuğu halen duruyor mu demek istiyorsun?

Biraz daha detay vermelisin...

Link to comment
Share on other sites

Evet tam olarak öyle olmasa da öyle denebilir

GuiDelete ile GUI siliniyor ama

Tray Menüsü halen duruyor

o yüzden exit'e benzer birşey aramak zorunda kaldım

Link to comment
Share on other sites

Hayır gui silinince traydaki çubuğunda silinmesi lazım.

Ufak bir test yapalım...

_TestGui()
Sleep(1500)
_TestGui()
Sleep(1500)
_TestGui()
Sleep(1500)
_TestGui()

Func _TestGui()
	Local $Form1 = GUICreate("Form1", 385, 106, 192, 124)
	$Button1 = GUICtrlCreateButton("Delete Test", 56, 40, 251, 25)
	GUISetState(@SW_SHOW)
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case -3,$Button1
				ExitLoop

		EndSwitch
	WEnd
	GUIDelete($Form1)
EndFunc

Kısaca senin kodlarında bir sorun var. Paylaşabilirsen, nerde hata olduğunu söyleyebiliriz...

Link to comment
Share on other sites

Yok hocam daha önce'de yazdım

Tray MENÜSÜ silinmiyor

Yeni Çağırdığım fonksiyonun içinde de Tray menüsü var

ikisi birleşiyor

Yani Tray Menüsü 1 yerine 2 tane oluyor

Tray Simgesi değil .

Yani şöyle oluyor

2lkwgom.jpg

Link to comment
Share on other sites

TrayItemDelete ile traydaki nesneleri silebilirsin. Ama traydaki nesneler hep aynı ise bir kez ekle.

Örnek verelim...

Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
Global $Escitray = TrayCreateItem("Kapat")
TrayItemSetOnEvent(-1, "Kapat")
TraySetState(1)

For $I = 1 to 3
	_TestGui()
	Sleep(1500)
Next

Func _TestGui()
	Local $Form1 = GUICreate("Form1", 385, 106, 192, 124)
	$Button1 = GUICtrlCreateButton("Delete Test", 56, 40, 251, 25)
	GUISetState(@SW_SHOW)
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case -3,$Button1
				ExitLoop

		EndSwitch
	WEnd
	GUIDelete($Form1)
EndFunc

Func Kapat()
	Exit
EndFunc

Link to comment
Share on other sites

Örnek Olarak vermem gerekirse

Hatam aynen aşağıdaki gibi hocam

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

Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)

Global $Form1,$Button1

_Form()

Func _Form()
$Form1 = GUICreate("Form1", 338, 104, 280, 177)
$Button1 = GUICtrlCreateButton("Button1", 64, 32, 169, 33, $WS_GROUP)
GUISetState(@SW_SHOW)


	$Cikis = TrayCreateItem("Çıkış")
	TrayItemSetOnEvent($Cikis, "Cik")



EndFunc
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			Local $Cikis
			GUIDelete($Form1)
			TrayItemDelete($Cikis);olmuyor
			TrayItemSetState($Cikis,@SW_HIDE);olmuyor
			_Form2()
		ExitLoop
	EndSwitch
WEnd

Func _Form2()
$Form2 = GUICreate("Form1", 338, 104, 280, 177)
$Button2 = GUICtrlCreateButton("Button1", 64, 32, 169, 33, $WS_GROUP)
GUISetState(@SW_SHOW)


	$Cikis = TrayCreateItem("Çıkış")
	TrayItemSetOnEvent($Cikis, "Cik")


EndFunc
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			GuiDelete($Form1)
			_Form()
			ExitLoop
	EndSwitch
WEnd

Func Cik()
	ExitEndFunc

Link to comment
Share on other sites

Tray nesnelerini bir kez eklersen sorununu çözersin. Aşağıdaki kodları incele!

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

Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
$Cikis = TrayCreateItem("Çıkış")
TrayItemSetOnEvent($Cikis, "Cik")

Global $Form1, $Button1
_Form()

Func _Form()
	$Form1 = GUICreate("Form1", 338, 104, 280, 177)
	$Button1 = GUICtrlCreateButton("Button1", 64, 32, 169, 33, $WS_GROUP)
	GUISetState(@SW_SHOW,$Form1)
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				Exit
			Case $Button1
				GUIDelete($Form1)
				_Form2()
				ExitLoop
		EndSwitch
	WEnd
EndFunc   ;==>_Form

Func _Form2()
	$Form2 = GUICreate("Form 2", 338, 104, 280, 177)
	$Button2 = GUICtrlCreateButton("Button1", 64, 32, 169, 33, $WS_GROUP)
	GUISetState(@SW_SHOW,$Form2)
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				Exit
			Case $Button2
				GUIDelete($Form2)
				_Form()
				ExitLoop
		EndSwitch
	WEnd
EndFunc   ;==>_Form2

Func Cik()
	Exit
EndFunc   ;==>Cik

Link to comment
Share on other sites

Hocam zaten bir fonksiyonda tek var tray nesneleri

Ama ben scriptin belli bir yerinde yeniden başa almak için

Scripti yeniden çalıştırıyorum .

ve bundan dolayıdır ki eski trayi silmeden yenisini de üstüne ekliyor .

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

Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)

Global $Form1,$Button1
_Form()
Func _Form()

$Form1 = GUICreate("Form1", 338, 104, 280, 177)

$Button1 = GUICtrlCreateButton("Button1", 64, 32, 169, 33, $WS_GROUP)

GUISetState(@SW_SHOW)

$Cikis = TrayCreateItem("Çıkış")
TrayItemSetOnEvent($Cikis, "Cik")
EndFunc

While 1

	$nMsg = GUIGetMsg()

	Switch $nMsg

		Case $GUI_EVENT_CLOSE

			Exit

		Case $Button1

			Local $Cikis

			GUIDelete($Form1)

			TrayItemDelete($Cikis);olmuyor

			TrayItemSetState($Cikis,@SW_HIDE);olmuyor

			_Form2()
		ExitLoop
	EndSwitch
WEnd

Func _Form2();bu Form1 . belli bir yerden sonra tekrardan başa aldırtıyorum .

$Form2 = GUICreate("Form1", 338, 104, 280, 177)
$Button2 = GUICtrlCreateButton("Button1", 64, 32, 169, 33, $WS_GROUP)
GUISetState(@SW_SHOW)

$Cikis = TrayCreateItem("Çıkış")
TrayItemSetOnEvent($Cikis, "Cik")
EndFunc

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			GuiDelete($Form1)
			_Form()
			ExitLoop
	EndSwitch
WEnd

Func Cik()
	Exit
EndFunc

Link to comment
Share on other sites

@Dj Demir

Sen TrayCreateItem bulunan fonksiyonu 10 kez çalıştırsan traya ilgili nesne 10 kez yansıtılır. Yaptığın hata bu!

Ben diyorum ki TrayCreateItem satırını ilgili nesne için bir kez kullan!

Ilgili fonkisyona başlamdan trayitem satırını kullan! Bak senin verdiğin örneği düzeltip koydum. Karşılaştır!

Sen şöyle bir şey mi yapmak istiyorsun yoksa!

Gui açıldı ve tray nesneleri geldi. Sen guiyi kapattınca taray nesneleri silinsi ve başka bir gui açılınca ona atadığın farklı tray nesneleri oluşsun ve kullanılsın.

Malesef yapmak istediğini ya ben anlamıyorum, yada sen beni anlamıyorsun! :(

Link to comment
Share on other sites

Sen while döngüsünü niye func dışına koyuyorsun? Tray değişkenini global ile tanıtmadığın için function dışında bu değişken tanınmıyor olabilir..

Neyse kolay gelsin...

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

Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)

Global $Form1, $Button1
_Form()

Func _Form()
	$Form1 = GUICreate("Form1", 338, 104, 280, 177)
	$Button1 = GUICtrlCreateButton("Button1", 64, 32, 169, 33, $WS_GROUP)
	$Cikis = TrayCreateItem("Çıkış")
	TrayItemSetOnEvent($Cikis, "Cik")
	GUISetState(@SW_SHOW,$Form1)
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				Exit
			Case $Button1
				TrayItemDelete($Cikis);olmuyor
				GUIDelete($Form1)
				_Form2()
				ExitLoop
		EndSwitch
	WEnd
EndFunc   ;==>_Form

Func _Form2()
	$Form2 = GUICreate("Form 2", 338, 104, 280, 177)
	$Button2 = GUICtrlCreateButton("Button1", 64, 32, 169, 33, $WS_GROUP)
	$Cikis = TrayCreateItem("Çıkış")
	TrayItemSetOnEvent($Cikis, "Cik")
	GUISetState(@SW_SHOW,$Form2)
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				Exit
			Case $Button2
				TrayItemDelete($Cikis);olmuyor
				GUIDelete($Form2)
				_Form()
				ExitLoop
		EndSwitch
	WEnd
EndFunc   ;==>_Form2

Func Cik()
	Exit
EndFunc   ;==>Cik

Link to comment
Share on other sites

Çalışmamda While döngüsü Func içinde

Burada örnek verirken dışarıda yazmışım .

Hocam sanırım ben anlatamıyorum

şimdi ana fonksiyonumuz var ve içinde tray nesneleri var

ana fonksiyonun bir başka fonksiyona bağlıyorum

ve bu fonksiyondan ise ana fonksiyonun GUI'sini gui delete ile sildiriyorum

ve yeniden çalıştırıyorum

ama ana GUI'yi silerken nesneleri silmiyor .

demek istediğim bu .

Link to comment
Share on other sites

Evet nedense bende de sizin örnekteki gibiydi ama olmuyordu

Hocam Teşekkür ederim ilginize

Tray nesnelerini fonksiyondan çıkartıp

hiçbir fonksiyonun içine koymayıp sctiptin en üstüne bıraktım

Ne tesadüftür ki oldu .

Link to comment
Share on other sites

Uzun olduğu doğru ama gerçekten hocam neden olmuyordu anlamış değilim

Tray nesneleri sadece bir yerde yazılmış halde .

While Döngüm fonksiyonumun içinde .

TrayItemDelete ile olmuyordu :)

En Sonunda bütün fonksiyonlardan ayırdım Tray Nesneleri

Baktım oldu :))

ilginiz için çok teşekkür ederim .

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...