Sign in to follow this  
Followers 0
ido12357

Script

16 posts in this topic

The script should convert rightclicks to rightclicks in their mirror position. E.g if I click on the top right corner, computer will react as if I clicked on the bottom left corner.

Apparently, this works around half of the times. It may also move to mirror position,back and rightclick in the original one.

Hope you can assist me!

#include <misc.au3>                         
HotKeySet("{esc}", "_exit")            
HotKeySet("{F4}", "_StartStop")             
Global $Switch = False                     
Global $dll = DllOpen("user32.dll")         
While Not $Switch                           
    Sleep(4000)                             
WEnd                                        
Func _exit()                              
    DllClose($dll)                           
    Exit                                    
EndFunc   
Func _StartStop()
    $Switch = Not $Switch                   
    consolewrite("Function = "&$Switch&@CRLF)   
    While 1                                 
        If Not $Switch Then ExitLoop            
        If _IsPressed("02", $dll) Then      
                                            
            Sleep(100)                      
            $pos = MouseGetPos()
            MouseClick("right", @DesktopWidth-$pos[0], @DesktopHeight-$pos[1], 1, 0)
            $pos = MouseGetPos()
            MouseMove(@DesktopWidth-$pos[0], @DesktopHeight-$pos[1], 0)
        EndIf
    WEnd
EndFunc
(monoscount999's mainly)

Share this post


Link to post
Share on other sites



Mmm, Your already done with reading Wiki for more helpful links to tutorials ... ok.

See if you can locate the part where it fails to do what you have in mind by taking a peek at whats going on in your code by injecting it with some debugging code to see if ... (Escher rules!)

Example: (disabled/remarked code == unchanged.)

;~ Func _StartStop()
    Local $result
;~  $Switch = Not $Switch
;~  ConsoleWrite("Function = " & $Switch & @CRLF)
;~  While 1
;~      If Not $Switch Then ExitLoop
;~      If _IsPressed("02", $dll) Then

;~          Sleep(100)
;~          $pos = MouseGetPos()
            $result = MouseClick("right", @DesktopWidth - $pos[0], @DesktopHeight - $pos[1], 1, 0)
            If Not $result Then
                ConsoleWrite('! MouseClick failed. $result = ' & $result @CRLF)
                ConsoleWrite('- $pos[0] = ' & $pos[0] @CRLF)
                ConsoleWrite('- $pos[1] = ' & $pos[1] @CRLF)
                Exit 911
            EndIf
;~          $pos = MouseGetPos()
;~          MouseMove(@DesktopWidth - $pos[0], @DesktopHeight - $pos[1], 0)
;~      EndIf
;~  WEnd
;~ EndFunc

Mmm, hope your not going to name all your help topics "Script". ... :)


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

this works around half of the times.

For me is working fine.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

For me is working fine.

$pos = MouseGetPos()
MouseClick("right", @DesktopWidth - $pos[0], @DesktopHeight - $pos[1], 1, 0)
$pos = MouseGetPos()
MouseMove(@DesktopWidth-$pos[0], @DesktopHeight-$pos[1], 0)

It apears that the move function does not wait for the click to end. Therefore it moves,clicks,move and then does another slight rightclick in the original position.

That is the source of the problem. In XP's desktop rightclick opens an option box which cancels the mirror position's option box (it also explains why it works for you well). Is there a way to fix that?

#include <misc.au3>                         
HotKeySet("{NUMPAD0}", "_exit")            
HotKeySet("{F2}", "_StartStop")             
Global $Switch = False                      
Global $dll = DllOpen("user32.dll")         
Opt("SendKeyDownDelay", 50)
While Not $Switch                           
    Sleep(4000)                             
WEnd                                        
Func _exit()                                
    DllClose($dll)                          
    Exit                                    
EndFunc   
Func _StartStop()
    $Switch = Not $Switch    
    consolewrite("Function = "&$Switch&@CRLF)   
    While 1                                 
        If Not $Switch Then
            Beep(500, 100)
            ExitLoop            
        EndIf
        send("{1}")
        If _IsPressed("02", $dll) Then                                                  
            Sleep(100)                      
            $pos = MouseGetPos()
            $result = MouseClick("right", @DesktopWidth - $pos[0], @DesktopHeight - $pos[1], 1, 0)
            If Not $result Then
                ConsoleWrite('! MouseClick failed. $result = ' & $result @CRLF)
                ConsoleWrite('- $pos[0] = ' & $pos[0] @CRLF)
                ConsoleWrite('- $pos[1] = ' & $pos[1] @CRLF)
                Exit 911
            EndIf
            $pos = MouseGetPos()
            MouseMove(@DesktopWidth-$pos[0], @DesktopHeight-$pos[1], 0)
        EndIf
    WEnd
EndFunc
Edited by ido12357

