Jump to content

Fonksiyona Diğer Fonksiyonu Durduma Görevi Vermek?


x_files_x
 Share

Recommended Posts

Mrb arkadaşlar elimde bi script vardı dakika belirliyorsun ve o belirledigin dakika bitince diledigin bir program otomatik acılıyordu, bende buna bir arayüz uyduruyum dedim, mantık sadece kendimi geliştirmek, ancak herseyi yaptım çalıştır dedigim zaman program saniyeleri sayarken ben iptal edemiyorum yada programı tamaman kapatamıyorum calısmıyor, bir yerde yanlıslık yaptım bir bakarmısınız rica etsem, basit ama ben eksik bilgilere sahibim

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TimeStartExe", 247, 136, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Input1 = GUICtrlCreateInput("", 16, 24, 121, 21)
$Button1 = GUICtrlCreateButton("Proğram Seç", 144, 24, 75, 25)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Combo1 = GUICtrlCreateCombo("", 16, 88, 57, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Group1 = GUICtrlCreateGroup("Dakika", 8, 70, 72, 50)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("  Tercih Ettiğiniz Proğram", 8, 5, 225, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("Çalıştır", 88, 84, 90, 33)
GUICtrlSetOnEvent($Button2, "Button2Click")
$Button3 = GUICtrlCreateButton("Vazgeç", 185, 84, 50, 33)
GUICtrlSetOnEvent($Button3, "Button3Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	Sleep(100)
WEnd



Func Button1Click()
	$message = "TimeStartExe"
	$var = FileOpenDialog($message, @DesktopDir & "", "Proğram (*.exe)|Müzik (*.mp3)", 1 + 4 )
    $var = StringReplace($var, "|", @CRLF)
	ControlSetText("TimeStartExe", "", $Input1 ,$var)
EndFunc

Func Button2Click()
	$dakika = GUICtrlRead($Combo1)
    Local $60Count = 0, $begin = TimerInit()
While $dakika > $60Count

    $dif = TimerDiff($begin)
    $dif2 = StringLeft($dif, StringInStr($dif, ".") -1)
    $Count = int($dif/1000)
    $60Count = Int($Count / 60)

    ToolTip("Belirlenen Dakika = " & $dakika & @CRLF & "Geçen Dakika = " & $60Count & @CRLF & "Saniye = " & $Count & @CRLF & "Mili Saniye = " & $dif2, 0, 0, "TimeStartExe", 1)

    Sleep(20)

WEnd
$var = GUICtrlRead($Input1)
ShellExecute($var)
EndFunc

Func Button3Click()
;scripti durduracak kod ??
EndFunc

Func Form1Close()
Exit 0 ;scripti kapatacak kod
EndFunc





Link to comment
Share on other sites

Kodlamanın hepsini düzeltmedim. Neyse aşağıdaki gibi bir yöntem izleyebilirsin. Kolay gelsin...

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TimeStartExe", 247, 136, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Input1 = GUICtrlCreateInput("notepad.exe", 16, 24, 121, 21)
$Button1 = GUICtrlCreateButton("Proğram Seç", 144, 24, 75, 25)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Input2 = GUICtrlCreateInput("1", 16, 88, 57, 25, 0x2000)
GUICtrlCreateUpdown($Input2)

$Group1 = GUICtrlCreateGroup("Dakika", 8, 70, 72, 50)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup(" Tercih Ettiğiniz Proğram", 8, 5, 225, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("Çalıştır", 88, 84, 90, 33)
GUICtrlSetOnEvent($Button2, "Button2Click")
$Button3 = GUICtrlCreateButton("Vazgeç", 185, 84, 50, 33)
GUICtrlSetOnEvent($Button3, "Button3Click")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
	Sleep(100)
WEnd

Func Button1Click()
	Local $FileSelect = FileOpenDialog("TimeStartExe", "", "Proğram (*.exe)|Müzik (*.mp3)", 3,"",$Form1)
	If @error Then Return SetError(1, 0, 0)
	GUICtrlSetData($Input1,$FileSelect)
EndFunc   ;==>Button1Click

Func Button2Click()
	Local $minute = Number(GUICtrlRead($Input2))
	If $minute = 0 Then Return 0
	Opt("GUIOnEventMode", 0)

	Local $tm_sec,$t_sec,$t_minute = 0,$timer = TimerInit()
	While $minute > $t_minute
		Switch GUIGetMsg()
			Case -3
				Exit
			Case $Button3
				ToolTip("")
				ExitLoop

		EndSwitch

		$tm_sec = Round(TimerDiff($timer)) ;milli-seconds
		$t_sec = Round($tm_sec / 1000) ;seconds
		$t_minute = Round($t_sec / 60) ;minute

		ToolTip("Belirlenen Dakika = " & $minute & @CRLF & "Geçen Dakika = " & $t_minute & @CRLF & "Saniye = " & $t_sec & @CRLF & "Mili Saniye = " & $tm_sec, 0, 0, "TimeStartExe", 1)
		Sleep(25) ;Cpu Save

	WEnd

	Local $Return = 0
	If $minute <= $t_minute Then
		Local $f_execute = StringStripWS(GUICtrlRead($Input1),3)
		$Return = ShellExecute($f_execute)
	EndIf
	ToolTip("")
	Opt("GUIOnEventMode", 1)
	Return $Return
EndFunc   ;==>Button2Click

Func Button3Click()
	;scripti durduracak kod ??
EndFunc   ;==>Button3Click

Func Form1Close()
	Exit 0 ;scripti kapatacak kod
EndFunc   ;==>Form1Close
Link to comment
Share on other sites

İşine yarayacak bir kod _IsPressed  , Autoit Yardım Dosyasından daha fazla ayrıntıya bakabilirsin , bunu dene ;

 

#include <Misc.au3>
 Local $hDLL = DllOpen("user32.dll")

 

Func Button2Click()
  $dakika = GUICtrlRead($Combo1)
    Local $60Count = 0, $begin = TimerInit()
While $dakika > $60Count

   If _IsPressed("41", $hDLL) Then ExitLoop  ;A tuşuna basılınca Döngüden Çıkar

    $dif = TimerDiff($begin)
    $dif2 = StringLeft($dif, StringInStr($dif, ".") -1)
    $Count = int($dif/1000)
    $60Count = Int($Count / 60)

    ToolTip("Belirlenen Dakika = " & $dakika & @CRLF & "Geçen Dakika = " & $60Count & @CRLF & "Saniye = " & $Count & @CRLF & "Mili Saniye = " & $dif2, 0, 0, "TimeStartExe", 1)

    Sleep(20)

WEnd

Link to comment
Share on other sites

Hocam verdiginiz örnekte 1 dakika deyince 30 saniyede işlem bitiyor, 2 dakika diyincede 90 saniyede, acaba hata nerdedir?

    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt("GUIOnEventMode", 1)
    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("TimeStartExe", 230, 136, 192, 124)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
    $Input1 = GUICtrlCreateInput("", 16, 24, 136, 21)
    $Button1 = GUICtrlCreateButton("Program Seç", 165, 16, 40, 40, $BS_ICON)
	GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button

	GUICtrlSetImage(-1, "shell32.dll", 46)
    GUICtrlSetOnEvent($Button1, "Button1Click")
    $Input2 = GUICtrlCreateInput("1", 16, 88, 57, 25, 0x2000)
    GUICtrlCreateUpdown($Input2)

    $Group1 = GUICtrlCreateGroup("Dakika", 8, 70, 72, 55)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group2 = GUICtrlCreateGroup(" Tercih Ettiğiniz Proğram", 8, 5, 213, 57)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button2 = GUICtrlCreateButton("Çalıştır", 86, 80, 40, 40, $BS_ICON)
	GUICtrlSetImage(-1, "shell32.dll", 22)
    GUICtrlSetOnEvent($Button2, "Button2Click")
    $Button3 = GUICtrlCreateButton("Vazgeç", 131, 80, 40, 40, $BS_ICON)
	GUICtrlSetImage(-1, "shell32.dll", 28)
    GUICtrlSetOnEvent($Button3, "Button3Click")
	$label = GUICtrlCreateLabel(" Adem Sezgin", 178, 87, 57, 40)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

    While 1
    Sleep(100)
    WEnd

    Func Button1Click()
    Local $FileSelect = FileOpenDialog("TimeStartExe", @DesktopDir, "Proğram (*.exe)|Müzik (*.mp3)", 3,"",$Form1)
    If @error Then Return SetError(1, 0, 0)
    GUICtrlSetData($Input1,$FileSelect)
    EndFunc ;==>Button1Click

    Func Button2Click()
    Local $minute = Number(GUICtrlRead($Input2))
    If $minute = 0 Then Return 0
    Opt("GUIOnEventMode", 0)

    Local $tm_sec,$t_sec,$t_minute = 0,$timer = TimerInit()
    While $minute > $t_minute
    Switch GUIGetMsg()
    Case -3
    Exit
    Case $Button3
    ToolTip("")
	ControlSetText("TimeStartExe" ,"", $Input1 ,"")
	ExitLoop
	EndSwitch

$tm_sec = Round(TimerDiff($timer)) ;milli-seconds
$t_sec = Round($tm_sec / 1000) ;seconds
$t_minute = Round($t_sec / 60) ;minute

ToolTip("Belirlenen Dakika = " & $minute & @CRLF & "Geçen Dakika = " & $t_minute & @CRLF & "Saniye = " & $t_sec & @CRLF & "Mili Saniye = " & $tm_sec, 0, 0, "TimeStartExe", 1)
Sleep(25) ;Cpu Save

WEnd

Local $Return = 0
If $minute <= $t_minute Then
Local $f_execute = StringStripWS(GUICtrlRead($Input1),3)
$Return = ShellExecute($f_execute)
EndIf
ToolTip("")
Opt("GUIOnEventMode", 1)
Return $Return
EndFunc ;==>Button2Click

    Func Button3Click()
    EndFunc ;==>Button3Click

    Func Form1Close()
    Exit 0
    EndFunc ;==>Form1Close
Edited by x_files_x
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...