Jump to content
Sign in to follow this  
UniPer

HotKeySet holds CTRL down

Recommended Posts

UniPer

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?

Share this post


Link to post
Share on other sites
BrewManNH

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

Share this post


Link to post
Share on other sites
UniPer

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

Share this post


Link to post
Share on other sites
BrewManNH

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

Share this post


Link to post
Share on other sites
UniPer

Really...really..thanks! :)

Great job...I see what you did..it makes me understand it a lot better now!

Thanks again..

Cheers,

UniPer

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  

  • Similar Content

    • Spartan117
      By Spartan117
      Hi everyone,
      I am wondering if is there any autoit function that make the program ignore errors and move on and resume correct lines?
      Thank you
    • guinness
      By guinness
      Right now the script will exit immediately if I don't pause it somehow (obvious of course).
      I was  curious on people's opinions of how they do it or what option they prefer below? Thanks
      Option 1 (I prefer)
      #include <MsgBoxConstants.au3> HotKeySet('^!p', SomeFunc) ProcessWaitClose(@AutoItPID) Func SomeFunc() MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10) EndFunc Option 2 (in the help file)
      #include <MsgBoxConstants.au3> HotKeySet('^!p', SomeFunc) While Sleep(100) WEnd Func SomeFunc() MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10) EndFunc Option 3
      #include <MsgBoxConstants.au3> HotKeySet('^!p', SomeFunc) While 1 GUIGetMsg() ; Use the internal sleep WEnd Func SomeFunc() MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10) EndFunc  
    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      I have a question please
      Can we customize error messages in autoit script?
      I mean internal error messages
      for example
      AutoIt Error
      Line 4  (File "D:\my projects\NVDA Manager\New AutoIt v3
      Script.au3"):
      $script[1] = 1
      $script^ ERROR
      Error: Subscript used on non-accessible variable.
      For example, I want to customize this message
      Is this possible?
      am waiting for your answers
    • AnonymousX
      By AnonymousX
      Hello,
      I'm trying to make a program that can look at a folder directory, find all the CSV files, and then add the data from CSV's to an array. 
      The problem I seem to be running into is on the 2nd iteration (2nd file) when the script will not create an array. Could someone please help? Thanks in advance
       
      #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> Global $MasterArray RefineData() Func RefineData() Local $i, $filenum, $file, $csvArray, $sFilePath = @ScriptDir $fileList = _FileListToArrayRec($sFilePath, "*.csv", 1) ;Create and array of all .csv files within folder ;=====Loop through the .csv files within the folder====== For $filenum = 1 To UBound($fileList) - 1 Step 1 $file = $fileList[$filenum] $sFilePath = $sFilePath & "\" & $file ;=====Create array based on csv file===== _FileReadToArray($sFilePath, $csvArray, $FRTA_NOCOUNT, ",") _ArrayDisplay($csvArray,"File: " & $filenum) If $filenum = 1 Then $MasterArray = $csvArray _ArrayDisplay($MasterArray, "Master") Else $MasterArray = _ArrayColInsert($MasterArray, UBound($MasterArray)) ;want column added at end For $i = 0 To UBound($MasterArray)-1 Step 1 $MasterArray[$i][UBound($MasterArray) - 1] = $csvArray[$i][4] Next _ArrayDisplay($MasterArray, "Master") EndIf Next EndFunc ;==>RefineData  
    • ur
      By ur
      In the autoit file, if we add multiple libraries (both internal and custom created one)
       
      When we compile the code and run the exe, some time we are getting runtime errors.
      But the line number of error is not showing the exact line number, might be it is including the line number count of libraries also.
      Can you please suggest how to get the exact error line number.
      So, it will be useful for debugging.
×