AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Work Break Timer, Task/Idea Logger, ScreenCapture - v. 3.00
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Thu Jan 24, 2008 12:39 am    Post subject: Re: A little help please? Reply with quote

kutay2005 wrote:
When the GUI shows up, I want to hit "Enter" button and rest.
I don't want to seek for OK button with mouse. Is it doable?

Hi kutay,
Not sure about setting the Enter key but I should be able to figure out a way to change the graphics so ALT-O "OK" does what you want. I'll put it on my todo for each of the graphic GUIs - Work, Break, End/Repeat.
_________________
Lars
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Thu Jan 24, 2008 7:02 am    Post subject: Reply with quote

HugoV wrote:
My first attempt at using RegRead.


This is good to know. Thanks again for sharing the code.
_________________
Lars
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Thu Jan 24, 2008 8:53 am    Post subject: Reply with quote

to allow enter to "ok" one of the alpha blended guis, just set somewhere else in the script:

Code:
~Enter::


and then in that hotkey, check which hwnd is visible, and then make it do the action that clicking ok would do in that situation, else if the alpha blended image is not present, just return from the hotkey.

ps..youve lopped off the bottom of the "g" on the guis now Wink
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Thu Jan 24, 2008 3:58 pm    Post subject: Reply with quote

tic wrote:
to allow enter to "ok" one of the alpha blended guis, just set somewhere else in the script:
Code:
~Enter::

and then in that hotkey, check which hwnd is visible, and then make it do the action that clicking ok would do in that situation, else if the alpha blended image is not present, just return from the hotkey.

Hmm, not quite sure how to check if hwnd is visible. Also, thought to do it for each of the graphic GUIs (work, break, exit/repeat). With the last, there are two hwnds (exit/repeat). I was thinking it would be best to redraw "buttons" with appropriate underline and assign ALT-E and ALT-R respectively. How would that work?


ps..youve lopped off the bottom of the "g" on the guis now Wink
Are you looking at the 2.81 alpha code? I made an error with earlier versions and backed out changes in 2.81.
_________________
Lars
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Thu Jan 24, 2008 4:32 pm    Post subject: Reply with quote

I think something like this, add the code just below the
hwnd := WinExist() line at the top of script. A quick test
with F12 as hotkey seems to work. I can test further tomorrow.

EDIT: function can't be at the top (if you read this earlier and it didn't
work)

Code:
Hotkey, F12, PressedOKHotkey


and this at the bottom of your script:

