haris08 Posted March 13, 2014 Posted March 13, 2014 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
JohnOne Posted March 13, 2014 Posted March 13, 2014 Post code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Moderators Melba23 Posted March 13, 2014 Moderators Posted March 13, 2014 haris08,Welcome to the AutoIt forum. And when you post your code please use Code tags - see here how to do it. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
haris08 Posted March 13, 2014 Author Posted March 13, 2014 (edited) expandcollapse popup#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 March 13, 2014 by Melba23 Added tags
BrewManNH Posted March 13, 2014 Posted March 13, 2014 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 GudeHow 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
Moderators Melba23 Posted March 13, 2014 Moderators Posted March 13, 2014 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
JohnOne Posted March 13, 2014 Posted March 13, 2014 I imagine $vary = _ExcelReadCell($oExcel, $x, $y) needs to be in your loop. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
haris08 Posted March 13, 2014 Author Posted March 13, 2014 LOOP is working fine and it is already inside the second loop when reading cells of the spreadsheet.
haris08 Posted March 13, 2014 Author Posted March 13, 2014 that line is just printed above the loop but actually it is inside the second loopFor $y = 1 To 12$vary = _ExcelReadCell($oExcel, $x, $y)
JohnOne Posted March 13, 2014 Posted March 13, 2014 Okay, not easy to see with unformatted code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
haris08 Posted March 13, 2014 Author Posted March 13, 2014 can somebody suggest how can i use controlclick in my scenario instead of mouseclik and send ?
haris08 Posted March 13, 2014 Author Posted March 13, 2014 expandcollapse popup#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
BrewManNH Posted March 13, 2014 Posted March 13, 2014 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 GudeHow 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
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