Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Simple desktop pad


  • Please log in to reply
8 replies to this topic
Nuwan
  • Members
  • 32 posts
  • Last active: Jun 24 2015 04:46 AM
  • Joined: 08 Oct 2005
Hai

Here is my simple desktop pad - Totally GUI basis

To save and enter simple notes / contact details / phone numbers

I think this is very easy than Note pad.

GUI Move (Win+Arrow keys)
Numbering system with "Numpad Enter"

;2005-12-01  Nuwan :Simple desktop pad-Test 
;----------------------------------------------------------------------------- 
;Saving folder is HOMEPATH (Place where the compiled exe file located) 
;----------------------------------------------------------------------------- 
;================================================Variables 
R1=200 
R2=400 
R3=185 
R4=147 
N=0 
P=0 
Q=0
A=1
B=0
;================================================GUI 
Gui, font, cBlack 
Gui, Add, edit,vMainEdit x200 y400 w185 h147 , 
Gui, font,, Times New Roman 
Gui, font, wBold s10 
Gui, Add, Button, x327 y546 w60 h30 gMess, Exit 
Gui, Add, Button, x266 y546 w60 h30 gOpt, Options 
Gui, Add, Button, x144 y546 w60 h30 gTrans, Trans 
Gui, Add, Button, x22 y515 w60 h30 gHeightA, Height + 
Gui, Add, Button, x83 y515 w60 h30 gWidthA, Width + 
Gui, Add, Button, x22 y546 w60 h30 gHeightD, Height  - 
Gui, Add, Button, x83 y546 w60 h30 gAppo, New 
Gui, Add, Button, x144 y515 w60 h30 gWidthD, Width  - 
Gui, Add, Button, x205 y546 w60 h30 gSave, Save 
Gui, Color,  C0C0C0 
Gui, +Lastfound 
WinSet, TransColor, C0C0C0 
Gui, -Caption  +ToolWindow 
Xp:= A_ScreenWidth - 400 
Yp:= A_ScreenHeight - 604 
Gui, Show,x%XP% y%Yp%, Desktop Pad 
Control, Hide,, Height +, 
Control, Hide,, Width +, 
Control, Hide,, Height  -, 
Control, Hide,, Width  -, 
Control, Hide,, New, 
Control, Hide,, Trans, 
WinSet, AlwaysOnTop, on, Desktop Pad
;================================================Numbering
NumpadEnter::
IfWinActive, Desktop Pad
{
	B:=B+1
	Send {Enter} %B%.{Space}
}
else
Send {Enter}
Return
;================================================WinMove 
#right:: 
   wingetpos x, y,,, Desktop Pad    
   x += 50            
   winmove, Desktop Pad,,%x%, %y%    
   return              
  
#left:: 
   wingetpos x, y,,, Desktop Pad 
   x -= 50 
   winmove, Desktop Pad,,%x%, %y% 
   return 

#Up:: 
   wingetpos x, y,,, Desktop Pad 
   y -= 50 
   winmove, Desktop Pad,,%x%, %y% 
   return 

#Down:: 
   wingetpos x, y,,, Desktop Pad 
   y += 50 
   winmove, Desktop Pad,,%x%, %y% 
   return 
;================================================Exit Message 

Mess: 
MsgBox ,4,,  Do you want to Save before exit ? 
IfMsgBox, No 
   ExitApp 
else 
   { 
   Gosub, Save 
   ExitApp 
   } 

Exit: 
GuiClose: 
ExitApp 

;================================================Dimensions 
HeightA: 
if R4>526
{
Gosub Fix 
}
else 
{ 
R2 -= 20 
R4 += 20 
Gosub Dimen 
Gosub Fix 
}
Return 

HeightD: 
if R4<20
{
Gosub Fix
}
else 
{ 
R2 += 20 
R4 -= 20 
Gosub Dimen 
Gosub Fix
}
Return 

WidthA: 
If R3=185 
{
R2 -= 30
}
if R3>364
{
Gosub Fix
}
else 
{ 
R1 -= 20 
R3 += 20 
Gosub Dimen
Gosub Fix 
}
Return 

WidthD: 
If R3=205 
{
R2 += 30
}
if R3<20
{
Gosub Fix
}
else 
{ 
R1 += 20 
R3 -= 20 
Gosub Dimen 
Gosub Fix 
} 
Return 

