Rainmeter-like Evernote/Search Widget (gui)

Post your working scripts, libraries and tools for AHK v1.1 and older
capeably
Posts: 47
Joined: 10 Jul 2014, 14:38

Rainmeter-like Evernote/Search Widget (gui)

28 Apr 2016, 16:51

Image

This is based on a template originally coded by Just Me (links are in the code).

I'm really new to this, so I've had a lot of help tweaking this from folks like kon and others.

One problem I would like to fix: the widget doesn't resize to accommodate larger text if the user has set their Control Panel > display settings (size of fonts/controls) to be larger or smaller than the default (100%). Does anyone know how this might be fixed?

This is a really cool template Just Me coded. Please feel free to post any adaptations you think people might find interesting.

The way this widget works...

In general, it's setup so that for any context (i.e. notebook, tag, or combo) option, if you just click the control with a blank search field, it returns all notes in that context -- goes to the notebook if it's a notebook, to the tag if it's a tag, etc.

If you type a search string and then click the control option, it searches the title of notes in that context.

If you enter a number (integer) into the search field, it will return all notes in that context that have been updated within that many days as the number entered.

You can also submit the searches by:

using Tab/Shift+Tab to select the option you want, then hit Enter.
Using Alt+1-0 hotkeys
Using Numpad1-0 Hokeys

Here's a quick video demo:

Code: Select all

SetTitleMatchMode, 2


; GUI style template coded by just me - http://www.autohotkey.com/board/topic/90723-achieve-rainmeter-style-gui-via-gdip-library/?p=573445
; posted to gui examples by kon - http://ahkscript.org/boards/viewtopic.php?f=6&t=3851#p12351
; modified as search box by capeably
; modified with tab selection controls by kon http://www.autohotkey.com/board/topic/120754-gui-example-with-multiple-edit-fields-and-buttons/?p=686496
; modified as Rainmeter-like widget by expert vision


; |=**********************************************
; | | | | Main Edit | | | | |
; | | | | | | | | |


GadgetName := "Evernote Search Box"


CtrlTxt1 = inTitle: All Notebooks
Ctrl1Param1 =
Ctrl1Param2 =
Ctrl1Param3 =
CtrlTxt2 = Inbox
Ctrl2Param1 = notebook:""Inbox""
Ctrl2Param2 =
Ctrl2Param3 =
CtrlTxt3 = Evernote
Ctrl3Param1 = tag:""Evernote""
Ctrl3Param2 =
Ctrl3Param3 =
CtrlTxt4 = Evernote Inbox
Ctrl4Param1 = notebook:""Inbox""
Ctrl4Param2 = tag:""Evernote""
Ctrl4Param3 =
CtrlTxt5 = Quotes
Ctrl5Param1 = tag:""Quotes""
Ctrl5Param2 =
Ctrl5Param3 =
CtrlTxt6 = Notebook
;~ Ctrl6Param1 =
;~ Ctrl6Param2 =
;~ Ctrl6Param3 =
CtrlTxt7 = Tag
;~ Ctrl7Param1 =
;~ Ctrl7Param2 =
;~ Ctrl7Param3 =
CtrlTxt8 = Recent Notes (2d)
Ctrl8Param1 = updated:day-2
;~ Ctrl8Param2 =
;~ Ctrl8Param3 =
CtrlTxt9 = Google
Ctrl9Param1 = https://www.google.com
Ctrl9Param2 = http://www.google.com/search?hl=en&q=
;~ Ctrl9Param3 =
CtrlTxt10 = YouTube
Ctrl10Param1 = http://www.youtube.com
Ctrl10Param2 = http://www.youtube.com/results?search_query=
;~ Ctrl10Param3 =

; | | | | | | | | |
; | | | | | | | | |
; ************************************************







Width := 230
Gui, +LastFound
Gui, +ToolWindow ; get's rid of the taskbar icon and gives a narrower title bar
WinSet, Transparent, 235
Gui, Color, 808080
Gui, Margin, 0, 0
Gui, Font,, Verdana
Gui, Font, s12 cFFFFFF Bold ; Header font
Gui, Add, Progress, % "x-1 y-1 w" (Width+2) " h31 Background31b7b9 Disabled hwndHPROG"
Control, ExStyle, -0x20000, , ahk_id %HPROG% ; propably only needed on Win XP
Gui, Add, Text, % "x0 y0 w" Width " h30 BackgroundTrans Center 0x200 gGuiMove vCaption", %GadgetName%
Gui, Font, s9 c808080 ; Search field font
Gui, add, edit, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX1" varSearch
Gui, Font, s9 cFFFFFF Bold ; Control label font
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX2 gCtrl1", &1 %CtrlTxt1%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX3 gCtrl2", &2 %CtrlTxt2%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX4 gCtrl3", &3 %CtrlTxt3%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX5 gCtrl4", &4 %CtrlTxt4%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX6 gCtrl5", &5 %CtrlTxt5%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX7 gCtrl6", &6 %CtrlTxt6%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX8 gCtrl7", &7 %CtrlTxt7%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX9 gCtrl8", &8 %CtrlTxt8%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX10 gCtrl9", &9 %CtrlTxt9%
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 vTX11 gCtrl10", &0 %CtrlTxt10%
Gui, Add, Text, % "x7 y+10 w" (Width-14), _________________
Gui, Add, Text, % "x7 y+13 w" (Width-14) "r1 +0x4000 vTX12 gClose", . CLOSE
Gui, Add, Text, % "x7 y+10 w" (Width-14) "h5 vP"
GuiControlGet, P, Pos
H := PY + PH
Gui, -Caption
WinSet, Region, 0-0 w%Width% h%H% r6-6
Gui, Show,, SearchGadgetWindow ; Name Window Title
Gui, Show, x0 y0 ; Position at top left of screen


