Jump to content

Geri Ve İleri Saymak İçin Basit Bir Örnek!


blue_life
 Share

Recommended Posts

Kodları inceleyip, kurcalayınız...
[codebox]_Geri_Sayim()
_Ileri_Sayim()

Func _Geri_Sayim()
Local $TIMER_1[4] = [TimerInit(), 0, 0, 15]

Local $Form1 = GUICreate("Geriye Saymak", 300, 170, -1, -1, 0x00080000)
GUISetBkColor(0xFFFFFF)

Local $Label_1 = GUICtrlCreateLabel("Arkadaşlar bu örnekte, basit bir geri sayım yapıp GUICtrlSetData komutuyla butona uyguluyoruz.", 5, 5, 285, 100, 1, 1)
GUICtrlSetColor(-1, 0x000000) ;Arkaplan rengini beyaz yaptık

Local $Button1 = GUICtrlCreateButton($TIMER_1[3] & " Saniye Kaldı", 5, 110, 285, 25, 0x0001)
GUICtrlSetBkColor(-1, 0x000650) ;Arkaplan rengi
GUICtrlSetColor(-1, 0xFFFFFF) ;yazı rengi

GUISetState(@SW_SHOW,$Form1)
While 1
$nMsg = GUIGetMsg() ;Guiden gelen mesajları algılamak için gerekli komut
Switch $nMsg
Case -3
ExitLoop ;Döngüden çıkma komutu
Case $Button1
ExitLoop

EndSwitch

If $TIMER_1[3] = 0 Then ExitLoop ;Süre bitmişse döngüden çıkış yapıyoruz
$TIMER_1[1] = Round(TimerDiff($TIMER_1[0]) / 1000)
If $TIMER_1[1] <> $TIMER_1[2] Then
$TIMER_1[2] = $TIMER_1[1]
$TIMER_1[3] -= 1;Bir azaltıyoruz
GUICtrlSetData($Button1, $TIMER_1[3] & " Saniye Kaldı") ;Bu komut ile butondaki yazıyı değiştiriyoruz
EndIf
WEnd
GUIDelete($Form1)
EndFunc


Func _Ileri_Sayim()
Local $TIMER_1[4] = [TimerInit(), 0, 0, 0]

Local $Form1 = GUICreate("İleri Saymak", 300, 170, -1, -1, 0x00080000)
GUISetBkColor(0xFFFFFF) ;Arkaplan rengini beyaz yaptık

Local $Label_1 = GUICtrlCreateLabel("Arkadaşlar bu örnekte de, basit bir ileri sayım yapıp GUICtrlSetData komutuyla butona uyguluyoruz.", 5, 5, 285, 100, 1, 1)
GUICtrlSetColor(-1, 0x000000)

Local $Button1 = GUICtrlCreateButton($TIMER_1[3] & " Saniye", 5, 110, 285, 25, 0x0001)
GUICtrlSetBkColor(-1, 0x000650)
GUICtrlSetColor(-1, 0xFFFFFF)

