Jump to content
Sign in to follow this  
Crooksy211

set paste to f5 key

Recommended Posts

Crooksy211

hi guys, I set myself a task to write my friend a copy and paste script she could use with autoit on her mac. she has cerebral palsy and can not easily press the shortcut keys.

I've managed to get the copy selected text to work, however, I can't seem to be able to get the text to paste when she presses the f5 key, please can you help me?

thanks

script:

HotKeySet("{ESC}", "_Mouse_Exit_App")
 
Global $f_mouse_is_down = true
Global $i_mouse_primary = 0x01 ; 0x01 = left for primary, 0x02 = right
Global $h_mouse_mod, $h_mouse_timer
$h_mouse_timer = _Mouse_StartWatch($h_mouse_mod, "_Mouse_GetHighlight_ToClipboard", "int", "", 0, 10003, 10)
 
While 1
    Sleep(100000)
WEnd
 
Func _Mouse_GetHighlight_ToClipboard()
    If Not $f_mouse_is_down Then
        Local $a_getasync = DllCall("User32.dll", "int", "GetAsyncKeyState", "int", $i_mouse_primary)
        If Not @error And BitAND($a_getasync[0], 0x8000) = 0x8000 Then
            $f_mouse_is_down = True
            While Not @error And BitAND($a_getasync[0], 0x8000) = 0x8000
                Sleep(50)
                $a_getasync = DllCall("User32.dll", "int", "GetAsyncKeyState", "int", $i_mouse_primary)
            WEnd
            Send("^c")
            Sleep(100)
            $f_mouse_is_down = False
        EndIf
    EndIf
    Return
EndFunc
 
Func _Mouse_StartWatch(ByRef $h_mod, $s_func, $v_ret_type, $v_params, $h_wnd, $i_event_id, $i_event_time)
    $h_mod = DllCallbackRegister($s_func, $v_ret_type, $v_params)
    If @error Then Return SetError(@error, 1, 0)
    Local $h_timer = DllCall("User32.dll", "int", "SetTimer", _
                        "hwnd", $h_wnd, _
                        "uint", $i_event_id, _
                        "uint", $i_event_time, _
                        "ptr", DllCallbackGetPtr($h_mod))
    If @error Then Return SetError(@error, 2, 0)
    Return $h_timer[0]
EndFunc
 
Func _Mouse_StopWatch($h_mod, $h_timer, $h_wnd = 0)
    DllCallbackFree($h_mod)
    DllCall("User32.dll", "int", "KillTimer", "hwnd", $h_wnd, "int", $h_timer)
    If @error Then Return SetError(@error, 0, 0)
    Return 1
EndFunc
 
Func _Mouse_Exit_App()
 
    Sleep(100)
 
  If IsDeclared("h_mouse_mod") Then _Mouse_StopWatch($h_mouse_mod, $h_mouse_timer)
  Sleep (100)
    Exit
 EndFunc
 
 HotKeySet("{f9}", "paste")
HotKeySet("{esc}", "quit")
 
Func paste()
ClipPut(^V)
    Send(^v)
 
EndFunc  ;==>paste
 
Func quit()
    Exit
EndFunc  ;==>quit

Share this post


Link to post
Share on other sites
Crooksy211

when I googled it, it said this worked on a mac o.O

Share this post


Link to post
Share on other sites
Crooksy211

can you recommend a software that could get this to work please? I wrote it in AHK first and managed to get it to work on there, but again not mac compatible 

Just out of curiosity, since support for Mac, Linux, etc. is on the NOT ToDo list, how are you planning on getting this to work for your friend?

http://www.autoitscript.com/trac/autoit/wiki/AutoItNotOnToDoList

Share this post


Link to post
Share on other sites
JLogan3o13

My guess is you'd have to use something like AppleScript, although I have not supported Mac in a long time.

It is not surprising that AHK does not work either - AutoIt uses the WinAPI (which is why it works only on Windows). Any language, like AHK, that is a theft branch of the original is going to have the same constraints ;)


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Crooksy211

ok thanks :) Well I'm glad I managed to get the copy and paste to work on windows :) I'll still make her a collection of window short-cuts until i can get access to her mac as she has windows too (and I can use them too), but I think I'm going to stick with AHK it's easier to understand in my opinion, but maybe because i've used it for years, and only started to us autoit 

thanks for your help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×