hGadgetGui := WinExist()
SetTimer, DesktopIntegration


TotalControls := 12


Selection := 1 ; when tab is first pressed, selection will be changed to 2, and TX2 will be selected
return


DesktopIntegration: ; label activates the gadget window (brings it to the front) whenever the current active window class is "WorkerW" (desktop when you press Win+D)
WinGetClass, ahk_class, A
If (ahk_class == "WorkerW") and (LastClass != "WorkerW") ;and (LastClass != "AutoHotkeyGUI")
WinActivate, % "ahk_id " . hGadgetGui
LastClass := ahk_class
return



ChangeSelection:
TotalLoops := TotalControls - 1
Loop, %TotalLoops% ; loop once for each control (TX2-TX5)
{
i := A_Index + 1
if (i = Selection) ; If this is the selected control change its font
{
Gui, Font, c31b7b9 bold
GuiControl, Font, TX%i%
}
else ; else use the normal font
{
Gui, Font, cFFFFFF bold
GuiControl, Font, TX%i%
}
}
return


GuiMove:
PostMessage, 0xA1, 2
return


#IfWinActive, SearchGadgetWindow ahk_class AutoHotkeyGUI
!1::gosub, Ctrl1
!2::gosub, Ctrl2
!3::gosub, Ctrl3
!4::gosub, Ctrl4
!5::gosub, Ctrl5
!6::gosub, Ctrl6
!7::gosub, Ctrl7
!8::gosub, Ctrl8
!9::gosub, Ctrl9
!0::gosub, Ctrl10


Numpad1::gosub, Ctrl1
Numpad2::gosub, Ctrl2
Numpad3::gosub, Ctrl3
Numpad4::gosub, Ctrl4
Numpad5::gosub, Ctrl5
Numpad6::gosub, Ctrl6
Numpad7::gosub, Ctrl7
Numpad8::gosub, Ctrl8
Numpad9::gosub, Ctrl9
Numpad0::gosub, Ctrl10
!x::ExitApp
Esc::ExitApp


Enter::
NumpadEnter::
Select := {2: "Ctrl1", 3: "Ctrl2", 4: "Ctrl3", 5: "Ctrl4", 6: "Ctrl5", 7: "Ctrl6", 8: "Ctrl7", 9: "Ctrl8", 10: "Ctrl9", 11: "Ctrl10"}
; the selection numbers and the labels they correspond to
if (Selection != 1)
{
gosub, % Select[Selection]
}
return


Tab::
Selection++
if (Selection > TotalControls)
{
Selection := 2
}
gosub, ChangeSelection
return


+Tab::
Selection--
if (Selection < 2)
{
Selection := TotalControls
}
gosub, ChangeSelection
return


#IfWinActive



Close:
ExitApp



Ctrl1:
Selection := 2
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
if tx1 is Integer ; if search field is a number
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl1Param1% %Ctrl1Param2% %Ctrl1Param3% updated:day-%TX1%"
Return
}
else ; if Search is a string
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl1Param1% %Ctrl1Param2% %Ctrl1Param3% intitle:""%TX1%"""
Return
}
}
Else ; if search is blank
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "updated:day-45"
}
Return


Ctrl2:
Selection := 3
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
if tx1 is Integer ; if search field is a number
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl2Param1% %Ctrl2Param2% %Ctrl2Param3% updated:day-%TX1%"
Return
}
else ; if Search is a string
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl2Param1% %Ctrl2Param2% %Ctrl2Param3% intitle:""%TX1%"""
Return
}
}
Else ; if search is blank
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl2Param1% %Ctrl2Param2% %Ctrl2Param3%"
}
Return


