AutoHotkey Community

It is currently May 27th, 2012, 3:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: May 26th, 2010, 10:10 pm 
tank wrote:

in its most simplistic form
Code:
#InstallMouseHook
SetTimer,mouse,10
mouse:
   if !drag := GetKeyState("LButton", "P")
      ToolTip % "Mouse Up"
   Else ToolTip % "Holding down"
Return





How exactly would that integrate with SKAN's code snippet? Your code suggests that it would apply in general to clicking or dragging. But SKAN's code is specific to each image being dragged. In addition, I would need to seperate clicking on one of those images versus clicking on a blank area of the screen.

I need something that integrates on a per-image basis - I think.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2010, 11:10 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
and so your saying you have no imagination to try figure it out? why should we do it all for you then maybe someone else will i wont

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 27th, 2010, 1:21 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Trente wrote:
SKAN wrote:
How to enable Drag for a Static Control ?
http://www.autohotkey.com/forum/viewtopic.php?p=123732#123732


SKAN, I have a few questions for you about this wonderful snippet of code...

1. How can I distinguish between the drag action, and a click action? And since it seems that all dragable images would have the same action code, is there a way to reference the variable of whichever image was clicked?

2. If I drag an image passing completely over another one, there are no glitches. But if I let go of the drag while one image is on top of another, then as soon as I drag that top image away, it retains whatever portion of the bottom image it was covering. I have to click that top image a second time in order to clear that. Is there a way to fix that visual glitch?


Redrawing the control before & after drag fixes the visual glitch.. for the rest of your queries, the following code should answer:

Code:
Gui, Add, Picture, Icon vCalc gMPPS, calc.exe
Gui, Add, Picture, Icon vNotepad gMPPS, notepad.exe
Gui, Show, w400 h300, Click to Launch or Long-Click to Move
Return

MPPS: ; Mobile-Phone-Power-Switch, which provides dual functionality. A short-press of the
      ; Power button shows you a menu whereas a long-press would shut-off the Mobile phone
  TC:=A_TickCount, App:=A_GuiControl
  MouseGetPos,,,,sHwnd1, 2
  While LongClick := GetKeyState( "LButton","P" )
   If (A_TickCount-TC) > DllCall("GetDoubleClickTime")
    Break
  IfNotEqual,LongClick,1, GoTo, AppLaunch
ControlMove:
  MouseGetPos,,,,sHwnd2, 2
  IfNotEqual, sHwnd2, %sHwnd1%, Return
  SoundBeep 500
  Winset,Redraw,,ahk_id %sHwnd1%
  SendMessage, 0x112,0xF012,0,,ahk_id %sHwnd1% ; [ WM_SYSCOMMAND+SC_MOVE ]
  Winset,Redraw,,ahk_id %sHwnd1%
Return

AppLaunch:
 IfEqual,App,Notepad, Run,notepad.exe
 IfEqual,App,Calc,    Run,calc.exe
Return


Another - simpler way - for differentiating between click and click-drag is to use a modifier key:

Code:
Gui, Add, Picture, Icon vCalc gAppLaunch, calc.exe
Gui, Add, Picture, Icon vNotepad gAppLaunch, notepad.exe
Gui, Show, w400 h300, Click to Launch or Long-Click to Move
Return

AppLaunch:
 If GetKeyState( "Control","P" )
    GoTo, ControlMove
 App := A_GuiControl
 IfEqual,App,Notepad, Run,notepad.exe
 IfEqual,App,Calc,    Run,calc.exe
Return

ControlMove:
  MouseGetPos,,,,sHwnd, 2
  Winset,Redraw,,ahk_id %sHwnd%
  SendMessage, 0x112,0xF012,0,,ahk_id %sHwnd% ; [ WM_SYSCOMMAND+SC_MOVE ]
  Winset,Redraw,,ahk_id %sHwnd%
Return


Last edited by SKAN on May 27th, 2010, 2:14 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2010, 1:38 am 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
hrmm would this also fix the 'glitch'?
Code:
...
; http://msdn.microsoft.com/en-us/library/dd145167(v=VS.85).aspx
dllCall("UpdateWindow", UInt, sHwnd1)
...

