AutoHotkey Community

It is currently May 27th, 2012, 12:50 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: January 19th, 2006, 11:14 am 
Offline

Joined: December 18th, 2005, 5:40 pm
Posts: 234
Location: Italy - Galatro(RC)
This program is usefull if you make some task, for many times, in few minutes, with fewest hotkeys :lol: ,but maybe usefull in many other contexts.
Description:
this script assign different action to the same hotkeys(definied in file hotkeys.kiu that should look like this
Code:
[hks]
hks=XButton1|XButton2
).
To change current mode(the actual actions definied for current hotkeys) you must press wheel up or down while holding down right mouse button.
The modes are definied in modes.kiu:
Code:
send   ^c|send   {LButton}{CTRL down}v{CTRL up}|
send   ^x|send   !c|
send   ^s|send   ^z|
send   {Enter}|Send   {BS}|
send   {LButton}{Tab}|send   msgbox
modifier   CTRL|modifier   ALT|
modifier   SHIFT|modifier   WIN|
run   E:\ahk_scripts\new\ahk2exe.exe|run   E:\ahk_scripts\new\my_functions.exe|
run   E:\programmi\Aveicon\AveIcon.exe|run   E:\programmi\XnView-win-full\XnView\xnview.exe|
run   E:\ahk_scripts\new\mouse_modes|run   E:\ahk_scripts\new\radialm_new\source3|
run   E:\ahk_scripts\new|run   e:\programmi|
changeword   %§%|changeword   {   §   }|
thiskey|thiskey|

as you can see each line as the following sintax:
commandforfirstHK[%A_Tab%option] | commandforsecondHK[%A_Tab%option] |commandforthirdHK[%A_Tab%option] |
etc.,as many as number of hotkeys.
for now are implemented only send,run and some other command,but you can define yours.
This is the script:

Code:
;Author: Salvatore Agostino Romeo(romeo84ATgmail)
currentMode:=0
mode_on=False
initializeModes()
#SingleInstance force
Return

;toggle modes on/off
^!Space::
if(mode_on="True")
  {
    mode_on=False
    Menu,tray,Icon , mm_images\off.ico,,1
    ToolTip,Modes deactivated
    SetTimer,stoptt,3000
    deactivateModes()
  }
Else
  {
    mode_on=True
    activateModes()
    ToolTip,Modes activated
    SetTimer,stoptt,3000
    Menu,tray,Icon , mm_images\on.ico,,1
  }
Return
;change mode with rbutton down + wheel
WheelUp::
  GetKeyState,state,RButton,P
  if(state ="D")
  prevMode()
  Else
      Send,{WheelUp}
Return

WheelDown::
  GetKeyState,state,RButton,P
  if(state ="D")
  nextMode()
  Else
      Send,{WheelDown}
Return
;exit app
^Esc::
  ExitApp
Return

activateModes()
  {
    global
    IniRead, hks, hokeys.kiu, hks, hks
    StringSplit, hk, hks, |
    Loop,%hk0%
      {
        current_hk:=hk%A_Index%
        Hotkey,%current_hk%,takeAction,on
      }
    Return
  }
deactivateModes()
  {
    global
    IniRead, hks, hokeys.kiu, hks, hks
    StringSplit, hk, hks, |
    Loop,%hk0%
      {
        current_hk:=hk%A_Index%
        Hotkey,%current_hk%,off
      }
    Return
  }
nextMode()
  {
    global
    ;if disabled,enable modes
    if(currentMode=0)
      gosub,^!Space
    currentMode++
    if(currentMode>maxMode)
    currentMode:=maxMode
    StringSplit, butt, mode%currentMode%, |
    modi=
    numberofloop:=butt0-1
    Loop,%numberofloop%
      modi:=modi "`n-" hk%A_Index% ": " butt%A_Index%
    ToolTip,Mode --> %currentMode%:%modi%
    SetTimer,stoptt,3000
    Return
  }
prevMode()
  {
    global
    currentMode--
    if(currentMode<0)
      currentMode:=0
    ;if selected mode0,disable modes
    if(currentMode=0)
      gosub,^!Space
    StringSplit, butt, mode%currentMode%, |
    modi=
    numberofloop:=butt0-1
    Loop,%numberofloop%
      modi:=modi "`n-" hk%A_Index% ": " butt%A_Index%
    ToolTip,Mode --> %currentMode%:%modi%
    SetTimer,stoptt,3000
    Return
  }
