Jump to content

HotKeySet holds CTRL down


 Share

Recommended Posts

Hi All,

I'm trying to create a script that makes it able to just hit a combination like CTRL+G to login to Gmail.com and CTRL+F to login on Facebook.

The problem is that when I used one of those hotkeys it seems to hold down the CTRL button so everytime I hit the 'F' or 'G' it runs the function.

My script below:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
HotKeySet ( "^g", "google" )
HotKeySet ( "^l", "linkedin" )
HotKeySet ( "^f", "facebook" )
HotKeySet ( "^h", "hyves" )
While 1;loop forever
sleep(100)
WEnd
Func Google()
Send ("username")
Send ("{TAB}")
Send ("password")
Send ("{TAB}")
Send ("{SPACE}")
EndFunc
Func linkedin()
Send ("username")
Send ("{TAB}")
Send ("password")
Send ("{TAB}")
Send ("{SPACE}")
EndFunc
Func facebook()
Send ("username")
Send ("{TAB}")
Send ("password")
Send ("{TAB}")
Send ("{SPACE}")
EndFunc
Func hyves()
Send ("username")
Send ("{TAB}")
Send ("password")
Send ("{TAB}")
Send ("{SPACE}")
EndFunc
Exit

Why is that happening?

Link to comment
Share on other sites

http://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.3F

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Sorry, I read the topic but I really don't know how to use it with my script.

I included the function but I still have got the same issue...I'm not that experienced. :)

Can please tell me, or put in the right direction, where I went wrong:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include "Misc.au3"
HotKeySet ( "^g", "google" )
HotKeySet ( "^l", "linkedin" )
HotKeySet ( "^f", "facebook" )
HotKeySet ( "^h", "hyves" )
While 1
sleep(100)
WEnd
;Send the string $ss after the Shift Alt and Ctrl keys are released. Optionally give a warning after 1 sec if any of those keys still down.
;Requires misc.au3 to be included in the script for the _IsPressed function.
Func _SendEx($ss, $warn = "")
Local $iT = TimerInit()
While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
  If $warn <> "" And TimerDiff($iT) > 1000 Then
   MsgBox(262144, "Warning", $warn)
  EndIf
  Sleep(50)
WEnd
Send($ss)
EndFunc;==>_SendEx
Func google()
Send ("username")
Send ("{TAB}")
Send ("password")
Send ("{Enter}")
_SendEx("{LCTRL}");
EndFunc
Func linkedin()
Send ("username")
Send ("{TAB}")
Send ("password")
Send ("{Enter}")
_SendEx("{LCTRL}");
EndFunc
Func facebook()
Send ("username")
Send ("{TAB}")
Send ("password")
Send ("{Enter}")
_SendEx("{LCTRL}");
EndFunc
Func hyves()
Send ("username")
Send ("{TAB}")
Send ("password")
_SendEx("{LCTRL}");
EndFunc
Exit
Edited by UniPer
Link to comment
Share on other sites

Here's how you would include that function in your script:

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Misc.au3>
HotKeySet("^g", "google")
HotKeySet("^l", "linkedin")
HotKeySet("^f", "facebook")
HotKeySet("^h", "hyves")
While 1;loop forever
    Sleep(100)
WEnd
Func Google()
    _SendEx("username")
    _SendEx("{TAB}")
    _SendEx("password")
    _SendEx("{TAB}")
    _SendEx("{SPACE}")
EndFunc   ;==>Google
Func linkedin()
    _SendEx("username")
    _SendEx("{TAB}")
    _SendEx("password")
    _SendEx("{TAB}")
    _SendEx("{SPACE}")
EndFunc   ;==>linkedin
Func facebook()
    _SendEx("username")
    _SendEx("{TAB}")
    _SendEx("password")
    _SendEx("{TAB}")
    _SendEx("{SPACE}")
EndFunc   ;==>facebook
Func hyves()
    _SendEx("username")
    _SendEx("{TAB}")
    _SendEx("password")
    _SendEx("{TAB}")
    _SendEx("{SPACE}")
EndFunc   ;==>hyves
Exit
Func _SendEx($ss, $warn = "")
    Local $iT = TimerInit()

    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
        If $warn <> "" And TimerDiff($iT) > 1000 Then
            MsgBox(262144, "Warning", $warn)
        EndIf
        Sleep(50)
    WEnd
    Send($ss)
EndFunc;==>_SendEx

This will not send the key sequences until the CTRL key is released, so make sure you only hit the hotkey once, otherwise it will send it multiple times.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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

×
×
  • Create New...