Just wondering..

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2010, 5:02 am 
tank wrote:

and so your saying you have no imagination to try figure it out? why should we do it all for you then maybe someone else will i wont




It's not about imagination, it's about programming knowledge and skill. I'm not asking others to do my work for me, but if I'm having difficulty figuring out how something works, I ask for help.

In case it slipped past you, this part of the forum is for people asking for help. If this is your attitude when it comes to people less skilled than you, it might be best if you spent your time elsewhere.


Report this post
Top
  
Reply with quote  
PostPosted: May 27th, 2010, 5:06 am 
SKAN wrote:

Redrawing the control before & after drag fixes the visual glitch.. for the rest of your queries, the following code should answer:

Another - simpler way - for differentiating between click and click-drag is to use a modifier key:




Thank you, SKAN. That helped me to understand better.

If it's not possible to do a true drag vs click, then I think the second method works better for me since it's less awkward (not to mention faster) to use a modifier key than to wait for a long click.


Honestly, thank you for taking the time to enlighten me. :)


Report this post
Top
  
Reply with quote  
PostPosted: May 27th, 2010, 7:02 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Trente wrote:
not possible to do a true drag vs click


I did not tell that. I do not know your application.
Mine is Picture Puzzle where I use 'drag control' to swap picture tiles.
Try the following:

Code:
Gui, Add, Picture, Icon vCalc gAppLaunch, calc.exe
Gui, Add, Picture, Icon vNotepad gAppLaunch, notepad.exe
Gui, Show, w400 h300, Click to Launch or Long-Click to Move
Return

AppLaunch:
 App := A_GuiControl, Count := pX := pY := 0
 ; Scan for mouse movement while Left-Mouse-Button is down
 While GetKeyState( "LButton","P" ) {
   MouseGetPos,X,Y,,sHwnd, 2
   Count := ( X<>pX || Y<>pY ) ? Count+1 : Count, pX:=X, pY:=Y
   IfGreater, Count, 3, GoTo, ControlMove ; Movement detected.., Trigger Control Move
 }
 IfEqual,App,Notepad, Run,notepad.exe
 IfEqual,App,Calc,    Run,calc.exe
Return

ControlMove:
 MouseGetPos,,,,sHwnd, 2
 Winset,Redraw,,ahk_id %sHwnd%
 SendMessage, 0x112,0xF012,0,,ahk_id %sHwnd% ; [ WM_SYSCOMMAND+SC_MOVE ]
 Winset,Redraw,,ahk_id %sHwnd%
Return


Quote:
the second method works better for me since it's less awkward


Awkward? A Mobile-phone-switch is not awkward in a mobile phone :)..., again, I do not know your application. I was just experimenting possibilities.

Quote:
Honestly, thank you for taking the time to enlighten me. :)


Honestly, I am pleased when somebody finds 'help' in my post. Most of my replies in Ask-for-help do not attract a reply from the original poster. :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2010, 3:10 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Trente wrote:
In case it slipped past you, this part of the forum is for people asking for help.


Just to clarify Trente, the Scripts & Functions forum is NOT the forum for people asking for help. Ask for Help is the correct forum.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2010, 6:35 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Agreed!

This thread is way too important to be sullied with help requests.

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2010, 2:58 pm 
sinkfaze wrote:
Trente wrote:
In case it slipped past you, this part of the forum is for people asking for help.


Just to clarify Trente, the Scripts & Functions forum is NOT the forum for people asking for help. Ask for Help is the correct forum.


I realized that about two seconds after hitting "Submit", but it was too late. :)

My apologies. However, I still maintain that it was a poor attitude to have.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2010, 2:58 pm 
TLM wrote:
Agreed!

This thread is way too important to be sullied with help requests.


I understand. I'm moving this discussion to another thread.


Report this post
Top
  
Reply with quote  
PostPosted: May 28th, 2010, 3:00 pm 
SKAN wrote:
Trente wrote:
not possible to do a true drag vs click


I did not tell that. I do not know your application.



SKAN, let's continue this here:
http://www.autohotkey.com/forum/topic58614.html


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

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