lowrider2025 Posted January 2, 2009 Share Posted January 2, 2009 Hi everyone, I made a program that clicks on screen coordinates. I enter letters on buttons (the buttons correspond to coordinates on the screen). I enter a word.It finds the letters.Makes the right order of coordinates and then clicks all of the coordinates. But the problem is that it isn't fast enough. It takes 500 milliseconds at least for each click. MouseClick("left",StringLeft($arClicks[$k],4),StringRight($arClicks[$k],3),1) => This is the crucial line of code. The speed of mouseclick is at 1 so it doesn't go any faster than this. When I put it to 0 it doesn't work anymore. Can someone help me to speed things up. Thanks, Tim expandcollapse popup#include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #Include <GuiEdit.au3> #include <GuiButton.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $btn1, $btn2, $btn3, $btn4, $btn5, $btn6, $btn7, $btn8 Local $btnSend, $btnDefaults, $btnClick Local $lblWoord, $txtWoord, $pct1 Local $msg, $frmWordClicker Local $Val1, $Val2, $Val3, $Val4, $Val5, $Val6, $Val7, $Val8 Local $sWoord, $Tekst, $i, $j, $k, $Letter Local $arCoords[8], $arLetters[8] $arCoords[0] = "1180,374" $arCoords[1] = "1263,374" $arCoords[2] = "1345,374" $arCoords[3] = "1180,456" $arCoords[4] = "1345,456" $arCoords[5] = "1180,538" $arCoords[6] = "1263,538" $arCoords[7] = "1345,538" #Region ### START Koda GUI section ### Form= $frmWordClicker = GUICreate("Word Clicker", 225, 312, 204, 114) $btn1 = GUICtrlCreateButton("1", 8, 8, 65, 65, 0) GUICtrlSetFont(-1, 19, 400, 0, "MS Sans Serif") $btn2 = GUICtrlCreateButton("2", 80, 8, 65, 65, 0) GUICtrlSetFont(-1, 19, 400, 0, "MS Sans Serif") $btn3 = GUICtrlCreateButton("3", 152, 8, 65, 65, 0) GUICtrlSetFont(-1, 19, 400, 0, "MS Sans Serif") $btn4 = GUICtrlCreateButton("4", 8, 80, 65, 65, 0) GUICtrlSetFont(-1, 19, 400, 0, "MS Sans Serif") $btn5 = GUICtrlCreateButton("6", 152, 80, 65, 65, 0) GUICtrlSetFont(-1, 19, 400, 0, "MS Sans Serif") $btn6 = GUICtrlCreateButton("7", 8, 152, 65, 65, 0) GUICtrlSetFont(-1, 19, 400, 0, "MS Sans Serif") $btn7 = GUICtrlCreateButton("8", 80, 152, 65, 65, 0) GUICtrlSetFont(-1, 19, 400, 0, "MS Sans Serif") $btn8 = GUICtrlCreateButton("9", 152, 152, 65, 65, 0) GUICtrlSetFont(-1, 19, 400, 0, "MS Sans Serif") $pct1 = GUICtrlCreatePic("C:\Documents and Settings\xxx\Bureaublad\xxxx.jpg", 80, 80, 65, 65, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $lblWoord = GUICtrlCreateLabel("Woord:", 8, 232, 39, 17) $txtWoord = GUICtrlCreateInput("", 48, 229, 169, 25) $btnSend = GUICtrlCreateButton("send", 8, 272, 73, 33, 0) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $btnDefaults = GUICtrlCreateButton("reset", 100, 272, 73, 33, 0) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $btnClick = GUICtrlCreateButton("click", 180, 272, 45, 33, 0) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btnClick For $k = 0 to UBound($arClicks)-1 Step 1 MouseClick("left",StringLeft($arClicks[$k],4),StringRight($arClicks[$k],3),1) Next Case $msg = $btnSend $sWoord = _GUICtrlEdit_GetText($txtWoord) Global $arClicks[StringLen($sWoord)] For $i = 1 to StringLen($sWoord) Step 1 $Letter = StringMid($sWoord,$i,1) For $j = 0 to UBound($arLetters)-1 Step 1 If $Letter==StringLeft($arLetters[$j],1) Then $arClicks[$i-1]=StringLeft($arCoords[$j],4) & "," & StringRight($arCoords[$j],3) _ArrayDelete($arLetters,$j) _ArrayDelete($arCoords,$j) ExitLoop EndIf Next Next Case $msg = $btn1 $Val1 = InputBox("Geef waarde voor 1","Geef een letter in","","",100,50) _GUICtrlEdit_SetText($btn1, $Val1) $Val2 = InputBox("Geef waarde voor 1","Geef een letter in","","",100,50) _GUICtrlEdit_SetText($btn2, $Val2) $Val3 = InputBox("Geef waarde voor 1","Geef een letter in","","",100,50) _GUICtrlEdit_SetText($btn3, $Val3) $Val4 = InputBox("Geef waarde voor 1","Geef een letter in","","",100,50) _GUICtrlEdit_SetText($btn4, $Val4) $Val5 = InputBox("Geef waarde voor 1","Geef een letter in","","",100,50) _GUICtrlEdit_SetText($btn5, $Val5) $Val6 = InputBox("Geef waarde voor 1","Geef een letter in","","",100,50) _GUICtrlEdit_SetText($btn6, $Val6) $Val7 = InputBox("Geef waarde voor 1","Geef een letter in","","",100,50) _GUICtrlEdit_SetText($btn7, $Val7) $Val8 = InputBox("Geef waarde voor 1","Geef een letter in","","",100,50) _GUICtrlEdit_SetText($btn8, $Val8) $arLetters[0]=$Val1 $arLetters[1]=$Val2 $arLetters[2]=$Val3 $arLetters[3]=$Val4 $arLetters[4]=$Val5 $arLetters[5]=$Val6 $arLetters[6]=$Val7 $arLetters[7]=$Val8 ControlFocus("Word Clicker","",13) Case $msg = $btnDefaults _GUICtrlEdit_SetText($btn1, "1") _GUICtrlEdit_SetText($btn2, "2") _GUICtrlEdit_SetText($btn3, "3") _GUICtrlEdit_SetText($btn4, "4") _GUICtrlEdit_SetText($btn5, "6") _GUICtrlEdit_SetText($btn6, "7") _GUICtrlEdit_SetText($btn7, "8") _GUICtrlEdit_SetText($btn8, "9") _GUICtrlEdit_SetText($txtWoord,"") ControlFocus("Word Clicker","",13) EndSelect WEnd GUIDelete() Exit EndFunc ;==>_Main Link to comment Share on other sites More sharing options...
FireFox Posted January 2, 2009 Share Posted January 2, 2009 @lowRider2025 Maybe... Opt("MouseClickDelay",0) Opt("MouseClickDownDelay",0) Cheers, FireFox. Link to comment Share on other sites More sharing options...
Fend Posted January 2, 2009 Share Posted January 2, 2009 Might want to try ControlClick instead of MouseClick unless you need to see the cursor move. Those nested for loops might be causing some slow down. I like cookies? Link to comment Share on other sites More sharing options...
Danix Posted January 2, 2009 Share Posted January 2, 2009 (edited) MouseClick("left",StringLeft($arClicks[$k],4),StringRight($arClicks[$k],3),1,1) Last digit ( 1 ) is "speed" ( MouseClick("Left",x,y,clicks,speed) ) Edited January 2, 2009 by Danix Link to comment Share on other sites More sharing options...
FireFox Posted January 2, 2009 Share Posted January 2, 2009 @Danix Welcome to AutoIt forum Cheers, FireFox. Link to comment Share on other sites More sharing options...
lowrider2025 Posted January 2, 2009 Author Share Posted January 2, 2009 @Danix Welcome to AutoIt forum Cheers, FireFox. Thanks. And thanks everyone for the replies. But it doesn't seem to speed up all that much :s. Added these: Opt('MouseClickDelay',0) Opt('MouseClickDownDelay',0) Opt('MouseClickDragDelay',0) Link to comment Share on other sites More sharing options...
lowrider2025 Posted January 2, 2009 Author Share Posted January 2, 2009 Might want to try ControlClick instead of MouseClick unless you need to see the cursor move. Those nested for loops might be causing some slow down.I'm afraid ControlClick is not an option. I thought about it but then realised it only works for controls. The mouse is clicking on a flash-movie so not buttons from another program or something. But thanks for thinking with me. Link to comment Share on other sites More sharing options...
FireFox Posted January 2, 2009 Share Posted January 2, 2009 @lowrider2025 Use ControlClick and for get it of control use au3info (Program Files\AutoIt\au3info.exe) Cheers, Firefox. Link to comment Share on other sites More sharing options...
lowrider2025 Posted January 2, 2009 Author Share Posted January 2, 2009 @lowrider2025Use ControlClick and for get it of control use au3info (Program Files\AutoIt\au3info.exe)Cheers, Firefox.It's going faster now.I'm using mousemove,mousedown & mouseup. Link to comment Share on other sites More sharing options...
FireFox Posted January 2, 2009 Share Posted January 2, 2009 @lowrider2025 yep but its very long as controlclick because you use 3 functions Cheers, FireFox. Link to comment Share on other sites More sharing options...
lowrider2025 Posted January 2, 2009 Author Share Posted January 2, 2009 @lowrider2025yep but its very long as controlclick because you use 3 functions Cheers, FireFox.I know it doesn't seem very logical, but it still is faster and much faster really. Link to comment Share on other sites More sharing options...
Fend Posted January 2, 2009 Share Posted January 2, 2009 Glad to hear you got it to speed up! I like cookies? 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