AutoHotkey Community

It is currently May 27th, 2012, 6:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Simple desktop pad
PostPosted: December 1st, 2005, 6:47 pm 
Offline

Joined: October 8th, 2005, 9:22 am
Posts: 29
Location: Sri Lanka
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"

Code:
;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


Last edited by Nuwan on December 4th, 2005, 4:22 pm, edited 10 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 1st, 2005, 8:59 pm 
Offline

Joined: November 28th, 2005, 4:34 pm
Posts: 10
Location: Michigan, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: GUI Move
PostPosted: December 2nd, 2005, 2:12 am 
Offline

Joined: October 8th, 2005, 9:22 am
Posts: 29
Location: Sri Lanka
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:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2005, 10:44 am 
Offline

Joined: February 7th, 2005, 11:11 am
Posts: 192
Location: Munich, Germany
Nice!

You wrote:
Code:
;================================================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:
Code:
;================================================Save
Save:
{
FormatTime, cfn,,yyyy_MM_dd
CurrentFileName = %cfn%.txt

Additionally there's a line with
Code:
    FileAppend, This is saved at:-  %H1%:%H2% on %D%-%M%-%Y%- - , %CurrentFileName%

Should be changed into:
Code:
    FormatTime, tsa,,HH:mm' on 'dd-MM-yyyy
    FileAppend, This is saved at:- %tsa%- - , %CurrentFileName%

_________________
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2005, 4:24 pm 
Offline

Joined: November 28th, 2005, 4:34 pm
Posts: 10
Location: Michigan, USA
Sweet, thanks Nuwan.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Creating New Note
PostPosted: December 3rd, 2005, 12:13 pm 
Offline

Joined: October 8th, 2005, 9:22 am
Posts: 29
Location: Sri Lanka
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2005, 7:35 pm 
Offline

Joined: November 28th, 2005, 4:34 pm
Posts: 10
Location: Michigan, USA
Cool, looks good. Thanks 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 7th, 2005, 10:58 am 
Offline

Joined: August 15th, 2005, 7:15 am
Posts: 107
Location: North Carolina
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Ask for help
PostPosted: December 7th, 2005, 11:30 am 
Offline

Joined: October 8th, 2005, 9:22 am
Posts: 29
Location: Sri Lanka
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
Code:
Gui, +resize +border

:(
but it not match with controls(Edit box)

Nuwan


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Exabot [Bot], Google Feedfetcher, JamixZol, Stigg, Yahoo [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group