Dimen: 
ControlMove, %MainEdit%, %R1%, %R2%, %R3% ,%R4% 
Return
;================================================New Sheet
Appo:
if N<>0 
{ 
    GuiControlGet, MainEdit 
    FileDelete %CurrentFileName% - %A%.txt 
    if ErrorLevel <> 0 
    {    
   MsgBox The attempt to overwrite "%CurrentFileName% - %A%.txt" failed. 
   return 
    }  
    FileAppend, This is saved at:- %tsa%- - , %CurrentFileName% - %A%.txt 
    FileAppend, %MainEdit%, %CurrentFileName% - %A%.txt 
    FileAppend, %S%, %CurrentFileName% - %A%.txt 
} 
GuiControl, Focus, MainEdit 
Send, ^{HOME}^+{END}{DELETE} 
N=0
B=0
A += 1
Return 
;================================================GUI Button Show/Hide 
opt: 
Gosub Fix
if Q=0 
{ 
If R2+R4=547 and If R3>185 
{
R2 -= 30
Gosub Dimen
}
Control, Show,, Trans, 
Control, Show,, New, 
Control, Show,, Width  -, 
Control, Show,, Height  -, 
Control, Show,, Width +, 
Control, Show,, Height +, 
Q=1 
return 
} 
 
if Q=1 
{ 
If R2+R4=517 and If R3>185
{
R2 += 30
Gosub Dimen
}
Control, Hide,, Height +, 
Control, Hide,, Width +, 
Control, Hide,, Height  -, 
Control, Hide,, Width  -, 
Control, Hide,, New, 
Control, Hide,, Trans, 
Q=0 
} 
return 
;================================================Transparent 
Trans: 
Gosub Fix
if P=0 
{ 
P=1 
Gui, Color,  White 
WinSet, TransColor, White 
return  
} 

if P=1 
{ 
P=0 
Gui, Color, C0C0C0 
WinSet, TransColor, C0C0C0 
} 
return 
;================================================Save 
Save: 
{ 
FormatTime, cfn,,yyyy_MM_dd
FormatTime, tsa,,HH:mm' on 'dd-MM-yyyy 
CurrentFileName = %cfn%
if N=0 
{ 
GuiControl, Focus, MainEdit 
;------------------------------------Write Begin 
Send, ^{HOME}{ENTER} 
Send, ------------------------------------------------------ 
Send, {ENTER} 
Send, ^{END}{ENTER 3} 
Send, ------------------------------------------------------ 
Send, {ENTER}/ DesktopPad %A% \ -{SPACE}{UP 4}{END} 
;------------------------------------Write End 
IfExist  %CurrentFileName% - %A%.txt  
    { 
   FileRead , S,%CurrentFileName% - %A%.txt    
   GuiControlGet, MainEdit 
    FileDelete %CurrentFileName% - %A%.txt  
    if ErrorLevel <> 0 
       {    
   MsgBox The attempt to overwrite "%CurrentFileName% - %A%.txt " failed. 
   return 
       } 
    FileAppend, This is saved at:- %tsa%- - , %CurrentFileName% - %A%.txt 
    FileAppend, %MainEdit%, %CurrentFileName% - %A%.txt 
    FileAppend, %S%, %CurrentFileName% - %A%.txt 
MsgBox, Saved as %CurrentFileName% - %A%.txt 
    } 
Else 
    { 
   GuiControlGet, MainEdit 
   FileAppend, This is saved at:- %tsa%- - , %CurrentFileName% - %A%.txt  
   FileAppend, %MainEdit%, %CurrentFileName% - %A%.txt  
Msgbox, %CurrentFileName% - %A%.txt  Created 
    } 
} 
IfExist  %CurrentFileName% - %A%.txt  
if N<>0 
{ 
GuiControl, Focus, MainEdit 
Send, ^{END}{UP 4}{END} 
    GuiControlGet, MainEdit 
    FileDelete %CurrentFileName% - %A%.txt  
    if ErrorLevel <> 0 
    {    
   MsgBox The attempt to overwrite "%CurrentFileName% - %A%.txt " failed. 
   return 
    }  
    FileAppend, This is saved at:- %tsa%- - , %CurrentFileName% - %A%.txt  
    FileAppend, %MainEdit%, %CurrentFileName% - %A%.txt  
    FileAppend, %S%, %CurrentFileName% - %A%.txt  
MsgBox, Saved as %CurrentFileName% - %A%.txt 
} 
N += 1 
} 
return 
;================================================Cursor position
Fix:
if N=0
{
GuiControl, Focus, MainEdit 
Send, ^{END}
GuiControl, +Redraw, MainEdit
Return
}

if N<>0
{
GuiControl, Focus, MainEdit 
Send, ^{END}{UP 4}{END}
GuiControl, +Redraw, MainEdit
}
Return


