Jump to content

super simple question (i'm a new user)


 Share

Recommended Posts

Hi there, I'd like to use Autoit for a simple thing:

When using Photoshop (and only on Photoshop, if that is able), whenever I press my left-control and the d at the same time, I would want that to be remapped to left-control and right-click.

I am sure this is easy, however I havent learned any knowledge in this field. Thank you if you would just show me how I can have it done.
 

Link to comment
Share on other sites

check out the functions...

HotKeySet()

this function can intercept the pressing of LCTRL+d and run commands.

WinActive()

inside the hotkeyset use if statements to check if Photoshop window is active.

Send()

if Photoshop window is active, Send LCTRL and...

MouseClick()

 

the sending of LCTRL+ right mouse click may be a little tricky, i have to tested so im not sure if this is the best method.

 

 

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

You'll probably want to send a left control down command, click with the mouse, and send a left control up command... like this

; Hold the left control down
Send("{LCTRL down}")
; Click with the Mouse
MouseClick("right")
; Release the left control
Send("{LCTRL up}")

It'll be better if there is a particular control that you can send these commands to with ControlSend instead of Send as it's much more reliable.

Edited by seadoggie01
Right click, left control, dyslexia at it again

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

;just an example may not be 100% accurate 
    Hotkeyset("{LCTRL}+d","remap")
    
    local $bool=false ;to toggle
    while 1
    Sleep(25)
    Wend
    
    func remap()
    
    if $bool=false then
    
    send("{LCTRLDOWN}")
    mouseclick("right")
    send("{LCTRLUP}")
    $bool=true
    return 
    
    elseif $bool=true then 
    $bool=false
    return 
    endif
    
    endfunc

Just to clarify you this sounds like youd need to use the hotkey function so that it triggers a different function to send the desired key press and click. 

;just an example may not be 100% accurate 
    Hotkeyset("{LCTRL}+d","remap")
    
    while 1
    Sleep(25)
    Wend
    
    func remap()
    send("{LCTRLDOWN}")
    mouseclick("right")
    send("{LCTRLUP}")
    endfunc

 

Edit!! Cleaned up...

Edited by markyrocks
Link to comment
Share on other sites

Link to comment
Share on other sites

31 minutes ago, Nine said:

@markyrocks Why do you do that ?  Why do you provide code that is totally wrong ?  I don't get your eager to help, but posting code that is so badly written.

What is wrong with what I wrote?

The hotkey function requires another function to operate.... 

If theres no while loop the script will just immediately exit.  This is stuff complete noobs don't know....

Edited by markyrocks
Link to comment
Share on other sites

  • Developers
9 hours ago, markyrocks said:

Edit!! Cleaned up...

Nearly there....You should also use Tidy  to make it more readable. ;) 
This is a shorter cleaned up version of your code:

;just an example may not be 100% accurate
HotKeySet("{LCTRL}+d", "remap")
Global $bool = False   ;to toggle

While 1
    Sleep(25)
WEnd

Func remap()
    If $bool = False Then
        Send("{LCTRLDOWN}")
        MouseClick("right")
        Send("{LCTRLUP}")
    EndIf
    $bool = Not $bool
EndFunc   ;==>remap

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...