@@ -761,7 +761,7 @@ def get_element_coords_centered(
761
761
height : Optional [int ] = None ,
762
762
matching : float = 0.9 ,
763
763
best : bool = True ,
764
- ):
764
+ ) -> Union [ Tuple [ int , int ], Tuple [ None , None ]] :
765
765
"""
766
766
Find an element defined by label on screen and returns its centered coordinates.
767
767
@@ -807,7 +807,7 @@ def browse(self, url, location=0):
807
807
# Mouse
808
808
#######
809
809
810
- def click_on (self , label ) :
810
+ def click_on (self , label : str ) -> None :
811
811
"""
812
812
Click on the element.
813
813
@@ -819,7 +819,7 @@ def click_on(self, label):
819
819
raise ValueError (f"Element not available. Cannot find { label } ." )
820
820
_mouse_click (self ._mouse_controller , x , y )
821
821
822
- def get_last_x (self ):
822
+ def get_last_x (self ) -> int :
823
823
"""
824
824
Get the last X position for the mouse.
825
825
@@ -828,7 +828,7 @@ def get_last_x(self):
828
828
"""
829
829
return self ._mouse_controller .position [0 ]
830
830
831
- def get_last_y (self ):
831
+ def get_last_y (self ) -> int :
832
832
"""
833
833
Get the last Y position for the mouse.
834
834
@@ -837,7 +837,7 @@ def get_last_y(self):
837
837
"""
838
838
return self ._mouse_controller .position [1 ]
839
839
840
- def mouse_move (self , x , y ) :
840
+ def mouse_move (self , x : int , y : int ) -> None :
841
841
"""
842
842
Move the mouse to the coordinate defined by x and y
843
843
@@ -849,7 +849,7 @@ def mouse_move(self, x, y):
849
849
self ._mouse_controller .position = (x , y )
850
850
self .sleep (config .DEFAULT_SLEEP_AFTER_ACTION )
851
851
852
- def click_at (self , x , y ) :
852
+ def click_at (self , x : int , y : int ) -> None :
853
853
"""
854
854
Click at the coordinate defined by x and y
855
855
@@ -862,12 +862,12 @@ def click_at(self, x, y):
862
862
@only_if_element
863
863
def click (
864
864
self ,
865
- wait_after = config .DEFAULT_SLEEP_AFTER_ACTION ,
865
+ wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ,
866
866
* ,
867
- clicks = 1 ,
868
- interval_between_clicks = 0 ,
869
- button = "left" ,
870
- ):
867
+ clicks : int = 1 ,
868
+ interval_between_clicks : int = 0 ,
869
+ button : str = "left" ,
870
+ ) -> None :
871
871
"""
872
872
Click on the last found element.
873
873
@@ -878,6 +878,7 @@ def click(
878
878
button (str, optional): One of 'left', 'right', 'middle'. Defaults to 'left'
879
879
"""
880
880
x , y = self .state .center ()
881
+
881
882
_mouse_click (
882
883
self ._mouse_controller , x , y , clicks , interval_between_clicks , button
883
884
)
@@ -886,14 +887,14 @@ def click(
886
887
@only_if_element
887
888
def click_relative (
888
889
self ,
889
- x ,
890
- y ,
891
- wait_after = config .DEFAULT_SLEEP_AFTER_ACTION ,
890
+ x : int ,
891
+ y : int ,
892
+ wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ,
892
893
* ,
893
- clicks = 1 ,
894
- interval_between_clicks = 0 ,
895
- button = "left" ,
896
- ):
894
+ clicks : int = 1 ,
895
+ interval_between_clicks : int = 0 ,
896
+ button : str = "left" ,
897
+ ) -> None :
897
898
"""
898
899
Click Relative on the last found element.
899
900
@@ -907,13 +908,14 @@ def click_relative(
907
908
"""
908
909
x = self .state .x () + x
909
910
y = self .state .y () + y
911
+
910
912
_mouse_click (
911
913
self ._mouse_controller , x , y , clicks , interval_between_clicks , button
912
914
)
913
915
self .sleep (wait_after )
914
916
915
917
@only_if_element
916
- def double_click (self , wait_after = config .DEFAULT_SLEEP_AFTER_ACTION ):
918
+ def double_click (self , wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ) -> None :
917
919
"""
918
920
Double Click on the last found element.
919
921
@@ -925,11 +927,11 @@ def double_click(self, wait_after=config.DEFAULT_SLEEP_AFTER_ACTION):
925
927
@only_if_element
926
928
def double_click_relative (
927
929
self ,
928
- x ,
929
- y ,
930
- interval_between_clicks = 0 ,
931
- wait_after = config .DEFAULT_SLEEP_AFTER_ACTION ,
932
- ):
930
+ x : int ,
931
+ y : int ,
932
+ interval_between_clicks : int = 0 ,
933
+ wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ,
934
+ ) -> None :
933
935
"""
934
936
Double Click Relative on the last found element.
935
937
@@ -949,7 +951,7 @@ def double_click_relative(
949
951
)
950
952
951
953
@only_if_element
952
- def triple_click (self , wait_after = config .DEFAULT_SLEEP_AFTER_ACTION ):
954
+ def triple_click (self , wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ) -> None :
953
955
"""
954
956
Triple Click on the last found element.
955
957
@@ -961,11 +963,11 @@ def triple_click(self, wait_after=config.DEFAULT_SLEEP_AFTER_ACTION):
961
963
@only_if_element
962
964
def triple_click_relative (
963
965
self ,
964
- x ,
965
- y ,
966
- interval_between_clicks = 0 ,
967
- wait_after = config .DEFAULT_SLEEP_AFTER_ACTION ,
968
- ):
966
+ x : int ,
967
+ y : int ,
968
+ interval_between_clicks : int = 0 ,
969
+ wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ,
970
+ ) -> None :
969
971
"""
970
972
Triple Click Relative on the last found element.
971
973
@@ -985,8 +987,11 @@ def triple_click_relative(
985
987
)
986
988
987
989
def mouse_down (
988
- self , wait_after = config .DEFAULT_SLEEP_AFTER_ACTION , * , button = "left"
989
- ):
990
+ self ,
991
+ wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ,
992
+ * ,
993
+ button : str = "left" ,
994
+ ) -> None :
990
995
"""
991
996
Holds down the requested mouse button.
992
997
@@ -998,7 +1003,12 @@ def mouse_down(
998
1003
self ._mouse_controller .press (mouse_button )
999
1004
self .sleep (wait_after )
1000
1005
1001
- def mouse_up (self , wait_after = config .DEFAULT_SLEEP_AFTER_ACTION , * , button = "left" ):
1006
+ def mouse_up (
1007
+ self ,
1008
+ wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ,
1009
+ * ,
1010
+ button : str = "left" ,
1011
+ ) -> None :
1002
1012
"""
1003
1013
Releases the requested mouse button.
1004
1014
@@ -1010,7 +1020,7 @@ def mouse_up(self, wait_after=config.DEFAULT_SLEEP_AFTER_ACTION, *, button="left
1010
1020
self ._mouse_controller .release (mouse_button )
1011
1021
self .sleep (wait_after )
1012
1022
1013
- def scroll_down (self , clicks ) :
1023
+ def scroll_down (self , clicks : int ) -> None :
1014
1024
"""
1015
1025
Scroll Down n clicks
1016
1026
@@ -1020,7 +1030,7 @@ def scroll_down(self, clicks):
1020
1030
self ._mouse_controller .scroll (0 , - 1 * clicks )
1021
1031
self .sleep (config .DEFAULT_SLEEP_AFTER_ACTION )
1022
1032
1023
- def scroll_up (self , clicks ) :
1033
+ def scroll_up (self , clicks : int ) -> None :
1024
1034
"""
1025
1035
Scroll Up n clicks
1026
1036
@@ -1031,15 +1041,15 @@ def scroll_up(self, clicks):
1031
1041
self .sleep (config .DEFAULT_SLEEP_AFTER_ACTION )
1032
1042
1033
1043
@only_if_element
1034
- def move (self ):
1044
+ def move (self ) -> None :
1035
1045
"""
1036
1046
Move to the center position of last found item.
1037
1047
"""
1038
1048
x , y = self .state .center ()
1039
1049
self ._mouse_controller .position = (x , y )
1040
1050
self .sleep (config .DEFAULT_SLEEP_AFTER_ACTION )
1041
1051
1042
- def move_relative (self , x , y ) :
1052
+ def move_relative (self , x : int , y : int ) -> None :
1043
1053
"""
1044
1054
Move the mouse relative to its current position.
1045
1055
@@ -1053,7 +1063,7 @@ def move_relative(self, x, y):
1053
1063
self ._mouse_controller .position = (x , y )
1054
1064
self .sleep (config .DEFAULT_SLEEP_AFTER_ACTION )
1055
1065
1056
- def move_random (self , range_x , range_y ) :
1066
+ def move_random (self , range_x : int , range_y : int ) -> None :
1057
1067
"""
1058
1068
Move randomly along the given x, y range.
1059
1069
@@ -1070,11 +1080,11 @@ def move_random(self, range_x, range_y):
1070
1080
@only_if_element
1071
1081
def right_click (
1072
1082
self ,
1073
- wait_after = config .DEFAULT_SLEEP_AFTER_ACTION ,
1083
+ wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ,
1074
1084
* ,
1075
- clicks = 1 ,
1076
- interval_between_clicks = 0 ,
1077
- ):
1085
+ clicks : int = 1 ,
1086
+ interval_between_clicks : int = 0 ,
1087
+ ) -> None :
1078
1088
"""
1079
1089
Right click on the last found element.
1080
1090
@@ -1094,7 +1104,7 @@ def right_click(
1094
1104
)
1095
1105
self .sleep (wait_after )
1096
1106
1097
- def right_click_at (self , x , y ) :
1107
+ def right_click_at (self , x : int , y : int ) -> None :
1098
1108
"""
1099
1109
Right click at the coordinate defined by x and y
1100
1110
@@ -1107,11 +1117,11 @@ def right_click_at(self, x, y):
1107
1117
@only_if_element
1108
1118
def right_click_relative (
1109
1119
self ,
1110
- x ,
1111
- y ,
1112
- interval_between_clicks = 0 ,
1113
- wait_after = config .DEFAULT_SLEEP_AFTER_ACTION ,
1114
- ):
1120
+ x : int ,
1121
+ y : int ,
1122
+ interval_between_clicks : int = 0 ,
1123
+ wait_after : int = config .DEFAULT_SLEEP_AFTER_ACTION ,
1124
+ ) -> None :
1115
1125
"""
1116
1126
Right Click Relative on the last found element.
1117
1127
0 commit comments