;read modes from modes.kiu
initializeModes()
  {
    global
    FileRead, mode, modes.kiu
    StringSplit, mode, mode, `n
    maxMode:=mode0
    mode=
    mode0=thiskey|thiskey|
    Return
  }

takeAction:
  ;I don't know how some variables are blank at this point,so I re-initialize them
  initializeModes()
  IniRead, hks, hokeys.kiu, hks, hks
  StringSplit, hk, hks, |
  StringSplit, hkac, mode%currentMode%, |
  Loop,%hk0%
    {
      StringSplit,butt%A_Index% , hkac%A_Index%, %A_Tab%
      if(A_ThisHotkey=hk%A_Index%)
      {
        option:=butt%A_Index%2
        Label:=butt%A_Index%1
        Gosub,%Label%
        Break
      }
    }
Return
;unshow tooltip
stoptt:
  SetTimer,stoptt,off
  ToolTip,
Return

;starting with possible commands definied for modes
msg:
  MsgBox,% option
Return

thiskey:
  Send,{%A_ThisHotkey%}
Return

send:
  send,%option%
Return

run:
  run,%option%
Return

modifier:
  Send,{%option% down}
  KeyWait, %A_ThisHotkey%
  Send,{%option% up}
Return

changeword:
  Send,{LButton 2}
  tempx=%Clipboard%
  Clipboard=
  Send,^x
  StringSplit, op, option, §
  Send,%op1%%Clipboard%%op2%
  Clipboard=%tempx%
Return

For the script to work you must place in the same folder:
this script,modes.kiu,hotkeys.kiu and eventually some icons like described in code.
Finally this is a complete pack,comprehensive of icons and exe too
http://autohotkey.net/file/users/Members/kiu/mouse%20modes%200.5.1.zip
Please tell me about,especially if you doesn't understand what this script can do.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2006, 11:18 am 
Offline

Joined: December 18th, 2005, 5:40 pm
Posts: 234
Location: Italy - Galatro(RC)
for exemple you can assign to numpad keys different task dynamically,or deactivate the script and use them normally in few seconds.These are corresponding files:

hotkeys.kiu
Code:
[hks]
hks=NumPad0|NumPad1|NumPad2|NumPad3|NumPad4|NumPad5|NumPad6|NumPad7|NumPad8|NumPad9


modes.kiu
Code:
send   ^c|send   {LButton}{CTRL down}v{CTRL up}|send   ^x|send   !c|send   ^s|send   ^z|send   {Enter}|Send   {BS}|send   {LButton}{Tab}|send   msgbox|
modifier   CTRL|modifier   ALT|modifier   SHIFT|modifier   WIN|run   E:\ahk_scripts\new\ahk2exe.exe|run   E:\ahk_scripts\new\my_functions.exe|run   E:\programmi\Aveicon\AveIcon.exe|run   E:\programmi\XnView-win-full\XnView\xnview.exe|run   E:\ahk_scripts\new\mouse_modes|run   E:\ahk_scripts\new\radialm_new\source3|run   E:\ahk_scripts\new|run   e:\programmi|


save the with correct name in the same folder of the script


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2006, 11:35 am 
Offline

Joined: December 18th, 2005, 5:40 pm
Posts: 234
Location: Italy - Galatro(RC)
the run options are some of my folders,change them with yours


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2006, 12:59 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Looks interesting. To make your job easier, v1.0.41 (to be released today or tomorrow hopefully) will support contex sensitive hotkeys using the following syntax:

#IfWinActive Untitled - Notepad
#a::MsgBox This hotkey will be enabled only when the above window is active.
#b::MsgBox The same.
#IfWinActive ; Turn off the criteria.

One of the drawbacks is that such hotkeys use the keyboard hook and thus require Windows NT/2k/XP or later.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2006, 8:18 pm 
Offline

Joined: November 23rd, 2004, 5:54 pm
Posts: 8
Very interesting.

Looking forward very much to that feature, Chris! Keep up the good work -- you rock.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2006, 9:48 pm 
Very good news. Thanks Chris.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: bowen666 and 18 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