HamidZaeri Posted June 5, 2018 Posted June 5, 2018 (edited) when I use ControlClick, My current active window lose its focus (Sometimes)! Is it natural or Is this a bug or something? And I know this workaround, but it repeatedly change focus of my windows (Annoying) $window = WinGetHandle("") ControlClick('iTools模拟器2','','CHWindow1','left',1,80,40) WinActivate($window) And i used these functions, but same problem! DllCall("user32.dll","int","SendMessage","hwnd",WinGetHandle($Window),"int",$WM_MOUSE,"int",0,"long",_MakeLong($X, $Y)) --- If it helps, I'm on latest Autoit version and win 10 x64 Edited June 5, 2018 by HamidZaeri
Bert Posted June 5, 2018 Posted June 5, 2018 are you doing something while the script is running? Like using your mouse? The Vollatran project My blog: http://www.vollysinterestingshit.com/
HamidZaeri Posted June 5, 2018 Author Posted June 5, 2018 On 6/5/2018 at 11:38 AM, Bert said: are you doing something while the script is running? Like using your mouse? Expand Of course, I'm working with another window. Do you want to say I should not use PC while autoit is running?
Moderators JLogan3o13 Posted June 5, 2018 Moderators Posted June 5, 2018 If you simply sit and let the script run, without doing anything else, does the active window still lose focus? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
HamidZaeri Posted June 5, 2018 Author Posted June 5, 2018 On 6/5/2018 at 12:45 PM, JLogan3o13 said: If you simply sit and let the script run, without doing anything else, does the active window still lose focus? Expand Yep Here is part of my codes: $hWin[$i] = WinGetHandle($winid[$en[0]+$i],'sub') $hCtr[$i] = ControlGetHandle($hWin[$i],'','CHWindow1') Switch PixWinColor(13,54,$hWin[$i]) Case 0x3281C6 ControlClick($hWin[$i],'',$hCtr[$i],'left',2,80,40) ControlSend($hWin[$i],'',$hCtr[$i],$apn[$cn[0]+Mod($i+$j,$cn[1])]) Sleep(20/$rate) ControlClick($hWin[$i],'',$hCtr[$i],'left',2,80,55) For $h = $cn[2] To $cn[2]+$cn[1] If StringLeft($apn[$cn[0]+Mod($i+$j,$cn[1])],6)=StringLeft($apn[$cn[0]+Mod($i+$j+$h,$cn[1])],6) And $apn[$cn[0]+Mod($i+$j,$cn[1])]<>$apn[$cn[0]+Mod($i+$j+$h,$cn[1])] Then ControlSend($hWin[$i],'',$hCtr[$i],$apn[$cn[0]+Mod($i+$j+$h,$cn[1])]) ExitLoop EndIf Next Sleep(20/$rate) ControlClick($hWin[$i],'',$hCtr[$i],'left',2,80,70) ControlSend($hWin[$i],'',$hCtr[$i],$fee[0]) Sleep(10/$rate) ControlClick($hWin[$i],'',$hCtr[$i],'left',1,7,191) And afaik it's not related to ControlSend (tested)
Moderators JLogan3o13 Posted June 5, 2018 Moderators Posted June 5, 2018 ControlClick doesn't steal focus either. How about posting all of your code, or at least a runnable reproducer, so we can test, along with an explanation of what you're trying to do? We can't do anything with this snippet. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
HamidZaeri Posted June 5, 2018 Author Posted June 5, 2018 (edited) On 6/5/2018 at 1:02 PM, JLogan3o13 said: ControlClick doesn't steal focus either. How about posting all of your code, or at least a runnable reproducer, so we can test, along with an explanation of what you're trying to do? We can't do anything with this snippet. Expand ControlClick is responsible for losing focus, Because when I remove them there's no problem! It is all the script (I have removed some sensitive stuff). Actually I use another script to ShellExecute This one . expandcollapse popup;If TimerDiff($time[$i]) < 200/$rate Then ContinueLoop Switch PixWinColor(13,54,$hWin[$i]) Case 0x3281C6 ;Cards For $h = 0 To 10 If PixWinColor(13,54,$hWin[$i])=0x2276BD Then ContinueCase If $err[$i][2] = 0 Then ExitLoop Sleep(15/$rate) Next ;$winid[0] = WinGetHandle('') If PixWinColor(73,107,$hWin[$i])=0xD4E4F3 Then ControlClick($hWin[$i],'',$hCtr[$i],'left',1,7,191) ;ControlClick($hWin[$i],'',$hCtr[$i],'left',2,80,40) ControlSend($hWin[$i],'',$hCtr[$i],$card[$cn[0]+Mod($i+$j,$cn[1])]) Sleep(20/$rate) ControlClick($hWin[$i],'',$hCtr[$i],'left',2,80,55) For $h = $cn[2] To $cn[2]+$cn[1] If StringLeft($card[$cn[0]+Mod($i+$j,$cn[1])],6)=StringLeft($card[$cn[0]+Mod($i+$j+$h,$cn[1])],6) And $card[$cn[0]+Mod($i+$j,$cn[1])]<>$card[$cn[0]+Mod($i+$j+$h,$cn[1])] Then ControlSend($hWin[$i],'',$hCtr[$i],$card[$cn[0]+Mod($i+$j+$h,$cn[1])]) ExitLoop EndIf Next If $i = $en[1] - 1 Then $cn[2] = Mod($cn[2],$cn[1]-1) + 1 Sleep(20/$rate) ControlClick($hWin[$i],'',$hCtr[$i],'left',2,80,70) ControlSend($hWin[$i],'',$hCtr[$i],$fee[0]) Sleep(10/$rate) If PixWinColor(145,170,$hWin[$i]) <> 0xFAFAFA Then ControlClick($hWin[$i],'',$hCtr[$i],'left',1,7,191) $fee[0] += 1 $err[$i][2] += 1 ResetErr(2) If $err[$i][2] > 2 And Mod(100*$rate,10) = 2 Then SwitchApp() ResetErr(-1) EndIf ElseIf TimerDiff($time[$i]) > 1500/$rate Then $time[$i]=TimerInit()+0*Run($avmdir&'tools\adb.exe -s '&$adbid[$en[0]+$i]&' shell am start -S -n '&$appid[$ap[0]+Mod($i+$j+$aps[$i],$ap[1])]&'/activities.SplashActivity --activity-clear-task','',@SW_HIDE) EndIf ;WinActivate($winid[0]) Edited June 12, 2018 by HamidZaeri
Juvigy Posted June 6, 2018 Posted June 6, 2018 The control that you are clicking is stealing the focus. Some controls do it because they perform some actions at the background. It is normal. HamidZaeri 1
HamidZaeri Posted June 6, 2018 Author Posted June 6, 2018 On 6/6/2018 at 7:24 AM, Juvigy said: The control that you are clicking is stealing the focus. Some controls do it because they perform some actions at the background. It is normal. Expand Ah, you're right. Any way to stop programs (controls) stealing focus?
Juvigy Posted June 6, 2018 Posted June 6, 2018 You can return the focus to the desired window with Autoit right after the control click. You can also try making the window minimized,invisible or the control enabled/disabled and so on. HamidZaeri 1
Bert Posted June 6, 2018 Posted June 6, 2018 You are running an uninstall routine if I'm reading the code right. Is it possible to use command line switches with the uninstaller? The Vollatran project My blog: http://www.vollysinterestingshit.com/
HamidZaeri Posted June 7, 2018 Author Posted June 7, 2018 On 6/6/2018 at 4:17 PM, Bert said: You are running an uninstall routine if I'm reading the code right. Is it possible to use command line switches with the uninstaller? Expand Thanks for your attention but no, it's not related to installation!
HamidZaeri Posted June 7, 2018 Author Posted June 7, 2018 (edited) On 6/6/2018 at 11:22 AM, Juvigy said: You can return the focus to the desired window with Autoit right after the control click. You can also try making the window minimized,invisible or the control enabled/disabled and so on. Expand ControlDisable did the trick Edited June 7, 2018 by HamidZaeri
HamidZaeri Posted July 16, 2018 Author Posted July 16, 2018 (edited) On 6/7/2018 at 5:35 PM, HamidZaeri said: ControlDisable did the trick Expand Stealing focus solved by disable control, but I have another problem: I lose mouse key hold after ControlClick, (I can't drag with mouse because mouse keys get released right after ControlClick) I know ControlClick is not responsible for that (Right?) but is there any workaround? Or what should I Google? Edited July 16, 2018 by HamidZaeri
Juvigy Posted July 16, 2018 Posted July 16, 2018 ControlClick is responsible for that - to workaround this - check for the mouse buttons hold before the control click and wait until there are no mouse buttons pressed.
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