 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
dwinar
Joined: 05 Sep 2009 Posts: 10
|
Posted: Mon Sep 07, 2009 12:59 pm Post subject: [Solved] Macro with programmable Hotkeys! Need help! |
|
|
Hi!
If someone could help me with macro I would be really grateful:
1) The point is to make macro that asks you to push any button, and remebers it, then it asks to click from 1 to 8 places on the screen.
2) And then the user should confirm his choices with other button.
3) Now after pushing another key the macro would "send {previously chosen key}" and automatically click in targeted points. And that action should be repeated every time the user pushes the macro key.
4) The reset of settings is easy it can just reload the script.
Thanks in advance.
with regards,
Dwinar
Last edited by dwinar on Tue Sep 08, 2009 10:20 am; edited 2 times in total |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5334 Location: San Diego, California
|
Posted: Tue Sep 08, 2009 7:44 am Post subject: |
|
|
Try this out, sorry for the lack of comments, not completely tested, comments welcome
Leef_me
| Code: | ;Try this out, sorry for the lack of comments
CoordMode, mouse, Screen
CoordMode, tooltip, Screen
count=-2
total=-3
return
#w::
if(count < -1)
{
Gui, Add, Text,, Press the 'any key' except {Enter} or {space} and then hit return`n Left-click up to 8 places, right-click to to provide less than 8 clicks
Gui, Add, Hotkey, vChosenHotkey ; push any button
Gui, Add, Button, Hidden Default, OK
count= -1
}
gui, show
return
$RBUTTON:: ; click right mouse to provide less than 8 clicks
if (count=total)
{
send {RBUTTON}
return
}
if (count<0)
{
send {RBUTTON}
return
}
if (count=0)
{
count=-1
send {RBUTTON}
return
}
;msgbox %count%!%total%
total:=count
goto almost_done
$LBUTTON::
if ((count<0) or (count=total))
{
send {LBUTTON}
return
}
count++
MouseGetPos, X%count%, Y%count%
;msgbox !%X1%!%Y1%!
;return
ToolTip, #%count%, X%count%, Y%count%, %count%
if (count<8)
return
almost_done:
MsgBox, 1, , key is %ChosenHotkey% and %count% locations are shown
IfMsgBox Ok
{
loop, %count%
{
ToolTip, , X%a_index%, Y%a_index%, %a_index%
}
total:=count
return
}
IfMsgBox Cancel
{
loop, %count%
{
ToolTip, , X%a_index%, Y%a_index%, %a_index%
}
count= -1
total=-3
return
}
return
#q::
if(count<1)
return
send %ChosenHotkey%
loop, %count%
{
mousemove, x%a_index%, y%a_index%, 10
click
}
return
ButtonOK:
gui, submit
msgbox %ChosenHotkey%
count = 0
return |
|
|
| Back to top |
|
 |
dwinar
Joined: 05 Sep 2009 Posts: 10
|
Posted: Tue Sep 08, 2009 9:35 am Post subject: |
|
|
This is really cool! Thanks a lot
There is one small problem: the whole script blocks Left Mouse Button. I can click icons or something but it doesn't work in text editors or can't drag a box on my desktop.
Another question is it possible to make script remembers a hotkey without GUI? |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Tue Sep 08, 2009 9:40 am Post subject: |
|
|
Try it out yourself and show us your attempt. Then we will help you.
I think you dont want to use your own brain...?
| dwinar wrote: | This is really cool! Thanks a lot
There is one small problem: the whole script blocks Left Mouse Button. I can click icons or something but it doesn't work in text editors or can't drag a box on my desktop.
Another question is it possible to make script remembers a hotkey without GUI? |
|
|
| Back to top |
|
 |
dwinar
Joined: 05 Sep 2009 Posts: 10
|
Posted: Tue Sep 08, 2009 9:54 am Post subject: |
|
|
So... You insist that be unable to make something from nothing means not having a brain? Cool. Barely I managed to find "vChosenHotkey" command in AutoHotkey Manual and it regards ONLY GUI. I don't even mention web searching. Personally I have produced this:
| Code: |
CoordMode Mouse, Screen
#Esc::
ExitApp
return
; Mouse movement "recording" mode
F5::
recordbreaker := 0
MsgBox Mouse movement "recording" mode
loop 1
{
KeyWait LButton, D
if recordbreaker > 0
break
else
SoundPlay *-1
MouseGetPos xpos1, ypos1
Sleep 100
KeyWait LButton, D
if recordbreaker > 0
break
else
SoundPlay *-1
MouseGetPos xpos2, ypos2
Sleep 100
KeyWait LButton, D
if recordbreaker > 0
break
else
SoundPlay *-1
MouseGetPos xpos3, ypos3
Sleep 100
MsgBox Recording ended
}
return
; Stop recording
F6::
recordbreaker := 1
MsgBox You have ended "recording" earlier
return
; Perform "recorded" action
F7::
MouseMove %xpos1%, %ypos1%
Sleep 100
MouseMove %xpos2%, %ypos2%
Sleep 100
MouseMove %xpos3%, %ypos3%
Sleep 100
return
; Reset of settings
#F5::
Reload
return
|
All I need for now is to know: how to "record" keys or is it even possible without GUI. Thanks for understanding. |
|
| Back to top |
|
 |
AnttiV
Joined: 14 Aug 2009 Posts: 237 Location: Finland
|
Posted: Tue Sep 08, 2009 9:57 am Post subject: |
|
|
| well, you could probably do it with GetKeyState, but I think it would require much more work than using a GUI. But looping GetKeyState by all possible keys and recording which of those keys' states were D... maybe. I'd prefer a GUI. |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Tue Sep 08, 2009 10:00 am Post subject: |
|
|
| edit: didnt look at the code -> wrong post |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Tue Sep 08, 2009 10:05 am Post subject: |
|
|
| Without Gui you could use the command Input |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Tue Sep 08, 2009 10:07 am Post subject: |
|
|
Like this:
| Code: |
Input,out,L1
MsgBox %Out%
|
|
|
| Back to top |
|
 |
dwinar
Joined: 05 Sep 2009 Posts: 10
|
Posted: Tue Sep 08, 2009 10:17 am Post subject: |
|
|
| AnttiV wrote: | | well, you could probably do it with GetKeyState, but I think it would require much more work than using a GUI. But looping GetKeyState by all possible keys and recording which of those keys' states were D... maybe. I'd prefer a GUI. |
You're right, it would...
But this is what I wanted to know:
| aaffe wrote: | Like this:
| Code: |
Input,out,L1
MsgBox %Out%
|
|
Thanks to all for the support
Now I know both methods with GUI and without That's a really good base for me to learn more about AHK.
with regards,
Dwinar |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|