Ctrl3:
Selection := 4
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
if tx1 is Integer ; if search field is a number
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl3Param1% %Ctrl3Param2% %Ctrl3Param3% updated:day-%TX1%"
Return
}
else ; if Search is a string
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl3Param1% %Ctrl3Param2% %Ctrl3Param3% intitle:""%TX1%"""
Return
}
}
Else ; if search is blank
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl3Param1% %Ctrl3Param2% %Ctrl3Param3%"
}
Return


Ctrl4:
Selection := 5
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
if tx1 is Integer ; if search field is a number
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl4Param1% %Ctrl4Param2% %Ctrl4Param3% updated:day-%TX1%"
Return
}
else ; if Search is a string
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl4Param1% %Ctrl4Param2% %Ctrl4Param3% intitle:""%TX1%"""
Return
}
}
Else ; if search is blank
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl4Param1% %Ctrl4Param2% %Ctrl4Param3%"
}
Return


Ctrl5:
Selection := 6
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
if tx1 is Integer ; if search field is a number
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl5Param1% %Ctrl5Param2% %Ctrl5Param3% updated:day-%TX1%"
Return
}
else ; if Search is a string
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl5Param1% %Ctrl5Param2% %Ctrl5Param3% intitle:""%TX1%"""
Return
}
}
Else ; if search is blank
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl5Param1% %Ctrl5Param2% %Ctrl5Param3%"
}
Return


Ctrl6:
Selection := 7
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
;~ if tx1 is Integer ; if search field is a number
;~ {
;~ Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl6Param1% %Ctrl6Param2% %Ctrl6Param3% updated:day-%TX1%"
;~ Return
;~ }
;~ else ; if Search is a string
;~ {
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "notebook:""%TX1%"""
Return
;~ }
}
;~ Else ; if search is blank
;~ {
;~ Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl6Param1% %Ctrl6Param2% %Ctrl6Param3%"
;~ }
Return


Ctrl7:
Selection := 8
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
;~ if tx1 is Integer ; if search field is a number
;~ {
;~ Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl7Param1% %Ctrl7Param2% %Ctrl7Param3% updated:day-%TX1%"
;~ Return
;~ }
;~ else ; if Search is a string
;~ {
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "tag:""%TX1%"""
Return
;~ }
}
;~ Else ; if search is blank
;~ {
;~ Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl7Param1% %Ctrl7Param2% %Ctrl7Param3%"
;~ }
Return


Ctrl8:
Selection := 9
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
if tx1 is Integer ; if search field is a number
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "updated:day-%TX1%"
Return
}
else ; if Search is a string
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl8Param1% %Ctrl8Param2% %Ctrl8Param3% intitle:""%TX1%"""
Return
}
}
Else ; if search is blank
{
Run, C:\Program Files (x86)\Evernote\Evernote\ENScript.exe showNotes /q "%Ctrl8Param1% %Ctrl8Param2% %Ctrl8Param3%"
}
Return


Ctrl9:
Selection := 10
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
Run, %Ctrl9Param2%%TX1%
Return
}
Else ; if search is blank
{
Run, %Ctrl9Param1%
}
Return


Ctrl10:
Selection := 11
Gui, submit, nohide
gosub, ChangeSelection
IfNotEqual, tx1, ; if search field isn't blank
{
Run, %Ctrl10Param2%%TX1%
Return
}
Else ; if search is blank
{
Run, %Ctrl10Param1%
}
Return

* Originally posted here:
https://autohotkey.com/board/topic/1210 ... idget-gui/
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Rainmeter-like Evernote/Search Widget (gui)

02 May 2016, 08:33

capeably wrote: One problem I would like to fix: the widget doesn't resize to accommodate larger text if the user has set their Control Panel > display settings (size of fonts/controls) to be larger or smaller than the default (100%). Does anyone know how this might be fixed?
i thought that should work by default in the newer versions of AHK:

https://autohotkey.com/docs/commands/Gui.htm#DPIScale

sttrebo
Posts: 68
Joined: 27 Jan 2014, 12:31

Re: Rainmeter-like Evernote/Search Widget (gui)

02 May 2016, 10:43

one recommendation would be to add a variable for the location of ENScript.exe. For me, my Evernote is installed in another directory so I changed your script to add:

EnLoc = my location \Evernote

then at each 'Run' command it's %EnLoc%\ENScript...........
capeably
Posts: 47
Joined: 10 Jul 2014, 14:38

Re: Rainmeter-like Evernote/Search Widget (gui)

06 May 2016, 13:17

sttrebo wrote:one recommendation would be to add a variable for the location of ENScript.exe. For me, my Evernote is installed in another directory so I changed your script to add:

EnLoc = my location \Evernote

then at each 'Run' command it's %EnLoc%\ENScript...........
That's a good idea. I'll try to do that when I get a chance.
sttrebo
Posts: 68
Joined: 27 Jan 2014, 12:31

Re: Rainmeter-like Evernote/Search Widget (gui)

06 May 2016, 13:21

or use regread to find the path
User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Rainmeter-like Evernote/Search Widget (gui)

09 May 2016, 03:54

We I always think about why we don't have widget that work like rainmeter.... like we have ability to create simple bars with location and sizes .... We really need things like rainmeter purely coded in single ahk :)
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: kaka2, Rohwedder and 104 guests