Jump to content

change mousemove x,y from input box


Recommended Posts

I have been learning alot about autoit on my own.I love the amount of resources available. What i am trying to do is set variables for the X, Y of mousemove that a user can change/update from a input box. My problem is i cannot get it to use the variables i set. I am not sure if i can update the variables then save it to a .txt or .ini if that would work. I am wondering if anyone would be able to help me with this.

 

This is my test script before i implement it into my main script i am working on.  It always is takign my to the points 0, 0 on my screen. I have researched and tried different methods but i cannot figure this out.

Essentially i am trying to make it so the end user can change the x,y variables on there own using a settings GUI and have what they input as the coords to save and be able to use.

my script at the moment is:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### 

$Form2 = GUICreate("Form2", 405, 294, 570, 351)
$Input1 = GUICtrlCreateInput("964", 128, 72, 121, 21)
$Input2 = GUICtrlCreateInput("624", 128, 128, 121, 21)
$Label1 = GUICtrlCreateLabel("964", 88, 128, 36, 17)
$Label2 = GUICtrlCreateLabel("964", 88, 80, 36, 17)
$Button1 = GUICtrlCreateButton("Button1", 136, 176, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global Const $X  = $Input1 
Global Const $Y = $Input2 

HotKeySet("{`}", "test")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func test()

   MouseMove($X, $Y, 0) ;  create ticket
   MouseClick("left") ; 
   
   EndFunc   ;==>vFaxTransfer
Link to comment
Share on other sites

Try this.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###

$Form2 = GUICreate("Form2", 405, 294, 570, 351)
$Input1 = GUICtrlCreateInput("964", 128, 72, 121, 21)
$Input2 = GUICtrlCreateInput("624", 128, 128, 121, 21)
$Label1 = GUICtrlCreateLabel("624", 88, 128, 36, 17)
$Label2 = GUICtrlCreateLabel("964", 88, 80, 36, 17)
$Button1 = GUICtrlCreateButton("Button1", 136, 176, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


HotKeySet("p", "test")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func test()
    Local $X = GUICtrlRead($Input1)
    Local $Y = GUICtrlRead($Input2)
    MouseMove($X, $Y, 0)
    MouseClick("left") ;
EndFunc   ;==>test

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

Of course, all you'd need to do is a FileWrite with the values in the $X and $Y variables before you leave the "test" function. Or if you're using an INI file, do a IniWrite instead.

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

i got the inifile write part figured out. and i am able to load it if i hit a button. How can i make it load the data from the .ini when run the program? seems to be one of my last peices to my giant puzzle here :)

You'd load it at start up the exact same way you'd load it with your button. Just use IniRead somewhere in your script before your message loop to read from it.

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

Thanks for all the help. Here is my finished test script for anyone needing help using variables for x,y and being able to save them for later. As well as load the values on startup :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $read_Y_host
Global $read_X_host

#Region ### START Koda GUI section ###
$Form2 = GUICreate("Form2", 405, 294, 570, 351)
$Input1 = GUICtrlCreateInput($read_X_host, 128, 72, 121, 21)
$Input2 = GUICtrlCreateInput($read_Y_host, 128, 128, 121, 21)
$Label1 = GUICtrlCreateLabel("Y", 88, 128, 36, 17)
$Label2 = GUICtrlCreateLabel("X", 88, 80, 36, 17)
$save = GUICtrlCreateButton("Button1", 136, 176, 75, 25)
GUICtrlSetData($Input2, IniRead("Config.jvf", "Data", "Host", ""))
GUICtrlSetData($Input1, IniRead("Config.jvf", "Data", "Port Host", ""))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

HotKeySet("p", "test")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $save
            save()
    EndSwitch
WEnd

Func test()
    Local $X = GUICtrlRead($Input1)
    Local $Y = GUICtrlRead($Input2)
    MouseMove($X, $Y, 0)
    MouseClick("left") ;
EndFunc   ;==>test

Func save()
    Local $ini_file, $workingdir
    ; save workingdir
    $workingdir = @WorkingDir
    ; save file dialog
    $ini_file = FileSaveDialog('Save', @ScriptDir, 'Ini (*.jvf)|All (*.*)', 10, 'Config.jvf', $Form2)
    ; check if return is valid
    If @error Or $ini_file == '' Then
        FileChangeDir($workingdir)
        Return SetError(1, 0, '')
    EndIf
    ; write to ini file
    IniWrite($ini_file, "Data", "Host", GUICtrlRead($input1))
    IniWrite($ini_file, "Data", "Port Host", GUICtrlRead($input2))
    ; restore workingdir
    FileChangeDir($workingdir)
EndFunc
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...