AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

why CTRL key always pressed after running my hotkey script?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Chunghualee



Joined: 16 Oct 2008
Posts: 2

PostPosted: Thu Oct 16, 2008 3:13 am    Post subject: why CTRL key always pressed after running my hotkey script? Reply with quote

I have a script to help my work on OrCAD. Sometimes after I fired a hotkey (ex. F5), windows XP seemed CTRL key is always pressed. I must reboot to get ride of it.

Code:

#SingleInstance force
SetTitleMatchMode, 2
I_Icon = C:\Documents and Settings\chrisl\My Documents\icon\orcad.ico

; Change tray icon (if one was specified in the configuration section above):
If I_Icon <>
    IfExist, %I_Icon%
        Menu, Tray, Icon, %I_Icon%

#ifwinactive, Orcad Capture

   ; change connector to input type
F5::
PlaceOffPageConnector(0)
return

   ; change connector to output type
F6::
PlaceOffPageConnector(1)
return

   ; change connector to bidir type
F8::
PlaceOffPageConnector(2)
return

   ; change connector to input type
+F5::
PlaceOffPageConnector(0,2)
return

   ; change connector to output type
+F6::
PlaceOffPageConnector(1,2)
return

   ; change connector to bidir type
+F8::
PlaceOffPageConnector(2,2)
return
   ; change connector to input type
^F5::
PlacePortConnector(0)
return

   ; change connector to output type
^F6::
PlacePortConnector(1)
return

   ; change connector to bidir type
^F8::
PlacePortConnector(2)
return

   ; change connector to input type
^+F5::
PlacePortConnector(0,2)
return

   ; change connector to output type
^+F6::
PlacePortConnector(1,2)
return

   ; change connector to bidir type
^+F8::
PlacePortConnector(2,2)
return

   ; repeat work
F7::
SendInput {Enter}
SendInput {Home}
SendInput {Del}
SendInput {Del}
SendInput CARD
SendInput {Enter}
return


; type = 0 for input, 1 for output, 2 for BIDIR
PlaceOffPageConnector(type, rot=4)
{
  BlockInput On
   name := type==0 ? "OFFPAGELEFT-IN" : type==1 ? "OFFPAGERIGHT-OUT" : "OFFPAGE-BIDIR"
   mv := type==0 ? -40 : 40

   MouseGetPos, mx, my
   SendInput {Enter}
   SendInput ^c
   SendInput {Esc}
   SendInput {Del}
   SendInput !p
   SendInput f
   SendInput %name%
   SendInput {Enter}
   Click, %mx%, %my%
   SendInput {Esc}
   MouseClick, , mv, 0, , , ,R
   SendInput {Enter}
   SendInput ^v
   SendInput {Enter}
   mv := type==0 ? -40 : 45
   MouseClick, , -mv, 0, , , ,R
    loop, %rot%
    {
    SendInput r
    }
    SendInput ^x
    SendInput ^v
  BlockInput Off
   return
}

; type = 0 for input, 1 for output, 2 for BIDIR
PlacePortConnector(type, rot=4)
{
  BlockInput On
   name := type==0 ? "PORTRIGHT-R" : type==1 ? "PORTLEFT-R" : "PORTBOTH-L"
   mv := type==2 ? 50 : -50

   MouseGetPos, mx, my
   SendInput {Enter}
   SendInput ^c
   SendInput {Esc}
   SendInput {Del}
   SendInput !p
   SendInput i
   SendInput %name%
   SendInput {Enter}
   Click, %mx%, %my%
   SendInput {Esc}
   loop, 4
   {
   SendInput r
   }
   SendInput {Esc}
   MouseClick, , mv, 0, , , ,R
   SendInput {Enter}
   SendInput ^v
   SendInput {Enter}
   mv := type==0 ? -30 : 35
   MouseClick, , -mv, 0, , , ,R
   loop, %rot%
   {
   SendInput r
   }
   SendInput ^x
   SendInput ^v
  BlockInput Off
   return
}

window(title)
{
  WinWait,%title%,,2
;  WinActivate,%title%
;  WinWaitActive,%title%,,2
  return
}

#ifwinactive
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Oct 16, 2008 6:57 am    Post subject: Reply with quote

code like: SendInput ^c
sometimes doesnt do {ctrl up}

instead, use:
Code:
sendinput {ctrl down}
sleep 10
sendinput c
sleep 10
sendinput {ctrl up}

this should fix
Back to top
Chunghualee



Joined: 16 Oct 2008
Posts: 2

PostPosted: Fri Oct 17, 2008 5:19 am    Post subject: Reply with quote

Thanks a lot, your method works after 2 days testing
Back to top
View user's profile Send private message
Carlol



Joined: 14 Aug 2006
Posts: 163
Location: CPH

PostPosted: Fri Oct 17, 2008 5:40 am    Post subject: Reply with quote

What exactly does it do?

See I have a similar problem with the ctrl key "hanging" and I was thinking that with a loop and a getkeystate, one could make Autohotkey watch, and if the key stays down more than a few seconds it would be released...

I just don't know how to go about it?

Rolling Eyes
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group