Jump to content

Recommended Posts

Posted

Hi. I want to make a script that changes an extra mouse button into Ctrl. If that isn't possible, I would like to have another key replace Ctrl. I want the script to have CTRLDOWN when the key is pressed down and CTRLUP when the key is released. I've been researching and am not sure if i should use a function or an if...then statement to make this work.

Posted

Sorry, the mouse button isn't working as i thought it would. Is it possible to make it so that I press a key to activate CTRLDOWN and release that key to activate CTRLUP?

Posted

One of my attempts for the script is this:

#RequireAdmin
#include <Misc.au3>
$dll = DllOpen("user32.dll")
While 1
Sleep ( 250 )
If _IsPressed(26, $dll) Then
  Send("{CTRLDOWN}")
EndIf
WEnd
Send("{CTRLUP}")
 
The script doesn't work as I intend because CTRL constantly stays down. And if i unlock it, then the script doesn't seem to work anymore.
  • Solution
Posted

Thank You. Finally got it. Script ended up being like this.

#RequireAdmin
#include <Misc.au3>
$dll = DllOpen("user32.dll")
While 1
Sleep ( 250 )
If _IsPressed(26, $dll) Then
  Send("{CTRLDOWN}")
  ; Wait until key is released.
  While _ISPressed(26, $dll)
Sleep(250)
  WEnd
  Send("{CTRLUP}")
 EndIf
 Sleep(250)
WEnd
 
DllClose($dLL)
Posted (edited)

Way to go man. Good luck with the rest of your project. You really should put in some way to exit out of that first loop though. The way you have it written, DLLClose will never be executed. It may not matter, especially if you want this script to just run forever, all the time, but good code should have a way of gracefully exiting. See the HotKeySet function..

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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
×
×
  • Create New...