GUISetState(@SW_SHOW,$Form1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
ExitLoop
Case $Button1
ExitLoop

EndSwitch

If $TIMER_1[3] = 100 Then ExitLoop ;100 saniye olunca kapatalım. Siz istediğnizi yaparsınız.

$TIMER_1[1] = Round(TimerDiff($TIMER_1[0]) / 1000)
If $TIMER_1[1] <> $TIMER_1[2] Then
$TIMER_1[2] = $TIMER_1[1]
$TIMER_1[3] += 1 ;Bir arttırıyoruz.
GUICtrlSetData($Button1, $TIMER_1[3] & " Saniye") ;Bu komut ile butondaki yazıyı değiştiriyoruz
EndIf
WEnd
GUIDelete($Form1)
EndFunc[/codebox]
Link to comment
Share on other sites

Fonksiyonda ufak bir değişiklik yaparak ikisini bir araya getirdim. Böylece Sayacın yönünü belirleyebiliyoruz, gerisayım yaparken sayım bittiğinde, ileri sayım yaparken verilen saniye değerine ulaştığında istenen işlemi yapması sağlandı.

[code]_Sayac(0,10)

Func _Sayac($CountDown = 0,$Sayi = 15)
Local $Son = $Sayi
if not $CountDown Then $Son = 0
Local $TIMER_1[4] = [TimerInit(), 0, 0, $Son]

Local $Form1 = GUICreate("Sayaç Örneği by BlueLife", 300, 170, -1, -1, 0x00080000)
GUISetBkColor(0xFFFFFF)

Local $Label_1 = GUICtrlCreateLabel("Arkadaşlar bu örnekte, basit bir sayım yapıp GUICtrlSetData komutuyla butona uyguluyoruz.", 5, 5, 285, 100, 1, 1)
GUICtrlSetColor(-1, 0x000000) ;Arkaplan rengini beyaz yaptık

Local $Button1 = GUICtrlCreateButton($TIMER_1[3] & " Saniye", 5, 110, 285, 25, 0x0001)
GUICtrlSetBkColor(-1, 0x000650) ;Arkaplan rengi
GUICtrlSetColor(-1, 0xFFFFFF) ;yazı rengi

GUISetState(@SW_SHOW,$Form1)
While 1
$nMsg = GUIGetMsg() ;Guiden gelen mesajları algılamak için gerekli komut
Switch $nMsg
Case -3
ExitLoop ;Döngüden çıkma komutu
Case $Button1
ExitLoop

EndSwitch

If $CountDown And $TIMER_1[3] = 0 Then ExitLoop ;Süre bitmişse döngüden çıkış yapıyoruz
if not $CountDown And $TIMER_1[3] = $Sayi Then ExitLoop
$TIMER_1[1] = Round(TimerDiff($TIMER_1[0]) / 1000)
If $TIMER_1[1] <> $TIMER_1[2] Then
$TIMER_1[2] = $TIMER_1[1]
if $CountDown Then $TIMER_1[3] -= 1;Bir azaltıyoruz
if not $CountDown Then $TIMER_1[3] += 1;Bir azaltıyoruz
GUICtrlSetData($Button1, $TIMER_1[3] & " Saniye") ;Bu komut ile butondaki yazıyı değiştiriyoruz
EndIf
WEnd
GUIDelete($Form1)
EndFunc[/code]

Link to comment
Share on other sites

Ben böyle örnekleri abarmayı severim biraz, şimdi de counterın yönünü istenildiği anda değiştirmek, istenilen değeri değiştirmek ve counterı durdurmak gibi opsiyonlar ekledim örneğe:

[code]_Sayac(0,10)

Func _Sayac($CountDown = 0,$Sayi = 15)
Local $Son = $Sayi, $Yon = "Yönü Değiştir: Yukarı", $Varsayilan = $Sayi
if not $CountDown Then $Yon = "Yönü Değiştir: Aşağı"
if not $CountDown Then $Son = 0
Local $TIMER_1[6] = [TimerInit(), 0, 0, $Son,True,$Varsayilan]

Local $Form1 = GUICreate("Sayaç Örneği by BlueLife", 300, 170, -1, -1, 0x00080000)
Local $ChangeCounter = GUICtrlCreateButton($Yon,5,20,200,25,0x0001)
Local $Input = GUICtrlCreateInput("",215,18,60,Default,0x2000)
GUICtrlSetLimit(-1,2)
Local $Button1 = GUICtrlCreateButton($TIMER_1[3] & " Saniye", 5, 110, 285, 25, 0x0001)

GUISetState(@SW_SHOW,$Form1)
While 1
$nMsg = GUIGetMsg() ;Guiden gelen mesajları algılamak için gerekli komut
Switch $nMsg
Case -3
ExitLoop ;Döngüden çıkma komutu
Case $Button1
if $TIMER_1[4] Then
$TIMER_1[4] = False
GUICtrlSetData($Button1,"Durduruldu - ["&$TIMER_1[3]&"]")
Else
$TIMER_1[4] = True
EndIf
Case $ChangeCounter
if $Yon = "Yönü Değiştir: Yukarı" Then
$Yon = "Yönü Değiştir: Aşağı"
$CountDown = 0
if Number(GUICtrlRead($Input)) > 0 Then
$Sayi = Number(GUICtrlRead($Input))
Else
$Sayi = $TIMER_1[5]
EndIf
Else
$Yon = "Yönü Değiştir: Yukarı"
$CountDown = 1
$Sayi = 0
EndIf
GUICtrlSetData($ChangeCounter,$Yon)
EndSwitch
if $TIMER_1[4] Then
If $CountDown And $TIMER_1[3] <= 0 Then ExitLoop ;Süre bitmişse döngüden çıkış yapıyoruz
if not $CountDown And $TIMER_1[3] >= $Sayi Then ExitLoop
$TIMER_1[1] = Round(TimerDiff($TIMER_1[0]) / 1000)
If $TIMER_1[1] <> $TIMER_1[2] Then
$TIMER_1[2] = $TIMER_1[1]
if $CountDown Then $TIMER_1[3] -= 1;Bir azaltıyoruz
if not $CountDown Then $TIMER_1[3] += 1;Bir azaltıyoruz
GUICtrlSetData($Button1, $TIMER_1[3] & " Saniye") ;Bu komut ile butondaki yazıyı değiştiriyoruz
EndIf
EndIf
WEnd
GUIDelete($Form1)
EndFunc[/code]

Link to comment
Share on other sites

  • 4 ay sonra...

Kronometre olarak kullanmak istediğim bir program yaptım
Butona basınca sistem saat, dakika ve saniye bilgilerini editboxa yazdırıyor
Butona basmadan editboxsa otomatik olarak hersaniye güncel sistem bilgilerini nasıl yazdırtabilriz?

 

 

#AutoIt3Wrapper_Icon=Install_Edilenler\Kronometreİkon.ico

#AutoIt3Wrapper_Outfile=Kronometre Kamuran 15.08.2012.exe
#AutoIt3Wrapper_Compression=3
#include <GDIPlus.au3> ;Arkaplan için
#Include <GuiButton.au3>
#include <Date.au3>
#include <GuiEdit.au3>
#include <GuiConstantsEx.au3>
 
Opt("TrayIconHide", 0)
Opt("TrayOnEventMode", 1) ; 0 = disable (Menüler işlem Görmez)
Opt("TrayMenuMode", 1) ; Sadece Kullanıcının oluşturduğu menüler Görünsün. (Script pause ve Exit Görünmesin)
;Opt("GUIOnEventMode",1) ; Labele tıkladığında atanan fonksiyonun çalışması için. Bunu kullanınca Sağ üstteki X işaretine basınca program kapanmıyor
;kapanabilmesi için $Form1 in aşağısına şu kodu girmelisin = GUISetOnEvent(-3, "On_Exit") ; Tepedeki X kapat işareti
 
;HotKeySet ( "^y", "_Yenile" ) ; ctrl ve K ye basınca Fonksiyonu çalıştır
;HotKeySet ( "^k", "_Kur" ) ; ctrl ve K ye basınca Fonksiyonu çalıştır
;HotKeySet ( "^s", "_Sil" ) ; ctrl ve K ye basınca Fonksiyonu çalıştır
;====INI Kodları Yedek
;IniWrite("Timer.ini", "Kronometre1" ,"Tarih" , GUICtrlRead($hedit_tarihicin))
 
;TraySetIcon("Install_Edilenler\Kronometreİkon.ico") ; tray ikonu için
;GUISetIcon(@TempDir & "\$.tmp") ;Tepedeki İkon için
 
$Form1 = GUICreate("Kronometre-Kamuran", 255, 100)
;FileInstall("Install_Edilenler\arkaplan.bmp", @TempDir & "\$a.tmp")
;GUICtrlCreatePic(@TempDir & "\$a.tmp",0,0,360,220) ;Arkaplan
GUICtrlSetState($Form1,128) ; Arkaplan varken Butonların  Tıklanabilmesi içindir
GUISetBkColor(0x000000)
GUISetState(@SW_SHOW)
 
 
FileInstall("kronometre.bmp", @TempDir & "\$krn.tmp") ;kronometre
$Kronometre = GUICtrlCreatePic(@TempDir & "\$krn.tmp",190,3,42,42) ;Kronmometre ikonu
;TrayItemSetOnEvent(-1, "_Kronometre")
;GUICtrlSetTip(-1, "Kronometre")
;GUICtrlSetCursor (-1, 0)
 
$hTray_Show_Item = TrayCreateItem("Gizle")
TrayItemSetOnEvent(-1, "To_Tray")
TrayCreateItem("Çık")
TrayItemSetOnEvent(-1,"On_Exit") ; Çalışacak Fonksiyon
 
$EdBaslangic = GUICtrlCreateEdit("", 72, 5, 85, 20) ; ,Sol ,Üst ,Gen  ,Yük
GUICtrlSetFont(-1, 9, 800, 0, "Segoe UI")
$EdBitis = GUICtrlCreateEdit("", 72, 30, 85, 20) ; ,Sol ,Üst ,Gen  ,Yük
GUICtrlSetFont(-1, 9, 800, 0, "Segoe UI")
 
$ButBaslangic = GUICtrlCreateButton("Başlangıç", 5, 5, 60, 22)   ; ,Sol ,Üst ,Gen  ,Yük
;GUISetOnEvent($ButBaslangic, "Baslangiç") ; Bu şekilde fonksiyon çalışmadı while ye yazdım
GUICtrlSetTip(-1, "CTRL+B")
$ButBitis = GUICtrlCreateButton("Bitiş", 5, 30, 60, 22)   ; ,Sol ,Üst ,Gen  ,Yük
GUICtrlSetTip(-1, "CTRL+S")
 
$ButYaz = GUICtrlCreateButton("Sonuç", 5, 55, 60, 22)   ; ,Sol ,Üst ,Gen  ,Yük
$edt = GUICtrlCreateEdit("Sonuç Bölümü", 72, 55, 110, 33 ,$ES_WANTRETURN)   ; ,Sol ,Üst ,Gen  ,Yük
 
Func Baslangic()
$tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
$aFile = _Date_Time_FileTimeToArray($tFile)
$sFile = StringFormat(" %02d:%02d:%02d", $aFile[3], $aFile[4], $aFile[5])
_GUICtrlEdit_SetText($EdBaslangic, $sFile  ) ; &":" & $hedit_Dk
EndFunc
 
Func Bitis()
$tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
$aFile = _Date_Time_FileTimeToArray($tFile)
$sFile = StringFormat(" %02d:%02d:%02d", $aFile[3], $aFile[4], $aFile[5])
_GUICtrlEdit_SetText($EdBitis, $sFile  ) ; &":" & $hedit_Dk
EndFunc
 
 
Func _yaz()
   ; RegWrite("HKEY_CURRENT_USER\Software\Kamuran Kronometre\Kronometre1", "Başlangıç", "REG_SZ",GUICtrlRead($EdBaslangic))
   ; RegWrite("HKEY_CURRENT_USER\Software\Kamuran Kronometre\Kronometre1", "Bitiş", "REG_SZ",GUICtrlRead($EdBitis))
    $sDosya = @TempDir & '\Kronometre Sonucu.txt'
    IniWrite($sDosya, "Kronometre 1" ," Başlangıç " , GUICtrlRead($EdBaslangic))
    IniWrite($sDosya, "Kronometre 1" ," Bitiş ......      " , GUICtrlRead($EdBitis))
   ; $sk = RegRead("HKEY_CURRENT_USER\Software\Kamuran Kronometre\Kronometre1", "Başlangıç")
$iniread1 = IniRead(@TempDir & "\Kronometre Sonucu.txt", "Kronometre 1", "Başlangıç","NotFound")
$iniread2 = IniRead(@TempDir & "\Kronometre Sonucu.txt", "Kronometre 1", "Bitiş ......","NotFound")
_GUICtrlEdit_SetText($edt, "Başlangıç = " & ($iniread1) &  @CRLF&  "Bitiş ........ = " &   ($iniread2)  )
    TrayTip(".::Kamuran::.", "Kronometre Sonucu Alındı...", 5, 2)
EndFunc
 
;Func _Sil()
;RegDelete("HKEY_CURRENT_USER\Software\Kamuran Kronometre\Kronometre1")
;TrayTip(".::Kamuran::.", "Kronometre Silindi", 5, 2)
;EndFunc
 
 
Func On_Exit()
;FileDelete(@TempDir & "\*.mp3")
;FileDelete(@TempDir & "\*.tmp")
Exit
 EndFunc
 
 ;Func _Hakkinda()
;MsgBox(0,"Hakkında","By Kamuran" ,2)
;EndFunc
 
Func To_Tray()
DirRemove(@TempDir & "\kam" ,1)
If TrayItemGetText($hTray_Show_Item) = "Göster" Then
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_RESTORE, $Form1)
TrayItemSetText($hTray_Show_Item, "Gizle")
Else
GUISetState(@SW_HIDE, $Form1)
TrayItemSetText($hTray_Show_Item, "Göster")
EndIf
EndFunc   ;==>To_Tray
 
 
 
 
While 1
Sleep(10)
$nMsg = GUIGetMsg()
Switch $nMsg
 
