AutoHotkey Community

It is currently May 25th, 2012, 11:01 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 145 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 10  Next
Author Message
 Post subject:
PostPosted: January 24th, 2008, 8:02 am 
Offline

Joined: January 22nd, 2007, 11:24 pm
Posts: 206
Location: CO, USA
HugoV wrote:
My first attempt at using RegRead.


This is good to know. Thanks again for sharing the code.

_________________
Lars


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 24th, 2008, 9:53 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
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:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 24th, 2008, 4:58 pm 
Offline

Joined: January 22nd, 2007, 11:24 pm
Posts: 206
Location: CO, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 24th, 2008, 5:32 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 24th, 2008, 8:44 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2008, 1:58 am 
Offline

Joined: January 22nd, 2007, 11:24 pm
Posts: 206
Location: CO, USA
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 :oops: ).

_________________
Lars


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2008, 3:45 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2008, 4:02 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
im sorry for over complicating things with the alpha blended guis :oops:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2008, 4:14 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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 :-)

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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2008, 7:10 pm 
Offline

Joined: January 22nd, 2007, 11:24 pm
Posts: 206
Location: CO, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2008, 7:14 pm 
Offline

Joined: January 22nd, 2007, 11:24 pm
Posts: 206
Location: CO, USA
tic wrote:
im sorry for over complicating things with the alpha blended guis :oops:

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2008, 7:21 pm 
Offline

Joined: January 22nd, 2007, 11:24 pm
Posts: 206
Location: CO, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2008, 1:15 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2008, 10:20 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2008, 9:50 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Ignore the post above, doesn't work (must be something with global v local vars or something I think) anyway, I've tested the code below and it works for me:

As hotkeys:

Code:
Hotkey, LWIN & Enter, HotkeyOK
Hotkey, LWIN & !E, HotkeyExit
Hotkey, LWIN & !R, HotkeyRepeat

And these labels:

Code:
HotkeyOK:
If !DllCall("IsWindowVisible", "UInt", hwnd)
Return
If !End
   {
   Gui, 2: Hide
   Working := !Working, Time1 := A_TickCount
   SetTimer, UpdateTray, 250
   SetTimer, EndWorkBreak, % Working ? WorkTime*60*1000 : BreakTime*60*1000
   }
Return

HotkeyExit:
If !DllCall("IsWindowVisible", "UInt", hwnd)
Return
;MsgBox Hello Exit
   If End
      ExitApp
Return

HotkeyRepeat:
If !DllCall("IsWindowVisible", "UInt", hwnd)
Return
;MsgBox Hello Repeat
If End
   {
   End =
   Gui, 2: Hide
   GoSub, TrayStart
   }
Return

The only problem that I have is that if I use a hotkey like F11 and press that while the OK/EXIT/REPEAT gui is visible it also sends the keypress to the active program (and I've mapped F11 in most of my programs).

But by using "exotic" keycombos like LWIN & Enter, LWIN & Alt-E, LWIN & Alt-R you can prevent that. Suggestions welcome on how to use a regular ENTER without interfering with the active program.

I tried:
Code:
Hotkey, ~Enter, HotkeyOK
but that didn't seem to do the trick for me.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 145 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 10  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 8 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