Jump to content

Draw 3x3 grid on desktop


 Share

Recommended Posts

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

JamesBrooks,

your code is 20 years in front of mine. Hard to understand all,

cause i'm not so skilled in Autoit, but appreciate differencies.

Now i'm preparing a bigger english DIC to see if prog can manipulate it.

m.

No really my code is retarded compared to others.

Finally I have something. The numbers entered are stored in a variable. If I press 1 it will output 1 if I press 2 it will input 12. Now I need to convert these codes into the dictionary.

If your compiling a bigger dictionary keep it in the same format - this way you could have multi-lingual dictionaries.

Forgot to include the code I have incase anyone wants to expand on it.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode
Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client

Global $GuiW = 120, $GuiH = 120
Global $msg, $hGui, $aMPos, $XSquare, $YSquare, $aWinPos
Global $sWinRect = _WinAPI_GetWindowRect(WinGetHandle("My Main")), $MP = _WinAPI_GetMousePos()
Global $sFile = @ScriptDir & '\T9Dict.dic', $hString, $in, $out
Global $aCPos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", ""); Taskbar
Global $Width = @DesktopWidth, $Height = @DesktopHeight, $user_insert
Global $sIn = "", $Edit = ""
Dim $gridWidth = 3, $gridHeight = 3, $btnArray[$GuiH][$GuiW]

; Get the desktop size without the taskbar
If $aCPos[3] > $aCPos[2] Then
    $Width = @DesktopWidth - $aCPos[2]
Else
    $Height = @DesktopHeight - $aCPos[3]
EndIf