Case $GUI_EVENT_CLOSE
On_Exit()
Exit
 
Case $ButBaslangic
Baslangic()
 
Case $ButBitis
Bitis()
 
 
Case $ButYaz
_yaz()
 
Case $GUI_EVENT_MINIMIZE
To_Tray()
EndSwitch
WEnd
;end By Kamuran 16.08.2012
 
 
Edited by kamuran731
Link to comment
Share on other sites

  • 9 ay sonra...

Aslında yukarıda da ve benim verdiğim linktede örnek var. Yinede kodları basitleştirip daha basit bir şey hazırlamaya çalıştım:

GUICreate("Örnek", 220, 125, Default, Default, 0x00080000)
GUISetBkColor("#000000")
Local $label = GUICtrlCreateLabel("00", 10, 20, 50, 50)
GUICtrlSetFont(-1, 33, 400)
GUICtrlSetBkColor(-1, 0x00ff00)
GUISetState(@SW_SHOW)

Local $TIMER_1[4] = [TimerInit(), 0, 0, 0]


While 1
	$msg = GUIGetMsg()
	Select
		Case $msg = -3
			GUIDelete()
			Exit
		Case $msg = $label
			GUIDelete()
			Exit
	EndSelect

	$TIMER_1[1] = Round(TimerDiff($TIMER_1[0]) / 1000)

	If $TIMER_1[1] <> $TIMER_1[2] Then
		$TIMER_1[2] = $TIMER_1[1]
		$TIMER_1[3] += 1
		GUICtrlSetData($label, $TIMER_1[3])
	EndIf