Share this post


Link to post
Share on other sites

put a little sleep(100) or less. Use your first script and place it after the mouseclick() function and before the mousemove()

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

#include <misc.au3>
HotKeySet("{NUMPAD0}", "_exit")
HotKeySet("{F2}", "_StartStop")
Global $Switch = False
Global $dll = DllOpen("user32.dll")
Opt("SendKeyDownDelay", 50)
While Not $Switch
    Sleep(4000)
WEnd
Func _exit()
    DllClose($dll)
    Exit
EndFunc
Func _StartStop()
    $Switch = Not $Switch
    consolewrite("Function = "&$Switch&@CRLF)
    While 1
        If Not $Switch Then
            Beep(500, 100)
            ExitLoop
        EndIf
        send("{1}")
        If _IsPressed("02", $dll) Then

            Sleep(100)
            $pos = MouseGetPos()
            MouseClick("right", @DesktopWidth - $pos[0], @DesktopHeight - $pos[1], 1, 0)
            Sleep(100)
            $pos = MouseGetPos()
            MouseMove(@DesktopWidth-$pos[0], @DesktopHeight-$pos[1], 0)
        EndIf
    WEnd
EndFunc

It didn't change a thing :)

The way I see it, the option left is that the MouseClick function is a lil inperfect. In high speeds (e.g 0) it may perform a slight click in the current position before the one requested.

EDIT: How did I miss it?! The script recieves a click in the if(_ispressed) and then sleeps(100).

I deleted both sleeps in the loop, the new and the old one that you added. Do you see any problems should be caused by this?

Edited by ido12357

Share this post


Link to post
Share on other sites

mmm maybe, do a mousemove() first, then mouseclick("right")(whitout the position parameters), then mousemove() to the original position.

Share this post


Link to post
Share on other sites

@edit

Share this post


Link to post
Share on other sites

@edit

and?????

Share this post


Link to post
Share on other sites

There was a change, yet it still does some sort of a click in the original position. Apart of that, removing the sleep caused that once a few clicks it completely ignores the script (does not even show the animation of moving). I start to think it is not possible with AutoIt.

Open for suggestions!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I onle once i be able to see the menu in the firs position when i click.

Anyway i do some changes, here you got, try it.

#include <misc.au3>
HotKeySet("{esc}", "_exit")
HotKeySet("{F4}", "_StartStop")
Global $Switch = False
Global $dll = DllOpen("user32.dll")
While Not $Switch
    Sleep(4000)
WEnd
Func _exit()
    DllClose($dll)
    Exit
EndFunc
Func _StartStop()
    $Switch = Not $Switch
    consolewrite("Function = "&$Switch&@CRLF)
    While 1
        If Not $Switch Then ExitLoop
        If _IsPressed("02", $dll) Then
;~             Sleep(100)
            $pos = MouseGetPos()
            Mousemove(@DesktopWidth-$pos[0], @DesktopHeight-$pos[1],0)
            sleep(50)
            MouseClick("right")
            MouseMove($pos[0], $pos[1], 0)
        EndIf
    WEnd
EndFunc

I start to think it is not possible with AutoIt.

Open for suggestions!

Possible is, but maybe can be more complicated. when i think that something is imposible to do it on autoit i start to look careful at my good friend Windows API List. Edited by monoscout999

Share this post


Link to post
Share on other sites

Possible is, but maybe can be more complicated. when i think that something is imposible to do it on autoit i start to look careful at my good friend Windows API List.

Can you explain me how to use the given list?

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Can you explain me how to use the given list?

Don`t think in the list for now. is just to show you a point, that sometimes the solution can be found digging into source. this is not the case, this can be done much easily(i guess) tell me if the script works.

(Sorry my bad english)

Edited by monoscout999

Share this post


Link to post
Share on other sites

Apparentely your script does not work. I used your idea of using sleeps to allow the computer can follow without mistakes. Everything does not to work.

No matter, thanks for all the help! Atleast I learned alot about AutoIt

Share this post


Link to post
Share on other sites

Apparentely your script does not work. I used your idea of using sleeps to allow the computer can follow without mistakes. Everything does not to work.

No matter, thanks for all the help! Atleast I learned alot about AutoIt

:) too bad, for me it works i only have ONE flash of the menu appearing in the first mouse position... good look and i hope i can help you in some other thing.

Share this post


Link to post
Share on other sites

The script should convert rightclicks to rightclicks in their mirror position.

Your script exampled works perfectly, based on the apparent intention of the code.

Whether there is a short ghost image of a menu in the original click position is a local issue. (system speed/specs, application, etc.)

For truly "converting" one mouse click to a other position ... you need to capture(intercept) the click in a other(earlier) way. (not my cup of tea however.)


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
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
Sign in to follow this  
Followers 0