Jump to content

Script Help


 Share

Go to solution Solved by Ryusenko,

Recommended Posts

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.

Link to comment
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.
Link to comment
Share on other sites

  • Solution

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)
Link to comment
Share on other sites

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.

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