AutoHotkey Community

It is currently May 26th, 2012, 9:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: April 23rd, 2005, 11:19 am 
Offline

Joined: November 3rd, 2004, 8:43 pm
Posts: 34
Hello all,

I have written a script which uses the spacebar to scroll down through articles in TreePad - very useful for presentations and reading ebooks.

When I reach the bottom of an article I need to have the hot key changed to send Ctrl+Alt+Down instead of PageDown. At the moment the only way I can see of detecting this is when the vertical scroll bar reaches the bottom of the window, but I don't know how to detect this condition.

Does anyone have any ideas?

Many thanks for all the help.

Regards,
Martin


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2005, 12:14 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Try PixelGetColor or PixelSearch.

By the way, I tried sending the SBM_GETPOS message to a window or control, but it doesn't retrieve its scrollbar position. It probably needs to be sent directly to the scroll bar, but I don't know how to retrieve a window's scroll bar ID(s).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2005, 8:20 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
To simplify matters, you could try just assigning it to a different hotkey, e.g. Ctrl+Space. That's what I would do, at least. You could also set up a timed routine which would send the alternate keys if you held it down long enough (if you're interested I'll show you how).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2005, 12:33 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Ultra has made good progress on DllCall, which when ready will allow a script to directly call the API function GetScrollPos() [Corrupt reminded me of this call]. That should be a good alternative to GetPixelColor.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2005, 5:38 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
I might note that this feature is already available in a workaround:

run,rundll32 <foo>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2005, 2:37 pm 
Offline

Joined: November 3rd, 2004, 8:43 pm
Posts: 34
Chris wrote:
Sat Apr 23, 2005 12:14 pm

Quote:
Try PixelGetColor or PixelSearch.


I assume that this means that I would see what pixel colour would be at the bottom of the scroll window when the scroll bar reaches this point. I will have to spend some time thinking this?

Many thanks Chris
Martin


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2005, 2:42 pm 
Offline

Joined: November 3rd, 2004, 8:43 pm
Posts: 34
jonny wrote:
To simplify matters, you could try just assigning it to a different hotkey, e.g. Ctrl+Space.


I already have the script set up to send PAgeDown when I press the space bar once and to send Ctrl+ALt+Down when the spacebar is pressed twice, but when you are standing during a presentation, it is not always easy to see whether I have reached the bottom of the article page or not and I often end up sending a triple press. It is just not as polished as PowerPoint of Opera where a single press will page down or move on to the next slide depending upon the position of the cursor.

I will have to spend some time looking at Chris's suggestion.

Many thanks for your help.
Martin


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2005, 5:18 pm 
Wouldn't a ControlGetPos - function combined with SetTimer do the thing ??? I doubt there isn't a max/min scrollbar position to go for :?:

Please enlighten me :wink:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2005, 5:48 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
BoBo wrote:
Wouldn't a ControlGetPos - function combined with SetTimer do the thing ??? I doubt there isn't a max/min scrollbar position to go for :?:

Please enlighten me :wink:


That would most likely just get the position of the top left corner of the entire scrollbar, but I haven't tested. Even if it got the slider itself, though, how would you tell when it was at the bottom?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2005, 10:16 pm 
AFAI've understand it, the page should be scrolled kinda "teleprompter"-style. Correct ???
Once a slider will have made it to its final/max position it wont change its (its topmost/left) position anymore, right !?!
Assumed the controls size won't be changed.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 18th, 2005, 4:02 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
There is finally a way to get the scroll bar position of a control that has a scroll bar (such as an Edit). Here is a working script that demonstrates this. It monitors the focused control in the active window and displays a tooltip to indicate the position of the vertical scroll bar (horizontal is also possible).
Code:
#Persistent
SetTimer, WatchScrollBar, 100
return

WatchScrollBar:
ActiveWindow := WinExist("A")
if not ActiveWindow  ; No active window.
   return
ControlGetFocus, FocusedControl, ahk_id %ActiveWindow%
if not FocusedControl
   return
; Display the vertical scroll bar's position in a ToolTip:
ChildHWND := GetChildHWND(ActiveWindow, FocusedControl)
;  Last param is 1 for SB_VERT, 0 for SB_HORZ:
Pos := DllCall("GetScrollPos", "UInt", ChildHWND, "Int", 1)
ToolTip %Pos%
return

GetChildHWND(ParentHWND, ChildClassNN)
{
   WinGetPos, ParentX, ParentY,,, ahk_id %ParentHWND%
   if ParentX =
      return  ; Parent window not found (possibly due to DetectHiddenWindows).
   ControlGetPos, ChildX, ChildY,,, %ChildClassNN%, ahk_id %ParentHWND%
   if ChildX =
      return  ; Child window not found, so return a blank value.
   ; Convert child coordinates -- which are relative to its parent's upper left
   ; corner -- to absolute/screen coordinates for use with WindowFromPoint().
   ; The following INTENTIONALLY passes too many args to the function because
   ; each arg is 32-bit, which allows the function to automatically combine
   ; them into one 64-bit arg (namely the POINT struct):
   return DllCall("WindowFromPoint", "int", ChildX + ParentX, "int", ChildY + ParentY)
}


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, fusion1920, MSN [Bot], poserpro, tomoe_uehara and 59 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