WEnd
Link to comment
Share on other sites

Düzenledim:
 

GUICreate("Örnek", 220, 125, Default, Default, 0x00080000)
GUISetBkColor("#000000")
Local $ileri = GUICtrlCreateLabel("00", 10, 20, 50, 50)
GUICtrlSetFont(-1, 33, 400)
GUICtrlSetBkColor(-1, 0x00ff00)
GUISetState(@SW_SHOW)

Local $TIMER_1[4] = [TimerInit(), 0, 0, 0], $ileribaslat


While 1
	$msg = GUIGetMsg()
	Select
		Case $msg = -3
			GUIDelete()
			Exit
		Case $msg = $ileri
			$ileribaslat = 1
	EndSelect

	If $ileribaslat = 1 Then
		$TIMER_1[1] = Round(TimerDiff($TIMER_1[0]) / 1000)
		If $TIMER_1[1] <> $TIMER_1[2] Then
			$TIMER_1[2] = $TIMER_1[1]
			$TIMER_1[3] += 1
			GUICtrlSetData($ileri, $TIMER_1[3])
		EndIf
	EndIf
WEnd

13 dk'dan geriye sayım dakika ve saniye şeklinde mi yoksa sadece saniye şeklinde mi olacak?

Edited by reyiz
Link to comment
Share on other sites

