mustafavanli Posted July 13, 2015 Share Posted July 13, 2015 (edited) Merhabalar, autoit ile program yazmaya yeni başladım ve bir şeyler yazdım fakat yazdığım programın daha stabil çalışmasını istiyorum. Stabilden kastımı tek tek anlatacağım. Ama ondan önce kodu ve ne işe yaradığını bilmeniz lazım. Bir arkadaşım benden metin 2 de hızlı ch atmak için bir program yazmamı ve bunun ban sebebi olmadan olmasını istedi bende yolu aşağıdaki kodlarda buldum ama ufak tefek sorunlar var(aslında onun için onun beklediğinden de iyi çalışıyor ama ben daha iyisini istiyorum). Önce kodlar; [spoiler]#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include #include #include #include Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 0) $mpos = MouseGetPos() #Region ### START Koda GUI section ### Form= $Form1= GUICreate("Metin2 CH ATICI", 335, 71, $mpos[0], $mpos[1]) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $Button3 = GUICtrlCreateButton("CH4", 8, 40, 75, 25) GUICtrlSetOnEvent($Button3, "Button4Click") $Button4 = GUICtrlCreateButton("CH2", 88, 8, 75, 25) GUICtrlSetOnEvent($Button4, "Button2Click") $Button5 = GUICtrlCreateButton("CH3", 168, 8, 75, 25) GUICtrlSetOnEvent($Button5, "Button3Click") $Button6 = GUICtrlCreateButton("CH6", 168, 40, 75, 25) GUICtrlSetOnEvent($Button6, "Button6Click") $Button1 = GUICtrlCreateButton("CH5", 88, 40, 75, 25) GUICtrlSetOnEvent($Button1, "ch5Click") $Button2 = GUICtrlCreateButton("CH1", 8, 8, 75, 25) GUICtrlSetOnEvent($Button2, "ch1Click") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $serveradiiii="Reklam olmasın :)" $serverx = 840 $servery = 640 $chx = 1074 $ch1y= 620 $ch2y= 635 $ch3y= 650 $ch4y= 665 $ch5y= 690 $ch6y=705 $idee= "bosver id yi" $pwee= "id yoksa zaten önemli değil" $tmmtusuy=932 Func clientkontrol() WinWait($serveradiiii) Sleep(250) WinActivate($serveradiiii) Sleep(250) WinWaitActive($serveradiiii) Sleep(250) BlockInput(1) EndFunc While 1 $winpos = WinGetPos($Form1) $ssss = PixelGetColor(1877, 956) if $ssss = "0" Then $mpos1 = MouseGetPos() WinActivate($Form1) if $mpos1[0] > $winpos[0]+335 Or $mpos1[0] < $winpos[0] Then WinMove($Form1,"",$mpos1[0],$mpos1[1]) EndIf EndIf Sleep(500) WEnd Func IDPW() Send($idee) Send("{TAB}") Send($pwee) Sleep(250) Send("{ENTER}") BlockInput(0) EndFunc Func ch1Click() clientkontrol() MouseClick("left",$serverx,$servery,2,0) Sleep(250) MouseClick("left",$chx,$ch1y,2,0) Sleep(250) MouseClick("left",$chx,$tmmtusuy,1,0) Sleep(250) IDPW() EndFunc Func Button2Click() clientkontrol() MouseClick("left",$serverx,$servery,2,0) Sleep(250) MouseClick("left",$chx,$ch2y,2,0) Sleep(250) MouseClick("left",$chx,$tmmtusuy,2,0) Sleep(250) IDPW() EndFunc Func Button3Click() clientkontrol() MouseClick("left",$serverx,$servery,2,0) Sleep(250) MouseClick("left",$chx,$ch3y,2,0) Sleep(250) MouseClick("left",$chx,$tmmtusuy,2,0) Sleep(250) IDPW() EndFunc Func Button4Click() clientkontrol() MouseClick("left",$serverx,$servery,2,0) Sleep(250) MouseClick("left",$chx,$ch4y,2,0) Sleep(250) MouseClick("left",$chx,$tmmtusuy,2,0) Sleep(250) IDPW() EndFunc Func ch5Click() clientkontrol() MouseClick("left",$serverx,$servery,2,0) Sleep(250) MouseClick("left",$chx,$ch5y,2,0) Sleep(250) MouseClick("left",$chx,$tmmtusuy,1,0) Sleep(250) IDPW() EndFunc Func Button6Click() clientkontrol() MouseClick("left",$serverx,$servery,2,0) Sleep(250) MouseClick("left",$chx,$ch6y,2,0) Sleep(250) MouseClick("left",$chx,$tmmtusuy,2,0) Sleep(250) IDPW() EndFunc Func Form1Close() Exit EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc #EndRegion form1 kodları[/spoiler] Şimdi anlatmaya başlayayım. Koddan anladığınız üzere metin 2 giriş ekranına döndüğünde kendini ön plana çıkararak bir ch seçmemi istiyor ve seçene kadar kendini fare imlecinin yanına taşıyor. Bunu yaparken ise sanki ufaktan bir lag hissediyorum tuşlara basarken bunun nedenin aşağıdaki döngüden olduğunu düşünüp birazcık uyutmayı denedim ama olmadı maalesef :(.Ayrıca oradaki 2. "if" döngüsü fare imleci formun içinde değilse formu fare imlecine taşı demek için orada.(if döngüsünün şartlarında da sorun var galiba) Birincisi ise sadece giriş ekranında iken bu döngü gerçekleşsin diye orada. Bana biraz fazla acemi çözümü gibi(ayrıca iyi çalışmadığını hissettiriyor bana) geldi bu döngü, daha profesyonel ve daha stabil her türlü çözüm önerisi veya kod parçası burada geçerli. While 1 $winpos = WinGetPos($Form1) $ssss = PixelGetColor(1877, 956) if $ssss = "0" Then $mpos1 = MouseGetPos() WinActivate($Form1) if $mpos1[0] > $winpos[0]+335 Or $mpos1[0] < $winpos[0] Then WinMove($Form1,"",$mpos1[0],$mpos1[1]) EndIf EndIf Sleep(500) WEnd Bir diğeri ise butonlara bastıktan sonra bazen en son basması gereken sol tuşa basmıyor.Basmaması için hiç bir sebep göremedim. Ben bunu da çözemedim maalesef. Konuya bakan ve ilgilenen herkese sonsuz teşekkürler. Edited July 13, 2015 by mustafavanli Quote Link to comment Share on other sites More sharing options...
MostWanted Posted July 14, 2015 Share Posted July 14, 2015 Döngüde yazdıklarını bir fonksiyon haline getirip autoit kütüphanesinden AdlibRegister fonksiyonunu kullanmayı dene belki lagı azaltır. If şartlarında da dediğin gibi sorun var, or değil and olacak bir de diğer aksisinde sınırlarını if'e eklemelisin. Quote Link to comment Share on other sites More sharing options...
mustafavanli Posted July 15, 2015 Author Share Posted July 15, 2015 Teşekkür ederim, while döngüsünü aşağıdaki haline getirdim lag yok oldu ve artık pencere fare imlecinin yanına taşınmıyor. Döngüdeki $a değişkeni "true-false" dışında değer almıyor. Bu da döngüyü sadece gerektiği zaman çalıştırıp diğer zamanlarda çalıştırmıyor. While $a $ssss = PixelGetColor(1877, 956) if $ssss = "0" Then WinWait($Form1) WinSetOnTop($Form1,"",1) Else WinWait($Form1) WinSetOnTop($Form1,"",0) EndIf Sleep(1000) WEnd Quote Link to comment Share on other sites More sharing options...
mustafavanli Posted July 15, 2015 Author Share Posted July 15, 2015 Ufak bir sorunum daha var yeni konu açmak istemedim.Eğer bu pencere aktifse demek için hangi if kodunu kullanabilirim. Bildiğim kadarı ile WinWaitActive kodu bunu desteklemiyor. Önerilerinizi bekliyorum... Quote Link to comment Share on other sites More sharing options...
MostWanted Posted July 15, 2015 Share Posted July 15, 2015 WinActive kullanabilirsin. Quote Link to comment Share on other sites More sharing options...
mustafavanli Posted July 15, 2015 Author Share Posted July 15, 2015 Malesef aradığım bu değil... Quote Link to comment Share on other sites More sharing options...
Sscrappy Posted July 24, 2015 Share Posted July 24, 2015 Malesef aradığım bu değil... İf(WinActive("Adsız")) Then MsgBox(64, "Coder Scrappy", "Not defteri şu an aktif.") Else MsgBox(64, "Coder Scrappy", "Not defteri şu an aktif değil!") EndIf Quote Link to comment Share on other sites More sharing options...
mustafavanli Posted July 26, 2015 Author Share Posted July 26, 2015 İf(WinActive("Adsız")) Then MsgBox(64, "Coder Scrappy", "Not defteri şu an aktif.") Else MsgBox(64, "Coder Scrappy", "Not defteri şu an aktif değil!") EndIf Bir kaç gün önce kodlarla tekrar ilgilenirken fark ettim ama konuya yazmamıştım. Konunun altında durması aynı sorunları yaşayacak arkadaşlar için iyi olabilir. Teşekkür ederim. 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.