Jump to content

Mouse commands


Recommended Posts

I am actually not writing anything for use. Just playing with some ideas at this point. Looks like i found a new hobby.

Ok here is my thought.

Without using the Au3info tool. Is it possible to get mouse positions x and y, just by clicking on the scree and then clicking a button?

here is an idea i am working on.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)

TEST()

Func TEST()
    Local $Button_1, $msg, $Test1, $Test2, $Test3, $Test4, $Test5, $Test6, $Test7, $Test8, $Test9, $Test10
    
    
    GUICreate("TEST", 160, 570, 5, 200) ; will create a dialog box that when displayed is centered
        
        GUICtrlCreateLabel("Test SETUP", 30, 5, 150)
                
                GUICtrlCreateLabel("(Test 1)", 10, 30, 150)
            $Test1 = GUICtrlCreateInput("", 10, 50, 100, 20)
                GUICtrlCreateLabel("(Test 2)", 10, 80, 100)
            $Test2 = GUICtrlCreateInput("", 10, 100, 100, 20)     ; 
                GUICtrlCreateLabel("(Test 3)", 10, 130, 100)
            $Test3 = GUICtrlCreateInput("", 10, 150, 100, 20)
                GUICtrlCreateLabel("(Test 4)", 10, 180, 100)
            $Test4 = GUICtrlCreateInput("", 10, 200, 100, 20)  
                GUICtrlCreateLabel("(Test 5)", 10, 230, 100)
            $Test5 = GUICtrlCreateInput("", 10, 250, 100, 20)
            
            $Button_1 = GUICtrlCreateButton("save", 25, 530, 100)

   
    GUISetState()      ; will display an  dialog box with 2 button
    
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                IniWrite("C:\Users\Main\Desktop\test.ini", "Test Positions", "Test#1 ", GUICtrlRead($Test1))    
                IniWrite("C:\Users\Main\Desktop\test.ini", "Test Positions", "Test#2 ", GUICtrlRead($Test2))
                IniWrite("C:\Users\Main\Desktop\test.ini", "Test Positions", "Test#3 ", GUICtrlRead($Test3))    
                IniWrite("C:\Users\Main\Desktop\test.ini", "Test Positions", "Test#4 ", GUICtrlRead($Test4))
                IniWrite("C:\Users\Main\Desktop\test.ini", "Test Positions", "Test#5 ", GUICtrlRead($Test5))
                exit
     
           
        EndSelect
    WEnd
EndFunc   ;==>Example

As you can see from above, it asks for the person to enter 5 points on their screen. Using the info tool.

I'm trying to have it do something like this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)

TEST()

Func TEST()
    Local $Button_1, $msg, $Test1, $Test2, $Test3, $Test4, $Test5, $Test6, $Test7, $Test8, $Test9, $Test10, $mpos
    
    
    GUICreate("TEST", 160, 570, 5, 200) ; will create a dialog box that when displayed is centered
        
        GUICtrlCreateLabel("Test SETUP", 30, 5, 150)
                
                GUICtrlCreateLabel("(Test 1)", 10, 30, 150)
$mpos = $Mousegetpos()

$Test1 = GUICtrlCreateInput($mpos, 10, 50, 100, 20)
                GUICtrlCreateLabel("(Test 2)", 10, 80, 100)

$Button_1 = GUICtrlCreateButton("save", 25, 530, 100)

   
    GUISetState()      ; will display an  dialog box with 2 button
    
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                IniWrite("C:\Users\Main\Desktop\test.ini", "Test Positions", "Test#1 ", GUICtrlRead($Test1)) 
exit
     
           
        EndSelect
    WEnd
EndFunc   ;==>Example

ok the 1st code works great. but would be too many things for a user to do. Would be nicer if i could get #2 to work :( .

Any and all ideas will be tried and welcomed.

Thx

Cue

Link to comment
Share on other sites

#Include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)

TEST()

Func TEST()
    Local $Button_1, $msg, $Test1, $Test2, $Test3, $Test4, $Test5, $Test6, $Test7, $Test8, $Test9, $Test10
    
    
    GUICreate("TEST", 160, 570, 5, 200) ; will create a dialog box that when displayed is centered
        
        GUICtrlCreateLabel("Test SETUP", 30, 5, 150)
                
                            
            $Button_1 = GUICtrlCreateButton("save 2 ini", 25, 530, 100)

   
    GUISetState()      ; will display an  dialog box with 2 button
    
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                getpos()
                exit
     
           
        EndSelect
    WEnd
EndFunc   ;==>Example
 


Func GetPos()
local $pos
    While 1
        ToolTip("Click Somewhere Else now")
        Sleep(100)
        If _IsPressed("01") Then ExitLoop
    WEnd
    ToolTip("")
    $pos = MouseGetPos()
    iniwrite(C:\Users\Main\Desktop\test.ini", "Test Positions", "Test#1 ", GUICtrlRead($pos))
EndFunc

any idea what I am missing here? edit: keeps returning a value of 0

doesn't seem to want to write to the ini. And when the button is pressed it closes.

Also is there an easier way to do this:

Local $Button_1, $msg, $Test1, $Test2, $Test3, $Test4, $Test5, $Test6, $Test7, $Test8, $Test9, $Test10

perhaps something like

local $button1, $msg, $test1-$test10 ?? or is it not that simple.

Edited by cueclub
Link to comment
Share on other sites

I saw you checking out the thread I had so I looked at yours to see if I could help you. Used the info in my thread for yours =]. This will write the file to the C: drive with the coords for you but it isnt set up to loop so after you click it will close.

#Include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)

TEST()

Func TEST()
    Local $Button_1, $msg, $Test1, $Test2, $Test3, $Test4, $Test5, $Test6, $Test7, $Test8, $Test9, $Test10
    
    GUICreate("TEST", 160, 570, 5, 200) ; will create a dialog box that when displayed is centered
        GUICtrlCreateLabel("Test SETUP", 30, 5, 150)
        $Button_1 = GUICtrlCreateButton("save 2 ini", 25, 530, 100)
        GUISetState()      ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                getpos()
                exit
        EndSelect
    WEnd
EndFunc

Func GetPos()
local $pos, $x = 1
    While $x = 1 ; Loop until the mouse is clicked.
            if _IsPressed("01") then ; If left mouse is pushed.
                $pos = MouseGetPos() ; Record the position.
                $x = 0 ; Change x to end loop.
            EndIf
    WEnd
    iniwrite("C:\test.ini", "Test Positions", "Test#1 ", $pos[0] & " " & $pos[1])
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...