Code:
PressedOKHotkey:
IfWinExist, ahk_id %hwnd%
 {
 Gui, 2: Hide
  Working := !Working
  SetTimer, UpdateTray, 250
  Time1 := A_TickCount
 If !Working
  SetTimer, EndWorkBreak, % BreakTime*60*1000   ;%
 Else
  SetTimer, EndWorkBreak, % WorkTime*60*1000   ;%

Return


I tried to use controlclick, but I can't get that to work:

Code:

PressedOKHotkey:
IfWinExist, ahk_id %hwnd%
 {
CoordMode, mouse, relative
ControlClick, x135 y144, ahk_id %hwnd% ; xy of OK button
CoordMode, mouse, screen ; Return to default setting

Return
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Thu Jan 24, 2008 7:44 pm    Post subject: Reply with quote

Quote:
Hmm, not quite sure how to check if hwnd is visible


Code:
If DllCall("IsWindowVisible", "UInt", hwnd)


and then as HugoV said:

Code:
~Enter::
If !DllCall("IsWindowVisible", "UInt", hwnd)
Return
Gui, 2: Hide
Working := !Working, Time1 := A_TickCount
SetTimer, UpdateTray, 250
SetTimer, EndWorkBreak, % Working ? WorkTime*60*1000 : BreakTime*60*1000
Return
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Sat Jan 26, 2008 12:58 am    Post subject: Reply with quote

Thanks HugoV & tic,

I've placed tic's code at the bottom of script (line 1221). Here's a link.
http://www.autohotkey.net/~TotalBalance/Productivity%20Scripts/WB_Timer_282_alpha_v1.ahk
Work great for both the Work and Break GUIs. Thanks!

However, for the "Session Over" GUI, how do I hotkey for either "Exit" or "Repeat" (e.g. Alt-E, Alt-R). Presently, when I click Enter key, it defaults to "Repeat" but only repeats the "Session Over" GUI (The Work/Break GUIs don't show up anymore)?

P.S. HugoV, if you didn't catch it from the 1st post, tic pretty much wrote all the code for this app (unless there's something "broken" due no doubt to changes I made Embarassed ).
_________________
Lars
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Sat Jan 26, 2008 2:45 pm    Post subject: Reply with quote

I'm not quite I understand much of it either, but I think most of
the magic happens in WM_LBUTTONDOWN() with regards to which
'button' was pressed and what the action should be.

As far as I understand it, there is this list of images:
Code:
Images := "Background.png|WorkEnd.png|OK.png|BreakEnd.png|SessionEnd.png|Exit.png|Repeat.png"

OK is the third image, and if you look in the WM_LBUTTONDOWN()
you will see that if the mouseclick occurs within the dimensions
of image 3 the work/break routine is executed.

Exit is the 6th image, if you look in the same function
you will see a ExitApp is done

Repeat is the 7th image, again in the same function you will
see the restart, so my guess is (can't test at the moment)
the code for Exit & Repeat will be something like this:

Code:
~!E:: ; Exit
If !DllCall("IsWindowVisible", "UInt", hwnd) ; If gui is NOT visible return else ...
Return
ExitApp
Return

~!R:: ; Repeat
If !DllCall("IsWindowVisible", "UInt", hwnd) ; If gui is NOT visible return else ...
Return
End =
Gui, 2: Hide
GoSub, TrayStart
Return


Perhaps you could add user defined hotkeys or include the Winkey:
Because you can still continue to work / type while the
GUI is visible and Enter, Alt-E and Alt-R might be hotkeys
a user presses in his program while the GUI popups.
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Sat Jan 26, 2008 3:02 pm    Post subject: Reply with quote

im sorry for over complicating things with the alpha blended guis Embarassed
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Sat Jan 26, 2008 3:14 pm    Post subject: Reply with quote

Cheer up mate Wink

That's one of the things I like about this one, if it was a regular
GUI it would be in the way, e.g you are typing: the gui popups
without you noticing and you would "press" OK without knowing it
is time for your break Smile

And in general I like the fact AHK can be used by non-programmers
to make something quite usefull (for themselves or others), but that
doesn't mean the complicated stuff isn't very usefull too!
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Sat Jan 26, 2008 6:10 pm    Post subject: Reply with quote

HugoV wrote:
so my guess is (can't test at the moment)
the code for Exit & Repeat will be something like this:

Code:
~!E:: ; Exit
If !DllCall("IsWindowVisible", "UInt", hwnd) ; If gui is NOT visible return else ...
Return
ExitApp
Return

~!R:: ; Repeat
If !DllCall("IsWindowVisible", "UInt", hwnd) ; If gui is NOT visible return else ...
Return
End =
Gui, 2: Hide
GoSub, TrayStart
Return


Thanks HugoV. I'll test it out.
The biggest question I've got at the moment is how to differentiate between the work/break GUIs, which only have the OK button and the Session Over GUI, which doesn't have OK but does have Exit/Repeat buttons.

Correct me if wrong, but adding the above code will trigger corresponding actions, regardless of which GUI pops up. For example, if Alt-E is pressed while the "Back to Work" GUI with OK button pops up, the program will exit.

HugoV wrote:

Perhaps you could add user defined hotkeys or include the Winkey:
Because you can still continue to work / type while the
GUI is visible and Enter, Alt-E and Alt-R might be hotkeys
a user presses in his program while the GUI popups.

Agreed. Once above is worked out, I'll update the preferences to also allow user defined hotkeys for OK, Repeat, Exit. Of course, with the more user defined options added, the more I should think about learning how to use tic's Preferences GUI similar to what he's done with Amun
_________________
Lars
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Sat Jan 26, 2008 6:14 pm    Post subject: Reply with quote

tic wrote:
im sorry for over complicating things with the alpha blended guis Embarassed

Not at all, how else will I learn this stuff! Besides, if not for you, this app. would have been dead in the water long ago.
_________________
Lars
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 180
Location: CO, USA

PostPosted: Sat Jan 26, 2008 6:21 pm    Post subject: Reply with quote

HugoV wrote:

And in general I like the fact AHK can be used by non-programmers
to make something quite usefull (for themselves or others), but that
doesn't mean the complicated stuff isn't very usefull too!


Well said! While I always hope my script ideas will be useful to others, the fact, with the help of many others, AHK makes such things possible for non-programmers, like me, is absolutely awesome!
_________________
Lars
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Sun Jan 27, 2008 12:15 am    Post subject: Reply with quote

Again not quite sure, but looking at WM_MOUSEMOVE() there
is a way to figure out when the EXIT and REPEAT images are
shown, so if you add that as a condition in the hotkey section
after you check for the GUI that will probably solve it.
(can't test on this computer I'm afraid)

Code:
~!E::
If !DllCall("IsWindowVisible", "UInt", hwnd)
Return
   If End ; possibly If (End and !Working)
      ExitApp
Return

~!R::
If !DllCall("IsWindowVisible", "UInt", hwnd)
Return
If End  ; possibly If (End and !Working)
   {
   End =
   Gui, 2: Hide
   GoSub, TrayStart
   }
Return
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Sun Jan 27, 2008 9:20 am    Post subject: Reply with quote

It is probably even a lot easier now that I think about it, the exit & repeat
hotkeys only have to work when the RepeatTimes value has been reached, so something like this:

Code:
If (LoopTimes >= RepeatTimes*2)


Is a good way to check if the required action has to be executed (e.g. exitapp and restart)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 4 of 8

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group