Jump to content

Uu


Achilles
 Share

Recommended Posts

This originally created by Larry, I think. I modified it slightly to make it a tool that is great for making your regular tasks going faster. What you do is press Ctrl twice and then whatever and then enter. For example: "fire" and then enter. It would then run firefox (if you have it programmed to, as it is below). Here is the part you modify:

Switch $command 
        Case 'avg' 
            Run('C:\Program Files\AVG\AVG8\avgupd.exe')
        Case 'fire'
            Run('C:\Program Files\Mozilla Firefox\firefox.exe') 
        Case 'foobar'
            Run('C:\Program Files\foobar2000\foobar2000.exe')
        Case 'gmail' 
            Run('C:\Program Files\Mozilla Firefox\firefox.exe "www.gmail.com"') 
        Case 'msn'
            Run('C:\Program Files\Windows Live\Messenger\msnmsgr.exe')
            
        Case 'exit' 
            Exit
    EndSwitch
You can add whatever you want (obviously) in the case statements. I'm currently trying to make a avgupdate command but first have to figure out how to update AVG using AutoIt. However, there are tons of ways this could be used.. for your media player, for sending text and the list goes on...

--> exit to exit <-- muttley

It's called Uu because it was originally programmed so that you press U twice to show run something but I think this works better.

Comments and ideas welcome, this is pretty easy to modify yourself..

Background pic: post-14131-1216545388_thumb.jpg

Here's the entire code (requires BETA):

#noTrayIcon
#Include <Misc.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>

Opt('GUIOnEventMode', 1)

Global $pass = False, $timer = TimerInit()

_Singleton('Uu')

$pass = True
Global $buffer = ""
Global $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
Global $hmod = _WinAPI_GetModuleHandle(0)
Global $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod)

$gui = GuiCreate('Uu', 110, 30, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
    WinSetOnTop($gui, '', 1)
    GuiCtrlCreatePic(@ScriptDir & '\Uu.jpg', 0, 0, 110, 30)
        GuiCtrlSetState(-1, $GUI_DISABLE)
    $txt = GuiCtrlCreateInput('', 5, 5, 100, 20)

    GuiCtrlCreateButton('', 115, 0, 10, 10) 
        GuiCtrlsetState(-1, $GUI_DEFBUTTON)
        GuiCtrlSetOnEvent(-1, '_Run')

While 1
    Sleep(10)
WEnd

Func _Run()
    $command = GuiCtrlRead($txt)
    GuiSetState(@SW_HIDE, $gui) 
    GuiCtrlSetData($txt, '')    

    Switch $command 
        Case 'avg' 
            Run('C:\Program Files\AVG\AVG8\avgupd.exe')
        Case 'comic'
            Run(@ProgramFilesDir & '\AutoIt3\AutoIt3.exe /AutoIt3ExecuteScript ' & FileGetShortName('C:\Documents and Settings\Daily Comics\DailyComics.au3')) 
        Case 'comicIE'
            Run(@ProgramFilesDir & '\AutoIt3\AutoIt3.exe /AutoIt3ExecuteScript ' & FileGetShortName('C:\Documents and Settings\Daily Comics\DailyComics - IE.au3')) 
        Case 'fire'
            Run('C:\Program Files\Mozilla Firefox\firefox.exe') 
        Case 'foo'
            Run('C:\Program Files\foobar2000\foobar2000.exe')
        Case 'gmail' 
            Run('C:\Program Files\Mozilla Firefox\firefox.exe "www.gmail.com"') 
        Case 'msn'
            Run('C:\Program Files\Windows Live\Messenger\msnmsgr.exe')
        Case 'office'
            Run('C:\Program Files\OpenOffice.org 2.4\program\soffice.exe')
        Case 'exit' 
            Exit
    EndSwitch 

EndFunc

Func EvaluateKey($keycode)
;~  ConsoleWrite($keyCode & @CRLF)
    If $keyCode = 162 then 
        $buffer &= '?' 
        If StringLen($buffer) = 2 then 
            $diff = TimerDiff($timer)
            If $diff < 500 and $diff > 50 then 
                GuiSetState(@SW_SHOW, $gui)
            EndIf 
            $buffer = ''
        EndIf
        $timer = TimerInit()
    Else 
        $buffer = '' 
    EndIf
EndFunc

Func _KeyProc($nCode, $wParam, $lParam)
    Local $tKEYHOOKS
    $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
    If $nCode < 0 Then
        Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
    EndIf
    If $wParam = $WM_KEYDOWN Then
        EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))
    EndIf
    Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
EndFunc  ;==>_KeyProc';gmail


Func OnAutoItExit()
    If $pass then 
        _WinAPI_UnhookWindowsHookEx($hHook)
        DllCallbackFree($hStub_KeyProc)
    EndIf
EndFunc  ;==>OnAutoItExit
Edited by Achilles
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Achilles

You forgot add GUISetState(@SW_SHOW, $gui) and i don`t understand, why need to use keyboard hook? Only for processing the Enter key? muttley Unreasonably IMHO...

Edited by rasim
Link to comment
Share on other sites

Achilles

You forgot add GUISetState(@SW_SHOW, $gui) and i don`t understand, why need to use keyboard hook? Only for processing the Enter key? muttley Unreasonably IMHO...

:) That's what I get for writing this late at night, however the key hook is still needed for when you press control twice... I think I might change enter to being hotkeyset so that the enter doesn't get sent to the active window.

I found a bug. If you go to a window, and open Uu then Alt+Tab, it will not come back!
Well, actually it's just left behind the window... This won't completely solve the problem (because I don't think many people will be pressing Alt+Tab when in the middle of such a simple script) but it will make it so that when you press control twice again the window comes to the top...
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

And I'm not many people...

You're one person, but since you matter I changed it muttley The window now is always on top (until a command is entered), plus enter is no longer sent to the active window.

Edit: @Rasim, I don't won't this popping up when the script starts, I placed in my startup and I don't need right when I startup so it's easier just to keep hidden until needed.

Edited by Achilles
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

You're one person, but since you matter I changed it muttley The window now is always on top (until a command is entered), plus enter is no longer sent to the active window.

Aww thanks!

Edit: @Racism, I don't won't this popping up when the script starts, I placed in my startup and I don't need right when I startup so it's easier just to keep hidden until needed.

I think you mean rasim :)
Link to comment
Share on other sites

I think you mean rasim :)

muttley I suppose I do, since rasim isn't a word I recognize my mind always reads Racism without me even realizing it...

Edit: I updated it so that you have to press Control twice within 500ms...

Edited by Achilles
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

LOL this script is totaly ALSOME muttley

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

One thing: change

If $wParam = $WM_KEYDOWN Then

to

If $wParam = $WM_KEYUP Then

beause the down-event is sent multiple times, when you press a key a longer time.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

One thing: change

If $wParam = $WM_KEYDOWN Then

to

If $wParam = $WM_KEYUP Then

beause the down-event is sent multiple times, when you press a key a longer time.

I would do that except I think it makes the program feel unresponsive. If you have to wait until you release the key it just seems as if the program is going to slow and didn't automatically realize you pressed the key. Also, with the "If $diff < 50" I added it means that by if you hold down control it won't trigger this program (at least on my computer).

Hey. you should check out how i did my command prompt. you might like it. you can run any thing in the current directory by just CD RUN [filename].

Wow, that's a nice program, I hadn't looked at that yet... I'm not sure how I would implement in a simple way 'cause I would have to add the entire part with the active directory.

LOL this script is totaly ALSOME smile.gif

Thanks
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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...