mustilem23 Posted May 15, 2019 Share Posted May 15, 2019 Hello, I need your help because I am new at entering code. I added also gif file and my problem is how the code must be If there is green colour, it goes on with "For $i = 2 To 1000" loop or If there is no green light, it resumes from where it stayed. Complete of codes are like below; whether the green color will activate 168. It is the line 153 ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. 154 ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. 155 sleep(1000) 156 $satir=$satir+1 157 $oExcel.Sheets("Sayfa2").cells($satir, 9).value=ClipGet() 158 ClipPut("") 159 160 sleep(1000) 161 send("{TAB 3}") http://s2.dosya.tc/server9/4b9s3k/COLOR_NEXT.gif.html 1.73 MB expandcollapse popup#include <AutoItConstants.au3> Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc ; İLK VERİİLİ $oExcel = ObjCreate("Excel.Application") $oExcel.Workbooks.Open (@ScriptDir & "\teklif.xlsx").Sheets (1).Select () $oExcel.Visible = True ;Excel dosyası açıldıktan 10 sn sonra bilgi girişine başlanacaktır. Sleep(5000) Local $satir=0 ;5 kayıt için 5 daha fazlası için bu rakam arttırılabilir For $i = 1 To 10000 ;Açılan excel dosyasından 1,3,4 kolonlarından veriler okunuyor. Local $stok=$oExcel.Sheets("Sayfa1").cells($i, 1).value ;Okunan veri boş ise döngü bitiriliyor. if $stok="" then ExitLoop Opt('TrayIconDebug', 1) Opt("WinTitleMatchMode", 2) _WinWaitActivate("Müşteri - ","") Local $sText = WinGetTitle("[ACTIVE]") $sText=StringMid($sText,17,9) ;Açılan excel dosyasından 1,3,4 kolonları45015 4ndan veriler okunuyor. Local $stok=$oExcel.activesheet.cells($i, 1).value ;+ ya basılıyor send("{F3}") Sleep(1000) send($stok) Sleep(1000) send("{TAB 6}") ;1 sn bekleniyor Sleep(1000) send("{ENTER}") Sleep(2000) MouseClick($MOUSE_CLICK_LEFT,332 , 160, 1) sleep(1000) ;ilk veri kopyalanıyor ; CTRL SHIFT HOME İŞARETLİ ALANI SEÇER . Send("^+{HOME}") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(1000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 3).value=ClipGet() ClipPut("") ;MÜŞTERİ NO ALINIYOR sleep(1000) ;BURDAN AL MouseClick($MOUSE_CLICK_LEFT,642 , 164, 1) sleep(1000) ;2 veri kopyalanıyor ; CTRL SHIFT HOME İŞARETLİ ALANI SEÇER . Send("^+{HOME}") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(1000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 4).value=ClipGet() ClipPut("") ;MÜŞTERİ firma ismine bağlı ad alınıyor sleep(1000) MouseClick($MOUSE_CLICK_LEFT,455 , 285, 1) MouseClick($MOUSE_CLICK_LEFT,455 , 285, 2) ; CTRL SHIFT HOME İŞARETLİ ALANI SEÇER . Send("^+{HOME}") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(1000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 7).value=ClipGet() ClipPut("") sleep(2000) ;Müşteri açıklama sutunu alınıyor send("{TAB}") sleep(1000) Send("^+{LEFT 8 }") sleep(1000) Send("^+{RIGHT 8 }") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(1000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 8).value=ClipGet() ClipPut("") ;Müşteri açıklama iletişim metedu sleep(2000) ;2 veri kopyalanıyor send("{TAB 2}") sleep(1000) Send("^+{LEFT 8 }") sleep(1000) Send("^+{RIGHT 8 }") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(1000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 9).value=ClipGet() ClipPut("") sleep(1000) send("{TAB 3}") ;burdan sonra yeşil olur ise satır *************************************************************************************************************************** ;MÜŞTERİ firma ismine bağlı ad alınıyor 2 sleep(2000) Send("^+{LEFT 8 }") sleep(1000) Send("^+{RIGHT 8 }") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(2000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 3).value=ClipGet() ClipPut("") ;MÜŞTERİ NO ALINIYOR sleep(1000) send("{TAB 3}") Send("^+{LEFT 8 }") sleep(1000) Send("^+{RIGHT 8 }") Send("^C") ;2 veri kopyalanıyor MÜTERİ DEĞER SUTUNU ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(1000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 4).value=ClipGet() ClipPut("") ;MÜŞTERİ firma ismine bağlı ad alınıyor sleep(2000) send("{TAB 3 }") Send("^+{LEFT 8 }") sleep(1000) Send("^+{RIGHT 8 }") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(2000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 7).value=ClipGet() ClipPut("") sleep(2000) ;Müşteri açıklama sutunu alınıyor send("{TAB}") sleep(1000) Send("^+{LEFT 8 }") sleep(1000) Send("^+{RIGHT 8 }") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(2000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 8).value=ClipGet() ClipPut("") ;Müşteri açıklama iletişim metedu sleep(2000) ;2 veri kopyalanıyor send("{TAB 2}") sleep(1000) Send("^+{LEFT 8 }") sleep(1000) Send("^+{RIGHT 8 }") Send("^C") ;Hafızaya alınmış kopyalanan değer Sayfa2 deki satir ve sutuna yapıştırılır. ;Değerler excel de sağa doğru yapıştırılacak ise $satir, 1 deki değer 2,3,4 olarak değiştirilir. sleep(1000) $satir=$satir+1 $oExcel.Sheets("Sayfa2").cells($satir, 9).value=ClipGet() ClipPut("") sleep(1000) send("{TAB 3}") ;burdan sonra yeşil olur ise satır *************************************************************************************************************************** ;MÜŞTERİ firma ismine bağlı ad alınıyor 2 sleep(1000) ;$oExcel.Workbooks.close Next ;$oExcel.Workbooks.close Link to comment Share on other sites More sharing options...
Bert Posted May 15, 2019 Share Posted May 15, 2019 İlk durak. Asla ve demek istediğim, daha iyi yöntemler olduğunda ASLA piksel arama kullanmayın. Durumunuzda Excel ile çalıştığınız için - yardım dosyasına gidin ve Excel komutlarını arayın. Bunlardan LOTS var ve gönderdiğiniz tüm şeyleri kaldırabilirsiniz. İkincisi - eğer bir "gönder" yapmak zorundaysanız - "controllerend" kullanın. Gönder kullandığınızda ve pencere odağını kaybederse komut dosyası kesilir. Üçüncüsü - excel dışındaki diğer uygulamalarla mı çalışıyorsunuz? Örnek, Chrome veya Edge gibi bir web tarayıcısı olmak. 4. - Gördüğünüz gibi ana diliniz Türkçe. Yorumlarınızı kodunuzda okumak için google çeviri kullanıyorum. İngilizce'yi iyi bir şekilde konuşabiliyorsanız, sizin için uygunsa yapmayı tercih ederim. Size elimden geldiğince yardımcı olmaktan mutluyum. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted May 15, 2019 Share Posted May 15, 2019 I looked at the link and see you are trying to interact with a web page. What web browser are you using? There are AutoIt tools you can use to hook into the controls of the web page. Take a look at this:https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/ Turkish translation: BBağlantıya baktım ve bir web sayfasıyla etkileşime girmeye çalıştığınızı gördüm. Hangi web tarayıcıyı kullanıyorsunuz? Web sayfasının kontrollerine bağlanmak için kullanabileceğiniz AutoIt araçları vardır. Şuna bir bak:https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/ The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
mustilem23 Posted May 16, 2019 Author Share Posted May 16, 2019 Firstly, thanks Bert for your support. Yes my mother language is Turkish but we can speak in English. Did you check this file at link below ? http://s2.dosya.tc/server9/4b9s3k/COLOR_NEXT.gif.html My browser is chrome and I am using IFS to get data. The process is like that ; Autoit runs, excel opens, copies data first and pastes to a program called IFS, after that IFS opens and start coping data from IFS. But there is a limit of coping and it is 161st line. 160 sleep(1000) 161 send("{TAB 3}") After 161st line, autoit needs to decide. If there is green colour, autoit have to pass to 26st line. If there is no green colour, autoit have to continue from 161st line. Colour code : 0xC0E16E Link to comment Share on other sites More sharing options...
mustilem23 Posted May 16, 2019 Author Share Posted May 16, 2019 (edited) 35 minutes ago, mustilem23 said: Firstly, thanks Bert for your support. Yes my mother language is Turkish but we can speak in English. Did you check this file at link below ? http://s2.dosya.tc/server9/4b9s3k/COLOR_NEXT.gif.html My browser is chrome and I am using IFS to get data. The process is like that ; Autoit runs, excel opens, copies data first and pastes to a program called IFS, after that IFS opens and starts coping data from IFS. But there is a limit of coping and it is 161st line. 160 sleep(1000) 161 send("{TAB 3}") After 161st line, autoit needs to decide. If there is green colour, autoit has to pass to 26st line. If there is no green colour, autoit has to continue from 161st line.Colour code : 0xC0E16E Edited May 16, 2019 by mustilem23 Link to comment Share on other sites More sharing options...
Bert Posted May 16, 2019 Share Posted May 16, 2019 (edited) Sorry - for security reasons on my end I can't view the file. In any case, did you look at https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/ ? I ask for you have many send statements and the huge problem with using send is if the window loses focus, or the page that renders is slow, send fails. If you use the IUI automation, it won't matter if the window is minimized, or even hidden. The script, if written correctly, will still run and will allow you to do other stuff at the same time. Yes, you have to rewrite your script, however the upside is well worth it. Edited May 16, 2019 by Bert The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
mustilem23 Posted May 22, 2019 Author Share Posted May 22, 2019 Hello there , I can add .rar as you can check. COLOR NEXT 1.rar Link to comment Share on other sites More sharing options...
mustilem23 Posted May 23, 2019 Author Share Posted May 23, 2019 Dear Bert, This coding is very important to me. I have a few more data retrieval procedures. Please ask for help. 🙏 Link to comment Share on other sites More sharing options...
mustilem23 Posted May 27, 2019 Author Share Posted May 27, 2019 On 5/23/2019 at 5:59 PM, mustilem23 said: Dear Bert, This coding is very important to me. I have a few more data retrieval procedures. Please ask for help. 🙏 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now