And I like more suggestions and better implementations without bugs.
:wink:
Thanks
Nuwan

Rich
  • Members
  • 10 posts
  • Last active: Dec 24 2005 10:01 AM
  • Joined: 28 Nov 2005
Nice script Nuwan, though I recommend you clean up the gui and msgboxs a little bit. :wink:

I would also suggest making the the notepad movable, and you should integrate it more to the desktop (ie, not have the notepad always on top of the screen). Also, you might wanna add more options like creating a new note. Lastly, I could not figure out what the "Appoint" button does.

Good job though, I really like the idea and I'm sure other people might like this script too if they find themselves constantly opening notepad.

Nuwan
  • Members
  • 32 posts
  • Last active: Jun 24 2015 04:46 AM
  • Joined: 08 Oct 2005
Hai Rich..


Now you can GUI Move with " Win+Arrow" Keys

Try this :)

I think thisGUI better always keep (front)top of the screen, You can use transparent when see others. And you can move/select mouse through the Transparent GUI.

I still try to Appointments modification. And Numbering system.

Thanks for your valuable advise
Nuwan :roll:

kapege.de
  • Members
  • 192 posts
  • Last active: Jan 16 2012 12:34 PM
  • Joined: 07 Feb 2005
Nice!

You wrote:
;================================================Save 
Save: 
{ 
CN:=A_NOW 
Stringmid,Y,CN,1,4 
Stringmid,M,CN,5,2 
Stringmid,D,CN,7,2 
Stringmid,H1,CN,9,2 
Stringmid,H2,CN,11,2 
CurrentFileName = %D%_%M%_%Y%.txt 
It's more easy to use "FormatTime" instead of yours. And using the sort-order "Year, Month, Day" prevents every 1st of a month grouping together:
;================================================Save 
Save: 
{ 
FormatTime, cfn,,yyyy_MM_dd
CurrentFileName = %cfn%.txt
Additionally there's a line with
FileAppend, This is saved at:-  %H1%:%H2% on %D%-%M%-%Y%- - , %CurrentFileName% 
Should be changed into:
FormatTime, tsa,,HH:mm' on 'dd-MM-yyyy
    FileAppend, This is saved at:- %tsa%- - , %CurrentFileName% 

Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)

Rich
  • Members
  • 10 posts
  • Last active: Dec 24 2005 10:01 AM
  • Joined: 28 Nov 2005
Sweet, thanks Nuwan.

Nuwan
  • Members
  • 32 posts
  • Last active: Jun 24 2015 04:46 AM
  • Joined: 08 Oct 2005
Hai Rich..

I have added "New" button to save current pad and

Create new pad (Desktop pad 1,2,3....)
-------------------------------------------------------------------
Dear Peter,

Your Date modification working now.
Thanx / Merci

:D
Latest modifications are updated in first post

Nuwan

Rich
  • Members
  • 10 posts
  • Last active: Dec 24 2005 10:01 AM
  • Joined: 28 Nov 2005
Cool, looks good. Thanks 8)

Terrapin
  • Members
  • 107 posts
  • Last active: Feb 06 2007 03:38 PM
  • Joined: 15 Aug 2005
Nuwan, are you still working on this? It is obvious you're learning from it, and I would encourage you to develop it further. It really is kind of interesting to me, as a little utility that would always be available to jot down notes or paste something into.

I played around with your code some the other day. I changed it to make the actual window size the size of the edit control plus some buttons. That way, you can put in a button to toggle a resize border on and off, and the user could move or resize with the mouse. The thing I ran into and didn't do a lot of research into, was how to make the edit box resize smoothly along with the window. It was jerky.

Also, please trust I am not the world's greatest at coding style! But I think you could benefit from looking at code by some others. One thing you're not doing is paying attention to indentation rules. Indentation is very helpful in trying to read code. Also, I see some things which aren't done quite the best way, I won't write about them unless you ask for it though. :)

Very Best,

Bob
When it comes to Binary, there are 10 types of people. Those who get it and those who don't. :)

Nuwan
  • Members
  • 32 posts
  • Last active: Jun 24 2015 04:46 AM
  • Joined: 08 Oct 2005
Hai Bob....

I'm using Office2003 in my PC.

The begining GUI location and Size perfectly match on my Desktop(on office2003) to best position. That is why I suggest for original size.

And I like your help.. waiting for them with your modifications.and indentation rules.

I thaught of
Gui, +resize +border
:(
but it not match with controls(Edit box)

Nuwan