Mehmet Posted May 19, 2013 Share Posted May 19, 2013 (edited) Arkadaşlar ne zaman case ile seçim yapmak istesem If Then veya fonksiyonlar arasında hata alıyorum örnek vermek gerekirse şöyle tarif edeyim #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <Fonksiyonum.au3> $guim = GUICreate("Formum",400,242) $altgui = _Fonksiyon1($guim,1,1,320,240) $Button1 = GUICtrlCreateButton("buton1", 325, 14, 70, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then _Fonksiyon2($altgui) Exit EndIf WEnd burada fonksiyon1 ve fonksiyon 2 guie bağladım 3.fonksiyonumuda butonla çağırmak istiyorum Case $Button1 _Fonksiyon3 gibi ama buradaki Case $Button1 _Fonksiyon3'i nereye yazarsam yazayım hata alıyorum case ile seçim yaptığımızda If EndIf gibi kapatmamızmı gerekiyor birtürlü bu case'i nerede nasıl kullanacağımı öğrenemedim Edited May 19, 2013 by MeHMeTBeN Quote Link to comment Share on other sites More sharing options...
SimpsoN_Bart Posted May 19, 2013 Share Posted May 19, 2013 (edited) Öncellikle kodlarını çalıştıramadım çünkü Fonksiyonum kütüphanesi bende yok.Ne yapmak istediğini de pek anlamadım doğrusu yani formlar arası geçiş falan mı yapıyorsun ? Eğer böyle ise GUISwitch koduna bak eğer böyle değilse biraz daha açıklayıcı olursan yardımcı olabiliriz. Kodlarından az çok anladığım kadarıyla şöyle bir şey yapmak istiyorsun ki -3 event olayına fonksiyon yazmışsın.Biraz incele.. #include <GUIConstantsEx.au3> Example() Func Example() Local $parent1, $parent2, $tabitem, $msg $parent1 = GUICreate("Parent1") GUICtrlCreateTab(10, 10) $tabitem = GUICtrlCreateTabItem("tab1") GUICtrlCreateTabItem("tab2") GUICtrlCreateTabItem("") $parent2 = GUICreate("Parent2", -1, -1, 100, 100) GUISwitch($parent2) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE GUISwitch($parent1, $tabitem) GUICtrlCreateButton("OK", 50, 50, 50) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW, $parent1) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Edited May 19, 2013 by SimpsoN_Bart Quote Link to comment Share on other sites More sharing options...
mesale0077 Posted May 19, 2013 Share Posted May 19, 2013 #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TabConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Dialog", 335, 236, 250, 250) $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("&OK", 70, 203, 75, 25) $Button2 = GUICtrlCreateButton("&Cancel", 149, 204, 75, 25) $Button3 = GUICtrlCreateButton("&Help", 229, 204, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _forum1() EndSwitch WEnd func _forum1() $Form2 = GUICreate("Tabbed Notebook Dialog", 413, 298, 299, 218) $PageControl1 = GUICtrlCreateTab(8, 8, 396, 256) $TabSheet1 = GUICtrlCreateTabItem("TabSheet1") $TabSheet2 = GUICtrlCreateTabItem("TabSheet2") $TabSheet3 = GUICtrlCreateTabItem("TabSheet3") GUICtrlCreateTabItem("") $Button1 = GUICtrlCreateButton("&OK", 166, 272, 75, 25) $Button2 = GUICtrlCreateButton("&Cancel", 246, 272, 75, 25) $Button3 = GUICtrlCreateButton("&Help", 328, 272, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd endfunc Quote Link to comment Share on other sites More sharing options...
Mehmet Posted May 20, 2013 Author Share Posted May 20, 2013 Fonksiyonum.au3 sadece örnek olsun diye belirttim öyle bir udf yok zaten biraz eksik anlatmışım haliyle sizde beni yanlış anlamışsınız :) neyse varolan bir udf belirteyim belki ozaman anlaşırız :) Webcam.au3 #include <WindowsConstants.au3> #include-once $WM_CAP_START = 0x400 $WM_CAP_UNICODE_START = $WM_CAP_START +100 $WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 $WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 $WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW $WM_CAP_ABORT = $WM_CAP_START + 69 $WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 $WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 $WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 $WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 $WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 $WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 $WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 $WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 $WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 $WM_CAP_EDIT_COPY = $WM_CAP_START + 30 $WM_CAP_END = $WM_CAP_UNICODE_END $WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 $WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 $WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 $WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 $WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 $WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 $WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 $WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 $WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 $WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 $WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 $WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 $WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 $WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 $WM_CAP_GET_STATUS = $WM_CAP_START + 54 $WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 $WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 $WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 $WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 $WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 $WM_CAP_PAL_OPENA = $WM_CAP_START + 80 $WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 $WM_CAP_PAL_PASTE = $WM_CAP_START + 82 $WM_CAP_SEQUENCE = $WM_CAP_START + 62 $WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 $WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 $WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 $WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 $WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 $WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 $WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 $WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 $WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 $WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 $WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 $WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 $WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 $WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 $WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 $WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 $WM_CAP_SET_SCALE = $WM_CAP_START + 53 $WM_CAP_SET_SCROLL = $WM_CAP_START + 55 $WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 $WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 $WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 $WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 $WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 $WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 $WM_CAP_STOP = $WM_CAP_START + 68 #include <GUIConstants.au3> $avi = DllOpen("avicap32.dll") $user = DllOpen("user32.dll") ;=============================================================================== ; ; Description: Open's a webcam preview screen in your gui ; Syntax: _WebcamOpen($sHwnd, $sLeft, $sTop, $sWidth, $sHeight, $sPort=0) ; Parameter(s): $sHwnd - The handle of the gui ; $sLeft - Left coord. of the preview screen ; $sTop - Top coord. of the preview screen ; $sWidth - Width of the preview screen ; $sHeight - Height of the preview screen ; $sPort - Specify wich webcam port you want to use (for multiple webcams) ; Requirement(s): A webcam ; Return Value(s): On Success - Returns id needed for other controls ; On Failure - Returns -1 ; Author(s): Ludocus ; Note(s): If a black/blank screen shows up, try using different $sPort's (0 to 3) ; ;=============================================================================== Func _WebcamOpen($sHwnd, $sLeft, $sTop, $sWidth, $sHeight, $sPort=0) $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", $sLeft, "int", $sTop, "int", $sWidth, "int", $sHeight, "hwnd", $sHwnd, "int", 1) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", $sPort, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0) if @error then return -1 return $cap[0] EndFunc ;=============================================================================== ; ; Description: Creates a Snapshot from a webcam ; Syntax: _WebcamSnap($sId, $sFile) ; Parameter(s): $sId - Id (returned from _WebcamOpen) ; $sFile - File to save the snapshot to (*.bmp) ; Requirement(s): A webcam ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; Author(s): Ludocus ; Note(s): None ; ;=============================================================================== Func _WebcamSnap($sId, $sFile) DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $sFile) if @error Then return 0 Else return 1 EndIf EndFunc ;=============================================================================== ; ; Description: Closes the preview screen created with _WebcamOpen ; Syntax: _WebcamClose($sId) ; Parameter(s): $sId - Id (returned from _WebcamOpen) ; Requirement(s): A webcam ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; Author(s): Ludocus ; Note(s): None ; ;=============================================================================== Func _WebcamClose($sId) DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_END, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0) DllClose($user) if @error Then return 0 Else return 1 EndIf EndFunc ;=============================================================================== ; ; Description: Starts recording the webcam to a file ; Syntax: _WebcamRecordStart($sFile, $sId) ; Parameter(s): $sId - Id (returned from _WebcamOpen) ; $sFile - File to save the movie to (*.avi) ; Requirement(s): A webcam ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; Author(s): Ludocus ; Note(s): Stop recording by: _WebcamRecordStop($Id) ; ;=============================================================================== Func _WebcamRecordStart($sFile, $sId) DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $sFile) DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0) if @error Then return 0 Else return 1 EndIf EndFunc ;=============================================================================== ; ; Description: Stops recording. ; Syntax: _WebcamRecordStop($sId) ; Parameter(s): $sId - Id (returned from _WebcamOpen) ; Requirement(s): A webcam ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; Author(s): Ludocus ; Note(s): None ; ;=============================================================================== Func _WebcamRecordStop($sId) DllCall($user, "int", "SendMessage", "hWnd", $sId, "int", $WM_CAP_STOP, "int", 0, "int", 0) if @error Then return 0 Else return 1 EndIf EndFunc #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <Webcam.au3> $gui = GUICreate("Kameranız",400,242) $camera = _WebcamOpen($gui,1,1,320,240) $Button1 = GUICtrlCreateButton("Kayıt", 325, 14, 70, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then _WebcamClose($camera) Exit Case $Button1 _WebcamSnap EndIf WEnd Burada Case $Button1'in _WebcamSnap fonksiyonunu çalıştırsın istiyorum ama neden case eklediğimde hata veriyor case kullanabilmem için ne yapmam gerekiyor.? Quote Link to comment Share on other sites More sharing options...
SimpsoN_Bart Posted May 20, 2013 Share Posted May 20, 2013 (edited) Sen biraz karıştırmışsın olayı bi keresinde öyle fonksiyonu çağıramazsın ki ve hala tam olarak ne yapmaya çalıştığını tam kestiremedim ama bu şekilde yazıp hata alman çok normal.$camera = _WebcamOpen($gui,1,1,320,240) böyle bi yazım olmaz yani. Ordaki $sHwnd gui handlesi değildir web cam ile ilgili bi durum ek olarak hem case yazmışın hem if yazmışın anlamadım ki :D Edited May 20, 2013 by SimpsoN_Bart Quote Link to comment Share on other sites More sharing options...
mesale0077 Posted May 20, 2013 Share Posted May 20, 2013 #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Webcam.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("[#] Form1 [#]", 640, 600,-1, -1) _WebcamInit() _Webcam($Form1,640,480,0,0) $Button1 = GUICtrlCreateButton("Başla", 56, 530, 100, 50) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _WebcamStop() Exit Case $Button1 _WebcamSnapShot() EndSwitch WEnd ama denemedim benim pcde webcam yok :) ses kartı yok :) onun için sade bir pc :) Quote Link to comment Share on other sites More sharing options...
MostWanted Posted May 23, 2013 Share Posted May 23, 2013 @simpson ordaki $sHwnd gui handle ı zaten au3 te yazıyor. @mehmetben senin sorunun case veya iflerden ziyade fonksiyonu çağırma yönteminde.@mesela007 de bir şeyler yazmaya çalışmış ama au3 ü incelememiş.Ordaki parametreleri girmen lazım.Düzeltirsek; #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <Webcam.au3> $gui = GUICreate("Kameranız",400,242) $camera = _WebcamOpen($gui,1,1,320,240) $Button1 = GUICtrlCreateButton("Kayıt", 325, 14, 70, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then _WebcamClose($camera) Exit Case $Button1 _WebcamSnap($camera, $file) ; $file kaydedileceği dosyanın yolu. EndIf WEnd Quote Link to comment Share on other sites More sharing options...
SimpsoN_Bart Posted May 23, 2013 Share Posted May 23, 2013 Fonksiyon çağırma yönteminin yanlış olduğunu bende söyledim ama cam olmadı için kodları test etme imkanım olmadı bende olayı yanlış anladım galiba ve bu udf yi hiç kullanmadım. Quote Link to comment Share on other sites More sharing options...
mesale0077 Posted May 23, 2013 Share Posted May 23, 2013 arkadaşlar ben sadece case kullanımını göstermek istedim dogru, kodu deneme şansım olmadı zaten kodun altına yazdım eğer fark ettiyseniz bu şekilde yazmıştım ama denemedim benim pcde webcam yok :) ses kartı yok :) onun için sade bir pc :) case kullanımına göre cevap yazdım galiba sorunlar farklılıklar göstermiş sorun çözüldüyse önemli değil dostlar kolay gele Quote Link to comment Share on other sites More sharing options...
MostWanted Posted May 24, 2013 Share Posted May 24, 2013 Sizlere lafım yok gençler savunmaya geçmenize gerek yok, sadece küçük yanlışlar yaptığınızı söyledim, yoksa biliyorum iyi uşaklarsınız :P Quote Link to comment Share on other sites More sharing options...
SimpsoN_Bart Posted May 24, 2013 Share Posted May 24, 2013 Ben şahsen durumumu açıkladım mosty ben böyle yazınca mesalede yazma gereği duydu sanırım neyse olayı çözmen iyi oldu saolasın :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.