What I do in my spare time... (show yours!)

Please choose one of the following:

  • Is Max a good candidate for Nerd OF The Month?

    Votes: 14 40.0%
  • Is Bryan's ceramics stuff just about the coolest shit I've seen lately?

    Votes: 3 8.6%
  • What's my name and where's my lunchbox?

    Votes: 11 31.4%
  • Piss off, I haven't got time for this rubbish!

    Votes: 7 20.0%

  • Total voters
    35
  • Poll closed .

maxd

Head of Complaints (PABs), Senior Forum Moderator
Staff member
Joined
Jan 20, 2004
Location
Saltirelandia
Bryan recently put up a really cool blog post (Link Outdated / Removed), here's a sneak peek:

tikihead1.jpg

Anyway, I got to thinking, might be a cool topic for general discussion. So, voila!, this is what I've been doing in my spare time lately:
Code:
; Stringbox.AHK:    use specific hotstrings to open a listbox of associated text strings,
;               choosing from the listbox will paste the selected string into the
;               user's workspace.
;
; - fwiw, default listbox behaviour is perfectly adequate for general use.
;
; things to do:
; - ??? load hotstrings and/or string sets from an ini file. ???
; - ??? allow user to edit hotstring sets. ???
; - offer a "temp" list, user can add/remove items.
; - try key-value arrays for larger/less readable texts (eg. sign-offs, etc).

#SingleInstance Ignore  ; won't start a new instance, the old instance rules.
#NoEnv
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#Include LBLib.ahk      ; low-level LB_*() functions to query and manipulate listboxes

