Sign in to follow this  
Followers 0
Ryusenko

Script Help

11 posts in this topic

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.

Share this post


Link to post
Share on other sites



Use _WinAPI_SetWindowsHookEx() to detect the push and release of the extra mouse button.

When pushed send("lctrl down}") and when released send("lctrl up}").

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Add this line to the If loop

If _IsPressed(28, $dll) Then Send("{CTRLUP}")

And get rid of the last line in your script.

Edited by somdcomputerguy

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

Share this post


Link to post
Share on other sites

Also,

DllClose($dLL)

Wouldn't hurt either..

Share this post


Link to post
Share on other sites

Can i make it so that one key represents CTRL?

Share this post


Link to post
Share on other sites

Look at the example code for the _IsPressed function. Notice the use of two While loops, one within the other? More specifically, the While in the If?


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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

#11 ·  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.

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