tıklayınca baştan başlamıyor bak üste verdiğim örnekte adam yazı var tıklayınca programı hazırlarken yaptğı süreden geri sayıyor tekrar tıkladğında yazı tekrar tıkladğında süre geliyor incelersen anlarsın üstekni indirp

Link to comment
Share on other sites

Oldu mu?

GUICreate("Örnek", 220, 125, Default, Default, 0x00080000)
GUISetBkColor("#000000")
Local $ileri = GUICtrlCreateLabel("00", 10, 20, 50, 50)
GUICtrlSetFont(-1, 33, 400)
GUICtrlSetBkColor(-1, 0x00ff00)
GUISetState(@SW_SHOW)

Local $ileribaslat


While 1
	$msg = GUIGetMsg()
	Select
		Case $msg = -3
			GUIDelete()
			Exit
		Case $msg = $ileri
			If Not $ileribaslat = 1 Then
				Local $TIMER_1[4] = [TimerInit(), 0, 0, 0]
				$ileribaslat = 1
			Else
				$ileribaslat = 0
				GUICtrlSetData($ileri, "00")
				Local $TIMER_1[4] = [TimerInit(), 0, 0, 0]
			EndIf
	EndSelect

	If $ileribaslat = 1 Then
		$TIMER_1[1] = Round(TimerDiff($TIMER_1[0]) / 1000)
		If $TIMER_1[1] <> $TIMER_1[2] Then
			$TIMER_1[2] = $TIMER_1[1]
			$TIMER_1[3] += 1
			GUICtrlSetData($ileri, $TIMER_1[3])
		EndIf
	EndIf
WEnd
Eksik varsa lütfen söyle. Edited by reyiz
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...