Messages - Onesimus Prime [ switch to compact view ]

Pages: prev1 [2] 3next
Post New Requests Here / Re: "PazzPort Helper"
« on: May 17, 2010, 03:52 AM »
I guess one "missing piece" from the description of my "solution" above is a fairly extensively configured instance of Executor, also portable.  I have lots of Alt+Win+___ hotkeys defined, plus I can always type the first few letters of something and rely on autocomplete.  So Alt+Win is one of the combos I'm trying to reclaim here...

A description of what the script does so far (which is not that much) might be helpful:
Ctrl+Esc = simulate holding down Alt+Win for 3 seconds; I can then hit just one alphanumeric key to use one of my hotkeys mentioned above
Alt+Esc = simulate holding Shift down for 3 seconds
Ctrl + Backspace - call the AltTabMenu, which can then be navigated using the arrow keys, Enter to accept, Esc to cancel
"t" 3x (3 times) = Tab
"a" 3x = Ctrl+Alt+A (shortcut key for Keepass' autofill feature)
"e" - 2x = Executor, 3x = Windows' Run dialogue, 4x = My Computer
"q" - 2x = launch Q-Dir via Executor, 3x = quit focused application (Alt+F4)
Esc - 3x = suspend this AHK script, 4x = reload this script, 5x = exit this script

Post New Requests Here / "PazzPort Helper"
« on: May 17, 2010, 02:27 AM »

So I recently bought a little gadget called an iPazzPort (among other aliases) and am getting another as a present for someone.  Basically, this thing is a tiny wireless QWERTY keyboard and touchpad (picture here, review here).  I'm generally enjoying it; wouldn't want to do extensive typing on it at all, though.  But--I'm finding out just how spoiled I usually am in terms of navigation on a laptop.  This thing doesn't have a scroll region on the touchpad, and it's missing several important (to me) keys: Function keys, Win key, Tab, Shift, Home, End, PgUp, PgDown, Prnt Scrn, etc.  You can see the keyboard layout in the above picture.  Yep, no Alt+F4, no Alt+Tab, no Win+E, no Ctrl+Shift+End, etc. - all the shortcut keys that I normally use so often.

Especially since I'll be "gifting" one of these shortly, I'm trying to figure out a way to fill the void as far as navigation goes.  I've been messing around with a combination of the portable mouse gestures program StrokeIt and an AutoHotkey script.  My goal is to have something as simple, yet functional, as possible.  Here's what I was thinking so far, but if anyone has better ideas I don't mind scrapping this.  This has a lot of re-mapping to remember, which can just get confusing.  I'm a newbie at AHK and the below took me an embarrassing number of hours, so if someone else wants to start from scratch, I wouldn't mind that either...

#SingleInstance force

; missing: Function keys, Win key, Tab, Shift, Home, End, PgUp, PgDown, Prnt Scrn,

; `::Tab
Ctrl & Backspace::AltTabMenu
~t::RapidHotkey("{TAB}",3, 0.2)
~a::RapidHotkey("!^a", 3, 0.2)
~e::RapidHotkey("#z""#r""#e",3, 0.2)
~Esc::RapidHotkey("SusScript""ReloadScript""exit", 3, 0.2, 1) ;Press Esc 5 times rapidly to exit this script

Ctrl & Esc::
send {LAlt down}
send {LWin down}
sleep 1500
send {LWin up}
send {LAlt up}

Alt & Esc::
send {Shift down}
sleep 3000
send {Shift up}

Suspend on
sleep 3000
Suspend off



; ------- HotKeyIt's "RapidHotkey" function --------

RapidHotkey(keystroke, times="", delay=0.15, IsLabel=0)
   Pattern := Morse(delay*1000)
   If (StrLen(Pattern) < 2 and Chr(Asc(times)) != "1")
   If (times = "" and InStr(keystroke, """"))
      Loop, Parse, keystroke,""   
         If (StrLen(Pattern) = A_Index+1)
            continue := A_Index, times := StrLen(Pattern)
   Else if (RegExMatch(times, "^\d+$") and InStr(keystroke, """"))
      Loop, Parse, keystroke,""
         If (StrLen(Pattern) = A_Index+times-1)
            times := StrLen(Pattern), continue := A_Index
   Else if InStr(times, """")
      Loop, Parse, times,""
         If (StrLen(Pattern) = A_LoopField)
            continue := A_Index, times := A_LoopField
   Else if (times = "")
      continue = 1, times = 1
   Else if (times = StrLen(Pattern))
      continue = 1
   If !continue
   Loop, Parse, keystroke,""
      If (continue = A_Index)
         keystr := A_LoopField
   Loop, Parse, IsLabel,""
      If (continue = A_Index)
         IsLabel := A_LoopField
   hotkey := RegExReplace(A_ThisHotkey, "[\*\~\$\#\+\!\^]")
   Loop % times
      backspace .= "{Backspace}"
   keywait = Ctrl|Alt|Shift|LWin|RWin
   Loop, Parse, keywait, |
      KeyWait, %A_LoopField%
   If ((!IsLabel or (IsLabel and IsLabel(keystr))) and InStr(A_ThisHotkey, "~") and !RegExMatch(A_ThisHotkey
   , "i)\^[^\!\d]|![^\d]|#|Control|Ctrl|LCtrl|RCtrl|Shift|RShift|LShift|RWin|LWin|Escape|BackSpace|F\d\d?|"
   . "Insert|Esc|Escape|BS|Delete|Home|End|PgDn|PgUp|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|AppsKey|"
   . "PrintScreen|CtrlDown|Pause|Break|Help|Sleep|Browser_Back|Browser_Forward|Browser_Refresh|Browser_Stop|"
   . "Browser_Search|Browser_Favorites|Browser_Home|Volume_Mute|Volume_Down|Volume_Up|MButton|RButton|LButton|"
   . "Media_Next|Media_Prev|Media_Stop|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2"))
      Send % backspace
   If (WinExist("AHK_class #32768") and hotkey = "RButton")
      WinClose, AHK_class #32768
   If !IsLabel
      Send % keystr
   else if IsLabel(keystr)
      Gosub, %keystr%
Morse(timeout = 400) { ;by Laszo -> (Modified to return: KeyWait %key%, T%tout%)
   static lastkey
   tout := timeout/1000
   key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
   Loop {
      t := A_TickCount
      KeyWait %key%, T%tout%
     Pattern .= A_TickCount-t > timeout
      Return Pattern
     KeyWait %key%,DT%tout%
      If (ErrorLevel)
         Return Pattern

So far my "strategy" has been to use not-likely-used key combinations (e.g. Ctrl+Esc), or multiple key presses with the RapidHotkey function.  But there are only so many unused key combinations, and I don't know that they might do something horrible in some programs.  And RapidHotkey uses backspace to clear the triggering text entry, which of course causes something else entirely in an Explorer or Internet Explorer window.  Plus it's hard to remember, potentially unreliable if the iPazzPort/my fingers are finicky, etc.  One of the other things I was doing is to send "down" messages for certain unavailable modifier keys, sleep for a few seconds to give me time for key combinations, then send the "up" messages.  Again, there are probably better, more efficient, more easily remembered ways of doing that? 

Help!    :)

Finished Programs / Re: ReplaceAbsolutePaths (RAP)
« on: March 17, 2010, 07:20 PM »
Sorry!  I had thought the Coding Snacks section was only for things requested by others.  Guess I shoulda asked before posting... :redface:

For future reference, what's the difference between posting in Coding Snacks or the "Other programs" section?

Finished Programs / ReplaceAbsolutePaths (RAP)
« on: March 15, 2010, 08:42 PM »
ReplaceAbsolutePaths (RAP) - a small app for the portable-software-lovers out there, to maybe make their lives just a little easier... 

From the (admittedly long) readme:
"I was testing a program for portability recently and discovered that, although it could be portable, the process required a fair amount of manual editing of text-based settings files, converting absolute paths to relative ones.  This is also the case in many program launchers such as Executor, SlickRun, or Launchy, as well as other software like MetaPath or QuickWayToFolders."
"Sometimes if a file is 'buried' in enough levels of folders and subfolders, it can get confusing how many '..\' to use."
"Basically, this program [RAP] has two general functions: calculating a relative path when given two absolute ones, and offering to replace any instances of an absolute path with the newly calculated relative one within a particular text-based settings file."

RAP should probably be considered still in beta...  The first attachment at the bottom of this post is version 0.8.9, complete with a Readme.  The second is an older 0.8.2 version, .exe only.  This program makes a .ini file in its own folder, hence it is also portable.

If you use the text-replace function,
1) Please first double-check what changes it will do to which file!
2) When doing its text-replace, RAP should make a backup of the original file with the added extension .rbak, so if something goes wrong, you can erase the changed one and rename the *.rbak file to its original filename (simply erase ".rbak").

Alright, hope this is helpful to y'all!

Heh - I'm making my own snax!  :lol:

You define which keypresses to send to which program in the .ini file (generated on first run).  You can copy & rename the .exe or script, have a matching-named .ini file (also automagically generated), and therefore run multiple unique instances at the same time.

There are 3 ways to set the countdown timer 'til when the above-mentioned keypresses are sent.  In order of precedence:
1) command-line parameter (I use this script through Executor); 2) user input via initial input box; 3) the 'ctimer' field in the .ini file.

*edit* I hope to have an actual icon for this, maybe by sometime next week...



; by Onesimus Prime
; 2010
; For now, right-click on the tray icon to exit...

; Countdown timer code (which is the majority of what's below) from
; Some .ini-related code from Skrommel's templates

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; gets current script name and 'ditches' the file extension so that each script instance can have its own .ini file...
stringGetPos, WhereExtension, CurrentScriptNm, ., R
stringLeft, CurrentScriptNm, CurrentScriptNm, WhereExtension
; Msgbox %CurrentScriptNm% ;error-checking

  ini=%ini%`n  `; 0 is false (no), 1 is true (yes).
  ini=%ini%`n  `; Even without a floating timer, you can mouse over the tray icon to get the current countdown.
  ini=%ini%`n  `; This sets the countdown timer (in minutes), unless it is over-ridden by launching the script with a numeric parameter or by entering a number into the program's initial input box.
  ini=%ini%`n  `; Therefore the order of precedence is 1) command-line parameter; 2) user input via initial input box; 3) the above 'ctimer' field in this .ini file.
  ini=%ini%`n  `; It is measured in minutes (and decimals are valid).
  ini=%ini%`ntargetprogram=ahk_class mp3DCWndClass
  ini=%ini%`n  `; This is the Title or Class of the window of the target program, the program that you wish to send the below keystrokes to.  
  ini=%ini%`n  `; By default, this line includes "ahk_class mp3DCWndClass", summoning a window with the class matching mp3DirectCut (mp3DC).
  ini=%ini%`n  `; Another option would be "ahk_class REAPERwnd", summoning a window with the class matching the REAPER recording program.
  ini=%ini%`n  `; The keystrokes here will be sent to the program listed above.  Your options, and the various formatting restrictions, are viewable at
  ini=%ini%`n  `; By default, this line simulates a press of the Spacebar(using {Space}),  which (by mp3DC's and Reaper's defaults) toggles "play" and "stop" (and thus can be used to stop recording!)
  ini=%ini%`n  `; You could also use r{Space} to send r, then Space, which should (hopefully) start recording in mp3DC;
  ini=%ini%`n  `; or {CTRLDOWN}r{CTRLUP} to send Ctrl+R, Reaper's default key combo to START recording.
  ini=%ini%`n  `; This determines whether to show a message box after sending the keypresses, or simply to exit quietly.
  ini=%ini%`n  `; 0 is false (no MsgBox), 1 is true (yes).

IniRead, floatingtimer, %CurrentScriptNm%.ini, Settings, floatingtimer

IniRead, ctimer, %CurrentScriptNm%.ini, Settings, ctimer

IniRead, targetprogram, %CurrentScriptNm%.ini, Settings, targetprogram
IniRead, keypresses, %CurrentScriptNm%.ini, Settings, keypresses
IniRead, endmsg, %CurrentScriptNm%.ini, Settings, endmsg

CoordMode, ToolTip, Screen
tt = %1%

if not tt
 InputBox, InputMin, Enter timer length, `nPlease enter below how many minutes the timer `nshould be set for. (Decimals are okay.) `nIf this is left blank`, the value set via the .ini file `n(currently %ctimer% minutes) will be used.,,,185
 if InputMin is number
    tt = %InputMin%

if not tt
   tt = %ctimer%
;tt = 120
time := Convert_Milliseconds(tt)
Sec := (tt * 60)

SetTimer, nMessage, %time%

SetTimer, nMessage, Off

WinActivate %targetprogram%
WinWaitActive %targetprogram%
send %keypresses%
sleep 1000
ifequal, endmsg, 1, MsgBox Your keypresses have been sent to the requested program.
;Gui, +MinimizeBox
;GUi, -sysmenu
;gui, +toolwindow
;Gui, Add, Button, w130, DONE - hit 'O' for OK
;Gui, Show, x1 y1, %CurrentScriptNm% %versionnumber%

;KeyWait, o, D
;Tooltip ,, 2, 980
;Gui Destroy


Convert_MilliSeconds(time,MS = 1000,M = 60)
   return MS*M*time

countdown(p_count="") {
   countdown_date+=%countdown_time%, s
   Loop {
      If (countdown_date >= 16010101010000){
        FormatTime, mmss, %countdown_date%, hh:mm:ss
      FormatTime, mmss, %countdown_date%, mm:ss
      ;msgbox %countdown_date%`n%hhmmss%
     ;//SB_SetText(mmss, 2)
      global floatingtimer
      ifequal, floatingtimer, 1, Tooltip, %mmss%, 2000,14
      Menu,Tray,Tip,Time Remaining: %mmss%
      Sleep, 1000
      countdown_date+=-1, s
      ;//IfLess, countdown_date, 16010101, break
      if (A_Index>countdown_time) {

Pages: prev1 [2] 3next
Go to full version