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

    • xiantez
      By xiantez
      This script used to work on an older version of AutoIT. Currently I am running AutoIT v3.3.14.5 and it's failing.
      Func PublicIP() ;Post public facing IP address Local $url = 'https://www.google.com/search?client=opera&q=what+is+my+ip&sourceid=opera&ie=UTF-8&oe=UTF-8' Local $getIPaddress = BinaryToString(InetRead($url)) Local $sStart = 'clamp:2">' Local $sEnd = '</div>' Local $ipaddress = _StringBetween($getIPaddress, $sStart, $sEnd For $i In $ipaddress MsgBox(0, 'External IP', "Your public IP address is " & $i) Next EndFunc ;==>PublicIP The console output shows:
      "C:\Users\user\Documents\AutoIT\Scripts\WSI Tools.au3" (197) : ==> Variable must be of type "Object".: For $i In $ipaddress For $i In $ipaddress^ ERROR ->14:12:16 AutoIt3.exe ended.rc:1 +>14:12:16 AutoIt3Wrapper Finished. >Exit code: 1 Time: 9.811
    • Xandy
      By Xandy
      I'm listing the error message strings, and roughly matching the error code
      Is this how to do error reporting?  Is there a more simple way I don't know about?
      I realise I might not need to trap @error inside $error.  I like it this way b/c I have no fear of overwriting @error now; I don't even use it.
      Func Send_Connect($address, $port)     $socket = TCPConnect($address, $port)     $error = @error     If $error <> 0 Then         Local $aError[4] = ["-2 not connected.", _                             "1 IPAddr is incorrect.", _                             "2 port is incorrect."]         $aError[3] = "10060 Connection timed out."         If $error < 0 Then $error = 0         If $error > 2 Then $error = 3         MsgBox(0, "TCP Connect Error", $aError[$error], 0)         $socket = 0     EndIf     Return $socket EndFunc
    • nacerbaaziz
      By nacerbaaziz
      Hello
      Dear Sirs, I have a question please
      About UPDown ctrl
      Where I want to adjust its format
      For example, I want to create a window to set the clock like the window in the system
      Can this be done?
      here's the example
      ______

      #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <UpDownConstants.au3> goto() func Goto() local $wGoto = GUICreate("go to spissific position", 250, 180, @DesktopWidth / 2 - 192, @DesktopHeight / 2 - 235, -1) GUICtrlCreateLabel("please write a corect position to go to it", 50, 10, 220, 20) GUICtrlCreateLabel("hours", 0, 80, 100, 30) local $Inp1 = GUICtrlCreateInput("00", 0, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp1, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 23, 0) GUICtrlCreateLabel("minuts", 110, 80, 100, 30) local $Inp2 = GUICtrlCreateInput("00", 110, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp2, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 60, 0) GUICtrlCreateLabel("seconds", 220, 80, 100, 30) local $Inp3 = GUICtrlCreateInput("00", 220, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp3, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 60, 0) local $Ok = GUICtrlCreateButton("&ok", 0, 150, 50, 30, 0x01) local $cancel = GUICtrlCreateButton("&cancel", 200, 150, 50, 30) GUISetState(@sw_show, $WgoTo) while 1 switch GUIGetMSG() case $GUI_Event_Close, $cancel exit case $OK local $read1 = GUICtrlRead($inp1) if $read1 >= 1 then $Read1 = ($Read1*60)*60 local $read2 = GUICtrlRead($inp2) if $read2 >= 1 then $Read2 = $Read2*60 local $read3 = GUICtrlRead($inp3) GUIDelete($WgoTo) Return $read1+$read2+$read3 exit endSwitch Wend EndFunc
      ________
      What I need is to be the contents of the inputs as follows when i change the value of the UPDown CTRL
      00
      01
      02
      03
      ...
       
    • 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  
×