Ethereal401 Posted June 28, 2013 Share Posted June 28, 2013 Ok, so what I want this script to do is to move the mouse down slightly along the y axis, and then after the loop is done redefine the mouse position, and move the mouse down again based on the new position. Instead what it does is move the mouse down based on the first time the mouse position variable was established. Doesn't the variable get redefined every time the loops exits and starts over again? What am I doing wrong? While 1 Do Dim $X = @DesktopWidth / 2 Dim $Y = @DesktopHeight / 2 Dim $X1 = $X - 50 ;-- start the scan area 50 pixels to the left of center coordinate. Dim $X2 = $X + 50 ;-- Stop the scan area 50 pixels to the right of center coordinate. Dim $Y1 = $Y - 50 ;-- Start the scan area 50 pixels above the center coordinate Dim $Y2 = $Y + 50 ;-- Stop the scan area 50 pixels below the center coordinate $pix = PixelSearch($X1, $Y1, $X2, $Y2, 0xFFFF2B, 30, 2) If IsArray($pix) = 1 Then Sleep(900) Send("e") Sleep(900) Send("r") Sleep(900) MouseClick("left") Sleep(300) $pos = MouseGetPos() local $ypos = $pos[1] + 1 Sleep(90) MouseMove ( $pos[0], $pos[1]+1,99 ) Sleep(90) $pos = MouseGetPos() EndIf ExitLoop Until False WEnd Link to comment Share on other sites More sharing options...
water Posted June 28, 2013 Share Posted June 28, 2013 (edited) A few notes: Don't use Dim to create variables. Use Global or Local. Dim is deprecated. Don't define variables in a loop, especially when the content doesn't change (e.g. Dim $X = @DesktopWidth / 2) Use [ autoit ][ /autoit ] tags to wrap your code. Enhances readability Why use MouseGetPos when you know where the mouse is after MouseMove? A last question. What do you try to achieve with this script? Edited June 28, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Ethereal401 Posted June 28, 2013 Author Share Posted June 28, 2013 A few notes: Don't use Dim to create variables. Use Global or Local. Dim is deprecated. Don't define variables in a loop, especially when the content doesn't change (e.g. Dim $X = @DesktopWidth / 2) Use [ autoit ][ /autoit ] tags to wrap your code. Enhances readability Why use MouseGetPos when you know where the mouse is after MouseMove? A last question. What do you try to achieve with this script? I use mousegetpos after mouse move because I would like to be able to move the mouse sometimes while the script in running. I wanted to define variables in a loop in the hopes that they would change when the loop resets. For some reason they're not changing when the loop resets. It's sloppy coding I know, but I just want this script to work. No one besides me and this forum will see the code. Link to comment Share on other sites More sharing options...
water Posted June 28, 2013 Share Posted June 28, 2013 Again: What do you search for? I don't get what you try to achieve. If you tell us we might show you an easier, more reliable way. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Ethereal401 Posted June 28, 2013 Author Share Posted June 28, 2013 Again: What do you search for? I don't get what you try to achieve. If you tell us we might show you an easier, more reliable way. I'm searching for the presence of a yellowish light on a screen in a first person videogame. If this color is present close to the middle of the screen then the script moves the mouse. The script is not done yet. I just want to clear this hurdle first before I make it do more complicated stuff. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 28, 2013 Moderators Share Posted June 28, 2013 Ethereal401, I'm searching for the presence of a yellowish light on a screen in a first person videogameA member for 4 years and you still have not read the Forum rules? Please read them now (there is also a link at bottom right of each page) - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. 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 Link to comment Share on other sites More sharing options...
Recommended Posts