Menu, Tray, NoStandard
Menu, Tray, Add , Pause, MyPause
Menu, Tray, Add , Suspend, MySuspend
Menu, Tray, Add , Reload, MyReload
Menu, Tray, Add , Exit, MyExit
Menu, Tray, Default, Pause
Menu, Tray, Click, 1	; single-click on the tray icon will trigger the default action
Menu, Tray, Icon , t:\bin\AutoHotkey\_scripts\stringboxico.dll, 2, 1	; green for Normal
Menu, Tray, Tip, Stringbox`nClick to Pause/unPause

CoordMode, Caret, Screen  ; use absolute screen coordinates for the caret, since Gui also uses screen coord.

;
;   globals and (faux) constants.
;

guiTitle := "Stringbox Items"
guiVarName := "MyLBox"
guiGosub := "MyLBoxGosub"

triggerText := ""

clipArray := []         ; a queue of recent Clipboard saves (see "OnClipboardChange:").
CONST_MAXCLIPS := 10    ; a faux constant to tell us the max number of clipboard items to remember.

firstPass := true   ; some things are run once when the script is loaded, in the case of certain events
                    ; this means the event handler is run at the beginning without the event actually having
                    ; happened.  this global tells us whether we've been through once before (since loading).

; MakeListbox: create, load and display a listbox.
; - we assume it is for temporary use, that it will be destroyed once
;   the user is finished with it (a selection has been made or the user
;   has cancelled out of it).
;
MakeListbox( arrayObj, sorted)
; arrayObj in assumed to be pre-loaded with strings that will be used to load a listbox
; sorted is a boolean: true = make it a sorted list, false = not sorted.
{
    global
    local lbNum := 0
    local lbPixelW := 0
    local longest := 0
    local sortLB := ""
    local xPos := 0
    local yPos := 0
    
    ; place the listbox/ToolTip near the caret (in the user's workspace)
    xPos := A_CaretX
    yPos := A_CaretY + 10   ; seems to look better if we nudge it down a little
    
    lbNum := arrayObj.MaxIndex()
    
    ; alert the user if there is nothing to put in a listbox.
    if (lbNum = 0)
    {
        ToolTip , "Nothing to choose from!", %xPos%, %yPos%
        Sleep , 2000
        ToolTip
        return
    }
    
    ; for the purposes of sizing the listbox, find the length of the longest item to be displayed.
    Loop , %lbNum%
    {
        loopFieldLen := StrLen( arrayObj[A_Index])
        longest := (loopFieldLen > longest) ? loopFieldLen : longest
    }
    
    ; calculate the list box width based on the StrLen of the longest element.
    ; 35 is (arbitrary) max chars to display,
    ; 8 is (assumed) number of pixels per character,
    ; so 35*8=280 is (arbitrary) max pixel width.
    lbPixelW := (longest < 35) ? (longest * 8) : 280
    
    sortLB := sorted ? "Sort" : ""

    ; have seen instances where we were trying to create a second listbox, don't.
    IfWinNotExist , %GUITitle%
    {
        Gui, Margin , 1, 1
        Gui -Caption +ToolWindow -Border
        Gui, Font, s8, Verdana      ; just hacking this in, makes the width calc'n more meaningful.
        Gui, Color,, FFFFAA         ; make it a contrasty colour so it stands out.
        Gui, Add, ListBox, r%lbNum% w%lbPixelW% v%guiVarName% g%guiGosub% %sortLB%
    }
    Gui, Show, AutoSize x%xPos% y%yPos%, %GUITitle%   ; x&y only work properly here if CoordMode for caret is Screen
    SetListboxFromArrayObj( arrayObj)
    LB_Set()    ; defaults to selecting the first item.
}

MyLBoxGosub:    ; see %guiGosub%
if A_GuiEvent = DoubleClick
{
    ShowAndDie()
}
return

ShowAndDie()
; Send the current list selection back to the user and kill the listbox
; - needs "global" iot access the listbox.
{
    global
    
    Gui, Submit
    Send , % %guiVarName%       ; "%" forces expression evaluation
    ; done with the listbox now.
    Gui, Destroy
}

; Esc to leave the listbox w/o selecting from it, in other words abort
;
GuiEscape:
    IfWinExist , %GUITitle%
        Gui, Destroy
    
    ; replace the text that triggered the listbox.
    ; (by default it is yoinked from the user's window when the hotstring fired)
    Send , %triggerText%
return

; ----------------------------------------------------------------
; ----------- hotstrings sets get defined here -------------------
; ----------------------------------------------------------------

:c*:bbb::   ;case sensitive, auto-trigger
    triggerText := "bbb"    ; would have used "www" here but that's too commonly used elsewhere
    localArray := []
    ;
    ; doing various work-related sign-off ("bye") strings
    ;
    localArray.Insert( 1, "Regards,{enter}Max."
        , "Regards,{enter}Max, Casinomeister.com"
        , "Regards,{enter}Max Drayman{enter}Casinomeister.com, Player Complaints Manager and Forum Moderator")
    
    MakeListbox( localArray, false)
return

:c*:ccc::   ;case sensitive, auto-trigger
    triggerText := "ccc"
    ;
    ; listbox the current current contents of clipArray, our queue of the last CONST_MAXCLIPS clipboard items.
    ;
    MakeListbox( clipArray, false)
return

:c*:ddd::   ;case sensitive, auto-trigger
    triggerText := "ddd"
    tStr := ""
    localArray := []
    nowDT := A_Now
    ;
    ; doing various useful date formats
    ;
    FormatTime, tStr, nowDT, yyyy-MMM-dd
    StringUpper, tStr, tStr
    localArray.Insert( tStr)
    
    FormatTime, tStr, nowDT, yyyy-MMM-dd-HH:mm
    StringUpper, tStr, tStr
    localArray.Insert( tStr)

    FormatTime, tStr, nowDT, yyyyMMdd
    localArray.Insert( tStr)

    FormatTime, tStr, nowDT, yyyyMMdd-HH:mm
    localArray.Insert( tStr)
    
    MakeListbox( localArray, false)
return

:c*:jjj::   ;case sensitive, auto-trigger
    triggerText := "jjj"
    localArray := []
    ;
    ; doing casino licence jurisdictions
    ;
    localArray.Insert( 1, "UK", "Panama", "Malta", "Kahnawake", "Isle of Man", "Gibraltar", "Cyprus", "Curaçao", "Costa Rica", "Belize", "Antigua-Barbuda", "Alderney")
    MakeListbox( localArray, true)
return

:c*:sss::   ;case sensitive, auto-trigger
    triggerText := "sss"
    localArray := []
    ;
    ; doing casino software providers
    ;
    localArray.Insert( 1, "Chartwell", "Boss Media", "Crypto", "OnGame", "NetEnt", "misc", "Proprietary", "Microgaming", "TopGame", "RTG", "Rival")
    MakeListbox( localArray, true)
return
    
:c*:vvv::   ;case sensitive, auto-trigger
    triggerText := "vvv"    ; would have used "www" here but that's too commonly used elsewhere
    localArray := []
    ;
    ; doing various work-related strings
    ;
    localArray.Insert( 1, "Casinomeister","Casinomeister.com","Pitch-A-Bitch","bryan@casinomeister.com","max.drayman@casinomeister.com")
    
    MakeListbox( localArray, false)
return

#IfWinExist, Stringbox Items        ; turns on context-sensitivity for the following hotkeys (and hotstrings)
                                    ; - have to provide the actual text here because %GUITitle% isn't processed.
                                    
; catch {Enter} as a selection key, show it and quit the listbox.
~Enter::
    ShowAndDie()
return

; Up and Down logic yoinked from SoLong&Thx4AllTheFish's post,
; "Endless scrolling in a listbox" ([url]http://www.autohotkey.com/forum/topic31618.html[/url])
;
Up::
    oldPos := LB_Get() + 1
    itemsInList := LB_GetCount()

    ControlSend, ListBox1, {Up}, %GUITitle%
    newPos := LB_Get() + 1
    If (newPos = oldPos)
        ; the Up didn't change our position => we're at the top, wrap-around
        LB_Set( LB_GetCount() - 1)
Return

Down::
    oldPos := LB_Get() + 1
    itemsInList := LB_GetCount()
    
    ControlSend, ListBox1, {Down}, %GUITitle%
    newPos := LB_Get() + 1
    If (newPos = oldPos)
        ; the Down didn't change our position => we're at the bottom, wrap-around
        LB_Set()  ; defaults to position 'one'
Return

#IfWinExist     ; turns off context-sensitivity for hotkeys and hotstrings

OnClipboardChange:
    ; docs say "The label also runs once when the script first starts", so looks like we need
    ; to know if this is the first time we've been here in order to avoid dropping something
    ; in the queue of saved clips that doesn't belong there.
    if firstPass
    {
        firstPass := false
        return
    }
    
    if (A_EventInfo = 1)
    {
        ; Clipboard has some text (presumably new),
        ; append it to our saved list (adds to the end of the "queue").
        clipArray.Insert( clipboard)
        
        ; limit the clipArray to a pre-specified number of items
        if (clipArray.MaxIndex() > CONST_MAXCLIPS)
            ; toss the oldest item in our saved clips "queue".
            clipArray.Remove( 1)
    }
return

!Pause::
MySuspend:
	Suspend , Toggle
	if (A_IsSuspended)
    {
		Menu, Tray, Icon , %A_IconFile%, 1, 1	; blue for Suspended
        Menu, Tray, Tip, Stringbox (Suspended)`nclick to Pause/unPause
    }
	Else
    {
		Menu, Tray, Icon , %A_IconFile%, 2, 1	; green for Normal
        Menu, Tray, Tip, Stringbox`nclick to Pause/unPause
    }
Return

; - some very strange stuff happens with the Pause key and/or when the script is Paused:
;   to make a long story short it seems that whatever key(s) are used to Pause the script
;   are not seen by a Paused script, iow you need to use something else to un-Pause. ???
;
; - ^Pause seems to cause "Process failed to respond; forcing abrupt termination...", sometimes. ???

MyPause:
	if (A_IsPaused)
        gosub , doPauseOff
    Else
        gosub , doPauseOn
Return

Pause::     ; ??? _sometimes_ it doesn't *@%£$%# work!  behaves as if it never happened.
doPauseOn:
    Menu, Tray, Icon , %A_IconFile%, 3, 1	; red for Paused
    Menu, Tray, Tip, Stringbox (Paused)`nclick to Pause/unPause
    Pause, On
return

+Pause::
doPauseOff:
    Pause, Off
    Menu, Tray, Icon , %A_IconFile%, 2, 1	; green for Normal
    Menu, Tray, Tip, Stringbox`nclick to Pause/unPause
return

MyReload:
	Reload
Return

F12::ListVars

^Escape::
MyExit:
    ExitApp	; Kill the script if it gets too Scary.
Return

Scary huh? My wife thinks I'm having some kind of mid-life crisis. :D
 
What app are you trying to make? :D

Pasted in to VB but don't think that's the language?

Great Idea for a thread BTW! :)

Cheers
Gremmy
 
Hey Gremmy, it works with a thing called AutoHotKey (
You do not have permission to view link Log in or register now.
). Basically it's a programmable shell that allows you to control, manipulate and augment the operating system hosting it, in my case Windows. The AutoHotKey blurb says:
AutoHotkey is a free, open-source utility for Windows. With it, you can:

* Automate almost anything by sending keystrokes and mouse clicks. You can write a mouse or keyboard macro by hand or use the macro recorder.
* Create hotkeys for keyboard, joystick, and mouse. Virtually any key, button, or combination can become a hotkey.
* Expand abbreviations as you type them. For example, typing "btw" can automatically produce "by the way".
* Create custom data-entry forms, user interfaces, and menu bars. See GUI for details.
* Remap keys and buttons on your keyboard, joystick, and mouse.
* Respond to signals from hand-held remote controls via the WinLIRC client script.
* Run existing AutoIt v2 scripts and enhance them with new capabilities.
* Convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed.

I've been using it for a few years now to do small things -- hotkeys, bitty system-level tasks -- and it's been a real boon. "Stringbox" is by far my most ambitious project so far. The basic idea being that it pops up things like this to help organize and speed up your text entry tasks:

stringbox-example.jpg

Here, for example, I type my hotstring "bbb" (which Stringbox eats) and up pops the listbox of strings (which I've pre-defined) useful in that context. I highlight the one I want, hit Enter (or double-click) and the selected string of text (which can be arbitrarily complex) is entered back into my text editing area, wherever that might be. Because AHK runs in the background and watches the keyboard it works anywhere: Word, Excel, here on the forums, basically anywhere you might be entering text. If for some reason you don't want it active in a particular program (or whatever) just click on the icon in the System Tray (or hit 'Pause') and it will toggle on/off.

The whole idea with Stringbox is that you define a different hotstring for each context in which you might find it useful -- sign-offs (like above), software providers, licencing jurisdictions, various pre-formatted strings of the current date/time, recent clipboard captures, etc -- and with just the hotstring you get your list of texts useful in that context. Using it now:

Regards,
Max.
 
:p :p :p

You should hear the sounds on my cell phone, all Star Trek (TOS), which I've been rewatching recently. :D I love it when an SMS arrives, the "communicator" chirp is music to my ears! :)
 
and for those of you not yet sufficiently confused, here's that info again but in Latin:

''Hic , vel , EGO typus meus hotstring bbb " ( quod Ligamen eats ) quod sursum pops album of ligamen ( quod I've pre - termino ) utilis in ut contineo contigi. EGO highlight unus Volo , ledo Penetro ( vel geminus click ) quod lego ligamen of text ( quod can exsisto ludicer universa ) est penetro tergum in meus text emendo area , qua ut vires exsisto. Quoniam AHK runs in background quod vigilo keyboard is officina usquam : Vox , Praecedo , hic in forums basically usquam vos vires exsisto ingressus text. Si pro nonnullus causa vos don't volo is strenuus in a proprius progressio ( vel quisquis ) iustus click in icon in Ratio Tray ( vel ledo 'Pause' ) quod is mos toggle in off.''

As for me, I fill my spare time with Zombie movies, Playstation and Poker. :)
 
:lolsign:

Yeah, okay, so not everyone's cup of tea. :D Gotta admit though, you want the Star Trek (TOS) sounds on your phone too, no? ;)
 
Where do we vote?

Top of the thread. The views expressed here are not representative of the views help by Casinomeister Inc, nor the staff or executives thereof. Casinomeister Inc is not responsible blah blah blah.
 
Well, Max... At least you didn't go out and buy a million$ Ferrari... ummm... I hope? I gave up any pathetic attempts at writing anything to do with programming when my Commodore 64 died. LOL

Gooooo, GeekMan... Go! :thumbsup:

Oh! and I forgot to show mine.... :oops: I mod and 'own' a few Yahoo groups... This weekend I made sig tags to offer to the girls in the request groups... I've made them smaller so they won't frighten anyone... LOL

resized 50%... copyright to all artwork belongs to original artists...
 
Can someone please tell me what "spare time" is? :confused:

KK
I think it has something to do with bowling I think.
spare_time--217120797549407281-product-210.jpg
 
Can someone please tell me what "spare time" is? :confused:

KK

It's usually some senseless fiddling around on the computer that USA players do when they don't/can't/won't play online anymore.....:)
 
This is what I used to do in my spare time (when I had some) This is one of my drawings (colored pencil) and a Photoshop poster thing starring an old BF. ;)

sultan.jpglizard.jpg
 
In my spare time I sleep :oops:. That's creative and stuff, yes? I mean you should see some of my dreams....especially those..nevermind.

Cheers to your spare time geekdom Max, I think it's awesome. Bryan your ceramics are stupendous and KK when you find out what spare time please PM me the details.

Chayton, I have said it before but I will say it again; you are very, very talented.
 
What do I do in my spare time?? Whatever I want!!! :p

If you are a geek, Max, you are the least geekish of any geeks I have ever known. That is a compliment, by the way. :cool:

And Chayton? You seriously do have a major talent there. I always loved to draw and paint, but I gave it up as I knew my "talent" lay elsewhere. I am still looking for my talent, by the way. It sure isn't cleaning house, or cooking, or baking, or sewing............Crud, I don't have any talent!!!??? :oops:

Mousey, I'm with you on the programming stuff. The last time I got into programming was when monitors were on desktops and they were attached to a big main frame sitting in an ice cold room. Talk about geeks? Oh yep, they were, glasses and pocket protectors and a vacant stare when you tried to explain something to them.
 
I guess I could say "play online" but I feel more like it became my second job.:eek: oh man, I need a vacation.
 
I'm thinking of going back to school (again) 'cause I can't decide what I want to be when I grow up and I suddenly find I have a lot of spare time. I already have an Associate in Science degree in Computer Tech. A minor degree in Abnormal psychology, a minor degree in math (need to go back to take a few refresher courses then I need 4 courses to obtain my Masters) and a minor degree in sociology. Was working on a degree in Early Childhood development when I had my first stroke in December.
 

Users who are viewing this thread

Click here for Red Cherry Casino

Meister Ratings

Back
Top