Jump to content

Mouse Click position changes while recording the screen entry


Recommended Posts

Hi,

            I am trying to enter the bulk of data hundred of records through spread sheet into my entry screen by simply recording the first entry and then using this recording in autoit passing the fields from spread sheet in send method or by mouse clicking to populate field and hit save button. I am recording my first entry and then using loop to repeat same recording for all the records reading from spreadsheet. My Mouseclick is not working fine and after saving two or three records it start skipping some fields.

Any suggestions will be appreciated.

Thanks

Link to comment
Share on other sites

  • Moderators

haris08,

Welcome to the AutoIt forum. :)

And when you post your code please use Code tags - see here how to do it. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

#include <Excel.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409) ---

#region --- Internal functions Au3Recorder Start ---
Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '')
If $aResult[1] <> '00000409' Then
MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')')
EndIf

EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc

_AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---
Local $sFilePath1 = @ScriptDir & "\Test.xlsx" ;This file should already exist
Local $oExcel = _ExcelBookOpen($sFilePath1)

Local $var1, $var2, 3var3,$var4, $var5, $var6, $var7, $var8, $var9,$var10, $var11, $var12



For $x = 1 To 11
If $x = 1 Then
ContinueLoop ; Skip displaying the message box when $i is equal to 7.
EndIf
$vary = _ExcelReadCell($oExcel, $x, $y)


For $y = 1 To 12
If $y = 1 then
$var1 = $vary
ElseIf $y = 2 then
$var2 = $vary
ElseIf $y = 3 then
$var3 = $vary
ElseIf $y = 4 then
$var4 = $vary
ElseIf $y = 5 then
$var5 = $vary
ElseIf $y = 6 then
$var6 = $vary
ElseIf $y =7 then
$var7 = $vary
ElseIf $y = 8 then
$var8 = $vary
ElseIf $y = 9 then
$var9 = $vary
ElseIf $y = 10 then
$var10 = $vary
ElseIf $y = 11 then
$var11 = $vary
ElseIf $y = 12 then
$var12 = $vary
Endif
Next


_WinWaitActivate("Application1 (2.0.5.1) - DEV- TESTU","")
MouseClick("left",135,67,1)
MouseClick("left",155,127,1)
Send($var1)
MouseClick("left",155,178,1)
Send($var2)
MouseMove(176,196)
MouseDown("left")
MouseMove(121,196)
MouseUp("left")
Send($var3)
MouseMove(190,241)
MouseDown("left")
MouseMove(112,242)
MouseUp("left")
Send($var4)
MouseClick("left",51,372,1)
MouseClick("left",155,424,1)
Send($var5)
MouseClick("left",159,449,1)
Send($var6)
MouseClick("left",461,119,1)
Send($emptype)
MouseClick("left",464,145,1)
Send($var7)
MouseClick("left",777,122,1)
Send($var8)
MouseClick("left",409,200,1)
MouseClick("left",433,397,1)
Send($var9)
MouseClick("left",435,423,1)
Send($var10)
MouseClick("left",461,439,1)
MouseClick("left",434,514,1)
Send($var11)
MouseClick("left",877,373,1)
Send($var12)
MouseClick("left",899,385,1)
MouseClick("left",875,675,1)
_WinWaitActivate("Message","")
MouseClick("left",400,129,1)
_WinWaitActivate("Application1 (2.0.5.1) - DEV- TESTU","")
MouseClick("left",131,71,1)
#endregion --- Au3Recorder generated code End ---
Next
_ExcelBookClose($oExcel) ; And finally we close

Edited by Melba23
Added tags
Link to comment
Share on other sites

Use the _Excel UDF instead of mouseclicks and send, they're VERY unreliable.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

haris08,

I asked you above to use code tags and even pointed you to an explanatory post. Please use them in future when you post code. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

#include <Excel.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409) ---

#region --- Internal functions Au3Recorder Start ---
Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '')
If $aResult[1] <> '00000409' Then
MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')')
EndIf

EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc

_AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---
Local $sFilePath1 = @ScriptDir & "\Test.xlsx" ;This file should already exist
Local $oExcel = _ExcelBookOpen($sFilePath1)

Local $var1, $var2, 3var3,$var4, $var5, $var6, $var7, $var8, $var9,$var10, $var11, $var12



For $x = 1 To 11
If $x = 1 Then
ContinueLoop ; Skip displaying the message box when $i is equal to 7.
EndIf

For $y = 1 To 12
$vary = _ExcelReadCell($oExcel, $x, $y)
If $y = 1 then
$var1 = $vary
ElseIf $y = 2 then
$var2 = $vary
ElseIf $y = 3 then
$var3 = $vary
ElseIf $y = 4 then
$var4 = $vary
ElseIf $y = 5 then
$var5 = $vary
ElseIf $y = 6 then
$var6 = $vary
ElseIf $y =7 then
$var7 = $vary
ElseIf $y = 8 then
$var8 = $vary
ElseIf $y = 9 then
$var9 = $vary
ElseIf $y = 10 then
$var10 = $vary
ElseIf $y = 11 then
$var11 = $vary
ElseIf $y = 12 then
$var12 = $vary
Endif
Next


_WinWaitActivate("Application1 (2.0.5.1) - DEV- TESTU","")
MouseClick("left",135,67,1)
MouseClick("left",155,127,1)
Send($var1)
MouseClick("left",155,178,1)
Send($var2)
MouseMove(176,196)
MouseDown("left")
MouseMove(121,196)
MouseUp("left")
Send($var3)
MouseMove(190,241)
MouseDown("left")
MouseMove(112,242)
MouseUp("left")
Send($var4)
MouseClick("left",51,372,1)
MouseClick("left",155,424,1)
Send($var5)
MouseClick("left",159,449,1)
Send($var6)
MouseClick("left",461,119,1)
Send($emptype)
MouseClick("left",464,145,1)
Send($var7)
MouseClick("left",777,122,1)
Send($var8)
MouseClick("left",409,200,1)
MouseClick("left",433,397,1)
Send($var9)
MouseClick("left",435,423,1)
Send($var10)
MouseClick("left",461,439,1)
MouseClick("left",434,514,1)
Send($var11)
MouseClick("left",877,373,1)
Send($var12)
MouseClick("left",899,385,1)
MouseClick("left",875,675,1)
_WinWaitActivate("Message","")
MouseClick("left",400,129,1)
_WinWaitActivate("Application1 (2.0.5.1) - DEV- TESTU","")
MouseClick("left",131,71,1)
#endregion --- Au3Recorder generated code End ---
Next
_ExcelBookClose($oExcel) ; And finally we close

Link to comment
Share on other sites

can somebody suggest how can i use controlclick in my scenario instead of mouseclik and send ?

Use the Excel UDF and DON'T use send or mouseclicks of any sort. Or better yet, use water's rewrite of it to do what ever it is you're doing in excel.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...