AutoHotkey Community

It is currently May 26th, 2012, 8:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: July 12th, 2009, 5:37 pm 
Offline

Joined: July 12th, 2009, 5:33 pm
Posts: 9
I'd like to use my windows key to run a program (FindAndRunRobot), but still use it in hotkey combinations. That is, if I press and release only the windows key, run FARR; but if I press Win+L, lock the computer.

Is that possible?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2009, 5:48 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Try this:
Code:
LWin::
   Input,v,L1 M
   If ErrorLevel=Max
      Send, #{%v%}
   else if ErrorLevel=NewInput
      MsgBox
Return
LWin Up::
   Input
Return

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2009, 11:52 pm 
Offline

Joined: July 12th, 2009, 5:33 pm
Posts: 9
That's perfect, thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2009, 11:57 pm 
Offline

Joined: July 12th, 2009, 5:33 pm
Posts: 9
Maybe I spoke too soon...
My other hotkey combos that use # no longer work..


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2009, 12:40 am 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
from the Helpfile:
    Code:
    You can use the following modifier symbols to define hotkeys:
    # Win (Windows logo key)
    ~ When the hotkey fires, its key's native function will not be blocked (hidden from the system). In both of the below examples, the user's click of the mouse button will be sent to the active window:

    ~RButton::MsgBox You clicked the right mouse button.
    ~RButton & C::MsgBox You pressed C while holding down the right mouse button.


so use the ~ infront of # at your hotkeys


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2009, 1:15 am 
Offline

Joined: July 12th, 2009, 5:33 pm
Posts: 9
I tried adding the ~, but no dice.

Here's my script, maybe there's something goofy throwing it off.

Code:
;Splash screen
Progress, b fs18 zh0, Script Loaded, , , Calibri
Sleep, 750
Progress, off

;Power settings
~#^1::Run, CMD.EXE /c "POWERCFG.EXE /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c",, Hide
~#^2::Run, CMD.EXE /c "POWERCFG.EXE /s 381b4222-f694-41f0-9685-ff5bb260df2e",, Hide
~#^3::Run, CMD.EXE /c "POWERCFG.EXE /s a1841308-3541-4fab-bc81-f71556f20b4a",, Hide

;Reload/Edit keys
!^r::Reload
!^e::Edit

;itunes controls
~#.::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{RIGHT}  ; > next
return

~#,::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{LEFT}  ; < previous
return

~#/::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, {SPACE}  ; play/pause toggle
return

;toggle ontop
~#t::
WinSet, AlwaysOnTop, Toggle, A
return

; minimize
~#F1::
WinMinimize, A
return

;maximize/restore
~#F2::
WinGetActiveStats, Title, W, H, X, Y
WinGet MX, MinMax, A
IfEqual, Title, Progman, Return
If MX   
   WinRestore, A
else if (W = MonitorRight and H = MonitorBottom/2 and X = 0 and Y = 0)
   WinMove, A,,, % MonitorBottom/2
Else   WinMaximize, A                           
return   

;Close
~#F3::
WinClose, A
return

;FARR
LWin::
   Input,v,L1 M
   If ErrorLevel=Max
      Send, #{%v%}
   else if ErrorLevel=NewInput
     Run, c:\program files\FindAndRunRobot\FindAndRunRobot.exe -show
Return
LWin Up::
   Input
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2009, 1:27 am 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
Lwin an # are the same button, so both need the ~

Code:
~LWin::
   Input,v,L1 M
   If ErrorLevel=Max
      Send, #{%v%}
   else if ErrorLevel=NewInput
     Run, c:\program files\FindAndRunRobot\FindAndRunRobot.exe -show
Return
~LWin Up::
   Input
Return


i dont know, if your code makes sense, but it seems to work with the ~ before LWin


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2009, 1:50 am 
Offline

Joined: July 12th, 2009, 5:33 pm
Posts: 9
That was it, thanks. I needed to use ~ in front of the LWins, and not the others. For some reason #F1 would still trigger FARR, but changing it to #1 works as intended. If anyone is interested, here is my script.
Code:
;#Include CoHelper.ahk
;Splash screen
Progress, b fs18 zh0, Script Loaded, , , Calibri
Sleep, 750
Progress, off

;Power settings
#^1::Run, CMD.EXE /c "POWERCFG.EXE /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c",, Hide
#^2::Run, CMD.EXE /c "POWERCFG.EXE /s 381b4222-f694-41f0-9685-ff5bb260df2e",, Hide
#^3::Run, CMD.EXE /c "POWERCFG.EXE /s a1841308-3541-4fab-bc81-f71556f20b4a",, Hide

;Reload/Edit keys
!^r::Reload
!^e::Edit

;itunes controls
#.::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{RIGHT}  ; > next
return

#,::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{LEFT}  ; < previous
return

#/::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, {SPACE}  ; play/pause toggle
return

;toggle ontop
#t::
WinSet, AlwaysOnTop, Toggle, A
return

; minimize
#1::
WinMinimize, A
return

;maximize/restore
#2::
WinGetActiveStats, Title, W, H, X, Y
WinGet MX, MinMax, A
IfEqual, Title, Progman, Return
If MX   
   WinRestore, A
else if (W = MonitorRight and H = MonitorBottom/2 and X = 0 and Y = 0)
   WinMove, A,,, % MonitorBottom/2
Else   WinMaximize, A                           
return   

;Close
#3::
WinClose, A
return

;FARR
~LWin::
   Input,v,L1 M
   If ErrorLevel=Max
      Send, #{%v%}
   else if ErrorLevel=NewInput
     Run, c:\program files\FindAndRunRobot\FindAndRunRobot.exe -show
Return
~LWin Up::
   Input
Return





Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2009, 12:57 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
dansherman wrote:
For some reason #F1 would still trigger FARR, but changing it to #1 works as intended.
Input is mostly intended for text entry, so it won't capture F1 by default. If you add {F1} to the list of end keys, pressing F1 will cause Input to complete and set ErrorLevel to EndKey:F1. If you have other non-text keys, string them together like: {F1}{F2}{F3}


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 14th, 2009, 6:46 pm 
I'm also having issues trying to get the WIN key to allow other Win+key shortcuts that are not specifically set in AK to continue to operate only without my win key operating, and normally as if I had not changed just the win key.

~LWIN UP:: feed me

This will "feed me", and the other keys, like Win E also continue to function. Great. BUT, I also need to DISABLE "feed me", IF the Win key is used as part of a later combination.

This is the result, showing what I have a problem with:

win press = no action
win E press = invokes "EDIT or EXPLORER"
E release = no action
win release = says "FEED me" [[unwanted action, since I chose Win E, and NOT just WIN.

One possibility would be to somehow exit the script if any win+key was pressed, thus bypassing the call to the win key. Any ideas on how, without adding code to any and every Win+key combination?

Is there a way to use a wildcard for the 2nd part of the key, and then exit? Like this:

~LWIN UP:: "feed me"
~LWIN ANYKEYvar:: EXIT script

Would that work, with the proper syntax?


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Retro Gamer, StepO, wolverineks, Yahoo [Bot] and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group