; Create the GUI
$hGui = GUICreate("My Main", $GuiW, $GuiH, $Width - $GuiW, $Height - $GuiW, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
;WinSetTrans("My Main", "", 40)

; Buttons
$num = 1
For $Y = 0 To $gridHeight - 1
    For $X = 0 To $gridWidth - 1
        $btnArray[$Y][$X] = GUICtrlCreateButton($num, ($X * 40), ($Y * 40), 40, 40)
        GUICtrlSetOnEvent(-1, "buttonPress")
        $num += 1
    Next
Next

GUISetState()

Do
    $msg = GUIGetMsg()
    Sleep(10)
Until $msg = $GUI_EVENT_CLOSE

Func buttonPress()
    Local $aString, $sOut = ""
    For $Y = 0 To $gridHeight - 1
        For $X = 0 To $gridWidth - 1
            If @GUI_CtrlId = $btnArray[$Y][$X] Then
        ; MsgBox(0, "Grid Ref", $X & "," & $Y)
                Button(GUICtrlRead($btnArray[$Y][$X]))
                ConsoleWrite("->KEYCODE: " & $user_insert & @CRLF)
                ConsoleWrite("+>OUTPUT: " & $sOut & @CRLF)
            EndIf
        Next
    Next
EndFunc ;==>buttonPress

Func Button($num)
    $user_insert = $user_insert & $num

    If $num = 'nul' Then
        $in = $in & 0
    Else
        $in = $in & $user_insert
    EndIf

    Search_Word()
EndFunc ;==>Button

Func Search_Word()
    If StringLen($sIn) >= 1 Then
        $sOut = ""
        $aRegEx = StringRegExp(FileRead($sFile), "(?i)(?m)^(" & $sIn & ".*)$", 3)
        If IsArray($aRegEx) Then
            For $i = 0 To UBound($aRegEx) - 1
                $sOut &= $aRegEx[$i] & @CRLF
            Next
            If $Edit <> StringStripWS($sOut, 2) Then $Edit = StringStripWS($sOut, 2)
        Else
            If $Edit <> "" Then $Edit = ""
        EndIf
    Else
        If $Edit <> "" Then $Edit = ""
    EndIf
EndFunc ;==>Search_Word

Func Close()
    Exit
EndFunc ;==>Close

By the way - the dictionary file is called, T9Dict.dic

Edited by JamesBrooks
Link to comment
Share on other sites

'KEYCODE:' is returned in console but not 'OUTPUT:'

maybe i'm wrong something ?

try also BIGGER T9 dictionary, search engine is fast as lighting :mellow:

DIC is made by me, maybe can be usefull made one based on most used words,

anyone can help find 'most used words' for your own language ?

(buildind small script that 'convert' in T9 dictionary format)

thank you all for interest,

m.

Link to comment
Share on other sites

Ok I changed some print messages to make it easier to understand. And now if you press 1 it acts like the word has been found. I still haven't been able to get the output word though, I narrowed it down to the regexp as it is not returning an array.

Forgot the code again :mellow:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode
Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client

Global $GuiW = 120, $GuiH = 120
Global $sFile = @ScriptDir & '\T9Dict.dic', $hString, $in, $out
Global $aCPos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", ""); Taskbar
Global $Width = @DesktopWidth, $Height = @DesktopHeight, $user_insert
Global $sIn = "", $Edit = ""
Dim $gridWidth = 3, $gridHeight = 3, $btnArray[$GuiH][$GuiW]

; Get the desktop size without the taskbar
If $aCPos[3] > $aCPos[2] Then
    $Width = @DesktopWidth - $aCPos[2]
Else
    $Height = @DesktopHeight - $aCPos[3]
EndIf

; Create the GUI
$hGui = GUICreate("My Main", $GuiW, $GuiH, $Width - $GuiW, $Height - $GuiW, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

; Generate Buttons
$num = 1
For $Y = 0 To $gridHeight - 1
    For $X = 0 To $gridWidth - 1
        $btnArray[$Y][$X] = GUICtrlCreateButton($num, ($X * 40), ($Y * 40), 40, 40)
        GUICtrlSetOnEvent(-1, "buttonPress")
        $num += 1
    Next
Next

GUISetState()

Do
    $msg = GUIGetMsg()
    Sleep(10)
Until $msg = $GUI_EVENT_CLOSE

Func buttonPress()
    Local $aString, $sOut = ""
    For $Y = 0 To $gridHeight - 1
        For $X = 0 To $gridWidth - 1
            If @GUI_CtrlId = $btnArray[$Y][$X] Then
            ; MsgBox(0, "Grid Ref", $X & "," & $Y)
                ConsoleWrite("!>BUTTON: " & GUICtrlRead($btnArray[$Y][$X]) & @CRLF)
                Button(GUICtrlRead($btnArray[$Y][$X]))
                ConsoleWrite("->USER_INSERT: " & $user_insert & @CRLF)
                ConsoleWrite("+>OUTPUT: " & $sOut & @CRLF)
            EndIf
        Next
    Next
EndFunc  ;==>buttonPress

Func Button($iNum)
    $user_insert = $user_insert & $inum

    If $iNum = 1 then
        $user_insert = ""
    Else
        If $inum = 'nul' Then
            $in = $in & 0
        Else
            $in = $in & $user_insert
        EndIf
    EndIf

    Search_Word($user_insert)
EndFunc  ;==>Button

Func Search_Word($sIn)
    ConsoleWrite("$sIn: " & $sIn & @CRLF)
    If StringLen($sIn) >= 1 Then
    ; ConsoleWrite("String length accepted" & @CRLF)
        $sOut = ""
        $aRegEx = StringRegExp(FileRead($sFile), "(?i)(?m)^(" & $sIn & ".*)$", 3)
        If IsArray($aRegEx) Then
            MsgBox(0, "", "")
            For $i = 0 To UBound($aRegEx) - 1
                $sOut &= $aRegEx[$i] & @CRLF
                MsgBox(0, "T9", $sOut)
            Next
            If $Edit <> StringStripWS($sOut, 2) Then $Edit = StringStripWS($sOut, 2)
        Else
            If $Edit <> "" Then $Edit = ""
        EndIf
    Else
        If $Edit <> "" Then $Edit = ""
    EndIf
EndFunc  ;==>Search_Word

Func Close()
    Exit
EndFunc  ;==>Close
Edited by JamesBrooks
Link to comment
Share on other sites

Haha. I just found out that I had the dictionary in the wrong folder.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode
Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client

Global $GuiW = 120, $GuiH = 120
Global $sFile = @ScriptDir & "\T9Dict.dic", $hString, $in, $out
Global $aCPos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", ""); Taskbar
Global $Width = @DesktopWidth, $Height = @DesktopHeight, $user_insert
Global $sIn = "", $Edit = ""
Dim $gridWidth = 3, $gridHeight = 3, $btnArray[$GuiH][$GuiW]

; Get the desktop size without the taskbar
If $aCPos[3] > $aCPos[2] Then
    $Width = @DesktopWidth - $aCPos[2]
Else
    $Height = @DesktopHeight - $aCPos[3]
EndIf

; Create the GUI
$hGui = GUICreate("My Main", $GuiW, $GuiH, $Width - $GuiW, $Height - $GuiW, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

; Generate Buttons
$num = 1
For $Y = 0 To $gridHeight - 1
    For $X = 0 To $gridWidth - 1
        $btnArray[$Y][$X] = GUICtrlCreateButton($num, ($X * 40), ($Y * 40), 40, 40)
        GUICtrlSetOnEvent(-1, "buttonPress")
        $num += 1
    Next
Next

GUISetState()

Do
    $msg = GUIGetMsg()
    Sleep(10)
Until $msg = $GUI_EVENT_CLOSE

Func buttonPress()
    Local $aString, $sOut = ""
    For $Y = 0 To $gridHeight - 1
        For $X = 0 To $gridWidth - 1
            If @GUI_CtrlId = $btnArray[$Y][$X] Then
            ; MsgBox(0, "Grid Ref", $X & "," & $Y)
                Button(GUICtrlRead($btnArray[$Y][$X]))
            ; ConsoleWrite("!>BUTTON: " & GUICtrlRead($btnArray[$Y][$X]) & @CRLF)
            ; ConsoleWrite("->USER_INSERT: " & $user_insert & @CRLF)
                If Not $Edit = "" Then ConsoleWrite("+>OUTPUT: " & $Edit & @CRLF)
            EndIf
        Next
    Next
EndFunc  ;==>buttonPress

Func Button($iNum)
    $user_insert = $user_insert & $inum

    If $iNum = 1 then
        $user_insert = ""
        $Edit = ""
    Else
        If $inum = 'nul' Then
            $in = $in & 0
        Else
            $in = $in & $user_insert
        EndIf
    EndIf

    Search_Word($user_insert)
EndFunc  ;==>Button

Func Search_Word($sIn)
    If StringLen($sIn) >= 1 Then
        $sOut = ""
        $aRegEx = StringRegExp(FileRead($sFile), "(?i)(?m)^(" & $user_insert & ".*)$", 3)
        If IsArray($aRegEx) Then
            For $i = 0 To UBound($aRegEx) - 1
                $sOut &= $aRegEx[$i]
            Next
            If $Edit <> StringStripWS($sOut, 2) Then $Edit = StringStripWS($sOut, 2)
        EndIf
    EndIf
EndFunc  ;==>Search_Word

Func Close()
    Exit
EndFunc  ;==>Close

You need a way of changing word though.

Edited by JamesBrooks
Link to comment
Share on other sites

Perfect !

You need a way of changing word though.

i'm reserved button 1 to do different task, now i'm need an idea...

Think also to add different buttons:

- cancel word

- backslash

- punctuation

- numbers

Or press 1 change (ehm) labels on buttons and theirs functions

What you think ?

Link to comment
Share on other sites

master,

i'm in your hands :mellow:

Often dictionary contains differents words for same number,

must think an easy way to see and choose one of them.

(array on video, copy & paste, need good idea...)

I'm working on T9 convert script (easy letter substitution)

so anyone can use own dictionary.

m.

Link to comment
Share on other sites

Just thinking about how to select new words. The only way I could think of doing it is if you put all the words matched into an array and "flicking" through them for each word.

Here we have the *0# buttons added. They don't do anything yet :mellow:.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode
Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client

HotKeySet("{F9}", "Output")

Global $GuiW = 120, $GuiH = 180
Global $sFile = @ScriptDir & "\T9Dict.dic", $hString, $in, $out
Global $aCPos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", ""); Taskbar
Global $Width = @DesktopWidth, $Height = @DesktopHeight, $user_insert
Global $sIn = "", $Edit[1000]
Dim $gridWidth = 3, $gridHeight = 4, $btnArray[$GuiH][$GuiW]

; Get the desktop size without the taskbar
If $aCPos[3] > $aCPos[2] Then
    $Width = @DesktopWidth - $aCPos[2]
Else
    $Height = @DesktopHeight - $aCPos[3]
EndIf

; Create the GUI
$hGui = GUICreate("My Main", $GuiW, $GuiH, $Width - $GuiW, $Height - $GuiH, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

$cWord = GuiCtrlCreateLabel("", 0, 0, $GuiW, 20)

; Generate Buttons
$num = 1
For $Y = 0 To $gridHeight - 1
    For $X = 0 To $gridWidth - 1
        $btnArray[$Y][$X] = GUICtrlCreateButton($num, ($X * 40), ($Y * 40) + 20, 40, 40)
        GUICtrlSetOnEvent(-1, "buttonPress")
        $num += 1
    Next
Next

; Set the last 3 to extra buttons
GUICtrlSetData($btnArray[3][0], "*")
GUICtrlSetData($btnArray[3][1], "0")
GUICtrlSetData($btnArray[3][2], "#")

GUISetState()

Do
    $msg = GUIGetMsg()
    Sleep(10)
Until $msg = $GUI_EVENT_CLOSE

Func buttonPress()
    Local $aString, $sOut = ""
    For $Y = 0 To $gridHeight - 1
        For $X = 0 To $gridWidth - 1
            If @GUI_CtrlId = $btnArray[$Y][$X] Then
        ; MsgBox(0, "Grid Ref", $Y & "," & $X)
                Button(GUICtrlRead($btnArray[$Y][$X]))
        ; ConsoleWrite("!>BUTTON: " & GUICtrlRead($btnArray[$Y][$X]) & @CRLF)
        ; ConsoleWrite("->USER_INSERT: " & $user_insert & @CRLF)
                If Not $Edit = "" Then 
                    ConsoleWrite("+>OUTPUT: " & $Edit & @CRLF)
                    GUICtrlSetData($cWord, $Edit)
                EndIf
            EndIf
        Next
    Next
EndFunc ;==>buttonPress

Func Button($iNum)
    $user_insert = $user_insert & $inum

    If $iNum = 1 then
        $user_insert = ""
        For $a = 0 to $Edit - 1
            $Edit[$a] = ""
        Next
    Else
        If $inum = 'nul' Then
            $in = $in & 0
        Else
            $in = $in & $user_insert
        EndIf
    EndIf

    Search_Word($user_insert)
EndFunc ;==>Button

Func Search_Word($sIn)
    If StringLen($sIn) >= 1 Then
        $sOut = ""
        $aRegEx = StringRegExp(FileRead($sFile), "(?i)(?m)^(" & $user_insert & ".*)$", 3)
        If IsArray($aRegEx) Then
            For $i = 0 To UBound($aRegEx) - 1
                $sOut &= $aRegEx[$i]
                _ArrayAdd($Edit, $sOut)
            Next
            If $Edit <> StringStripWS($sOut, 2) Then $Edit = StringStripWS($sOut, 2)
        EndIf
    EndIf
EndFunc ;==>Search_Word

Func Output()
    ConsoleWrite("+>Output----------------------------------" & @CRLF)
    For $z = 0 to $Edit - 1
        ConsoleWrite($Edit[$z])
    Next
EndFunc

Func Close()
    Exit
EndFunc ;==>Close

Also a label is placed at the top and it shows the current letter. I am thinking * for next word and # for previous.

Here is my idea, hope you like it.

An array is created with the amount of words in the dictionary e.g. 1000:

$Edit[1000]

The $Edit variable is now an array. The 0 index should keep count of how many words there are for the words for example if we type 432 we should get 6 results. So now $Edit[0] = 6

The first word is put into the label and a marker turns green showing another word is available. We press * and the next word is shown. When we run out of possible words we can turn go back by pressing # and the marker will turn red to display no more words.

To do this you might need to create a two-dimensional array, $Edit[1000][2] so that the 2nd element will hold the word which is being displayed or at least the value which it is in the first element. If we go back to the 432 example our array will look like so; 6, 250. 250 is the line number that the word is found in the dictionary. If we press star then the next word "hear" will be found and our array will be; 6, 252.

Hope that makes sense.

Edited by JamesBrooks
Link to comment
Share on other sites

two-dimensional array is good idea, hope initial amount of words in the dictionary is not too big

to manage, for script (think not).

My DIC are big, read somewhere that T9 dic contains about 65000 words, mine are smaller ...

When a single word is find or choosen by user, i think to put it in clipoard, maybe a tooltip near mouse arrow

show word and a double click or paste can finish the job.

Vitual keyboard seen here in forum manage focus on other windows, but i can't figure how this works.

good job!

m.

Link to comment
Share on other sites

Now if there is words found the bar will turn green. I am now implementing the array idea along with a listbox to display all available words above the keys.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1); Change to OnEvent mode
Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client

HotKeySet("{F9}", "Output")

Global $GuiW = 120, $GuiH = 180
Global $sFile = @ScriptDir & "\T9Dict.dic", $in, $out
Global $aCPos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", ""); Taskbar
Global $Width = @DesktopWidth, $Height = @DesktopHeight, $user_insert, $sIn = "", $Edit[1000][2]
Dim $gridWidth = 3, $gridHeight = 4, $btnArray[$GuiH][$GuiW]

; Get the desktop size without the taskbar
If $aCPos[3] > $aCPos[2] Then
    $Width = @DesktopWidth - $aCPos[2]
Else
    $Height = @DesktopHeight - $aCPos[3]
EndIf

; Create the GUI
$hGui = GUICreate("My Main", $GuiW, $GuiH, $Width - $GuiW, $Height - $GuiH, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

$cWord = GuiCtrlCreateLabel("", 0, 0, $GuiW - 10, 20)
GuiCtrlSetFont(-1, 9)
$cNext = GuiCtrlCreateLabel("", $GuiW - 10, 0, 10, 20)
GUICtrlSetBkColor(-1, 0xff0000)

; Generate Buttons
$num = 1
For $Y = 0 To $gridHeight - 1
    For $X = 0 To $gridWidth - 1
        $btnArray[$Y][$X] = GUICtrlCreateButton($num, ($X * 40), ($Y * 40) + 20, 40, 40)
        GUICtrlSetOnEvent(-1, "buttonPress")
        $num += 1
    Next
Next

; Set the last 3 to extra buttons
GUICtrlSetData($btnArray[3][0], "*")
GUICtrlSetData($btnArray[3][1], "0")
GUICtrlSetData($btnArray[3][2], "#")

GUISetState()

Do
    $msg = GUIGetMsg()
    Sleep(10)
Until $msg = $GUI_EVENT_CLOSE

Func buttonPress()
    Local $aString, $sOut = ""
    For $Y = 0 To $gridHeight - 1
        For $X = 0 To $gridWidth - 1
            If @GUI_CtrlId = $btnArray[$Y][$X] Then
            ; MsgBox(0, "Grid Ref", $Y & "," & $X)
                Button(GUICtrlRead($btnArray[$Y][$X]))
            ; ConsoleWrite("!>BUTTON: " & GUICtrlRead($btnArray[$Y][$X]) & @CRLF)
            ; ConsoleWrite("->USER_INSERT: " & $user_insert & @CRLF)
                If Not $Edit = "" Then 
                    ConsoleWrite("+>OUTPUT: " & $Edit & @CRLF)
                    GUICtrlSetData($cWord, $Edit)
                EndIf
            EndIf
        Next
    Next
EndFunc  ;==>buttonPress

Func Button($iNum)
    $user_insert = $user_insert & $inum

    If $iNum = 1 then
        $user_insert = ""
        $edit = ""
        GUICtrlSetData($cWord, $edit)
        GUICtrlSetBkColor($cNext, 0xff0000)
    Else
        If $inum = 'nul' Then
            $in = $in & 0
        Else
            $in = $in & $user_insert
        EndIf
    EndIf

    Search_Word($user_insert)
EndFunc  ;==>Button

Func Search_Word($sIn)
    If StringLen($sIn) >= 1 Then
        $sOut = ""
        $aRegEx = StringRegExp(FileRead($sFile), "(?i)(?m)^(" & $user_insert & ".*)$", 3)
        If IsArray($aRegEx) Then
            For $i = 1 To UBound($aRegEx) - 1
                $sOut &= $aRegEx[$i]
            Next
            If $Edit <> StringStripWS($sOut, 2) Then $Edit = StringStripWS($sOut, 2)
            If $Edit <> "" Then GUICtrlSetBkColor($cNext, 0x00ff00)
        EndIf
    EndIf
EndFunc  ;==>Search_Word

Func Output()
    ConsoleWrite(">Output----------------------------------" & @CRLF)
    For $z = 0 to $Edit - 1
        ConsoleWrite($Edit[$z])
    Next
EndFunc

Func Close()
    Exit
EndFunc  ;==>Close
Link to comment
Share on other sites

You might be able to use some of the workings from this example.

Instructions are at the top of the script, good luck.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>

; http://www.autoitscript.com/forum/index.php?s=&showtopic=83659&view=findpost&p=599440
; ====================== Instructions =================
; Left mouse button                         - Select letter.
; Left mouse button while Ctrl key pressed  - Move /Drag GUI.
; Right mouse button                        - Returns selected word.
; Right mouse button while Ctrl key pressed - Removes last selected letter (BackSpace)
; Mouse Wheel rotation - Rotates through ToolTip list.
; When required word show on tooltip press Right mouse button to return word.
; =================> End of Instructions ===============

Global Const $WM_MOUSEWHEEL = 0x020A ;wheel up/down
Global Const $WM_LBUTTONDOWN = 0x0201 ; Drag Window 1 of 3
Global $hGui, $gui, $sOut, $Edit = "", $xmouseData = 0, $iDexAr = 1
Global $sFile = @ScriptDir & "\T9Dict.dic"

Local $input = T9()
;ConsoleWrite("$input = " & $input & @CRLF)
MsgBox(0, "", "Selected Word is:- " & @CRLF & @CRLF & $input)

Exit


Func T9()
    Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client
    Local $aLabel[10][2] = [[9, 0],[0, "1    "],[0, " 2 " & @CRLF & "abc"],[0, " 3 " & @CRLF & "def"], _
            [0, " 4 " & @CRLF & "ghi"],[0, " 5 " & @CRLF & "jkl"],[0, " 6 " & @CRLF & "mno"],[0, " 7 " & @CRLF & "pqrs"],[0, " 8 " & @CRLF & "tuv"],[0, " 9 " & @CRLF & "wxyz"]]
    Local $msg, $RetNo, $iIdx = 1, $iInit = 1, $iTimer = 10000, $iTimeDiff = 1000
    Local $ret = "", $num = 0, $aRet, $x = 3, $y = 3,$aRet
    Local $guix = $x * 50
    Local $guiy = $y * 50
    $hGui = GUICreate("T9", $guix, $guiy, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
    WinSetTrans("T9", "", 255)
    GUISetBkColor(0xEEEEEE)
    _WinAPI_SetLayeredWindowAttributes($hGui, 0xEEEEEE);,255);,3,true);
    GUICtrlCreateGraphic(0, 0, $guix, $guiy)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $guiy / 3)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, $guix, $guiy / 3)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $guiy * 2 / 3)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, $guix, $guiy * 2 / 3)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $guix / 3, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, $guix / 3, $guiy)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $guix * 2 / 3, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, $guix * 2 / 3, $guiy)
    GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove") ; Drag Window 2 of 3
    GUIRegisterMsg($WM_MOUSEWHEEL, "_MOUSEWHEEL")
    GUISetState()
   
    For $n = 1 To $y
        For $m = 1 To $x
            $num += 1
            $aLabel[$num][0] = GUICtrlCreateLabel($aLabel[$num][1], 6 + ($m - 1) * 50, 7 + ($n - 1) * 50,40,40)
            ;GUICtrlSetColor(-1, "0x" & Hex(Random(0, 0xFF, 1), 2) & Hex(Random(0, 0xAA, 1), 2) & Hex(Random(0, 0xFF, 1), 2))
            GUICtrlSetFont(-1, 12, 800)
        Next
    Next
    GUISetState()
    $gui = GUICreate("Control Gui", $guix, $guiy, -2, -20, $WS_POPUPWINDOW, $WS_EX_MDICHILD, $hGui)
    WinSetTrans($gui, "", 40)
    GUISetBkColor(0xEEEEEE)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Local $sWinRect = _WinAPI_GetWindowRect(WinGetHandle("T9"))
        Local $MP = _WinAPI_GetMousePos()
        If _WinAPI_PtInRect($sWinRect, $MP) Then
            Select
                Case $msg = -3 ; $GUI_EVENT_CLOSE
                    GUIDelete($hGui)
                    Return $ret
                Case $msg = $GUI_EVENT_PRIMARYUP; -8 ;
                    If Not _IsPressed("11") Then
                        $currPos = MouseGetPos()
                        If $currPos[1] > 0 Then
                            $RetNo = Int($currPos[0] / 50) + 1 + (Int($currPos[1] / 50) * $x)
                            $ret &= $RetNo
                            $aWinPos = WinGetPos("Control Gui")
                            Search_Word($ret)
                            ToolTip(" " & $Edit & " ", $aWinPos[0] + $guix, $aWinPos[1] - 10)
                            $aEdit = StringSplit($Edit, @CRLF)
                            $iDexAr = 1
                            ;If Not $Edit = "" Then ConsoleWrite("+>OUTPUT: " & $Edit & @CRLF)
                            ;ConsoleWrite("$ret = " & $ret & " $RetNo = " & $RetNo & " $Edit = " & $Edit & @CRLF)
                        EndIf
                    EndIf
                Case $xmouseData <> 0
                    $iDexAr += $xmouseData
                    If $iDexAr < 1 Then $iDexAr = $aEdit[0]
                    If $iDexAr > $aEdit[0] Then $iDexAr = 1
                    ToolTip(" " & $aEdit[$iDexAr] & " ", $aWinPos[0] + $guix, $aWinPos[1] - 10)
                    $xmouseData = 0
                Case $msg = $GUI_EVENT_SECONDARYUP
                    If Not _IsPressed("11") Then
                        GUIDelete($hGui)
                        ;$aRet = StringSplit(, ";")
                        Return $aEdit[$iDexAr]
                        ;ConsoleWrite("$ret = " & $ret & "$Edit = " & $Edit & @CRLF)
                    Else
                        $ret = StringTrimRight($ret, 1)
                        $aWinPos = WinGetPos("Control Gui")
                        ToolTip(" " & $ret & " ", $aWinPos[0] - 10, $aWinPos[1] - 10)
                        ToolTip(" " & $aEdit[$iDexAr] & " ", $aWinPos[0] + $guix, $aWinPos[1] - 10)
                    EndIf
            EndSelect
        Else
            ToolTip("")
        EndIf
    WEnd
EndFunc   ;==>T9

Func Search_Word($sIn)
    If StringLen($sIn) >= 1 Then
        $sOut = ""
        $aRegEx = StringRegExp(FileRead($sFile), "(?i)(?m)^(" & $sIn & ".*)$", 3)
        If IsArray($aRegEx) Then
            For $i = 0 To UBound($aRegEx) - 1
                $sOut &= StringRegExpReplace($aRegEx[$i], "\A(\d*);(\D*)","$2" )
            Next
            If $Edit <> StringStripWS($sOut, 2) Then $Edit = StringStripWS($sOut, 2)
        EndIf
    EndIf
    Return $Edit
EndFunc   ;==>Search_Word

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc   ;==>_WinAPI_SetLayeredWindowAttributes

Func _WinMove($hwnd, $Command, $wParam, $lParam)
    If $hwnd = $hGui Or $hwnd = $gui Then
        If _IsPressed("11") Then ; Ctrl key
            DllCall("user32.dll", "int", "SendMessage", "hWnd", $hGui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
        EndIf
    EndIf
    Return
EndFunc   ;==>_WinMove

Func _MOUSEWHEEL($hwnd, $Command, $wParam, $lParam)
    If _WinAPI_HiWord($wParam) > 0 Then
        $xmouseData = 1 ; "Wheel Forward"
    Else
        $xmouseData = -1 ; "Wheel Backward"
    EndIf
    ;ConsoleWrite("$Command = " & $Command & " $xmouseData = " & $xmouseData & " $lParam = " & $lParam & @CRLF)   
    Return
EndFunc   ;==>_MOUSEWHEEL

Edit:6/11/2008 - Added StringRegExpReplace for tooltip (removes numbers).

Edited by Malkey
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...