modification script

johny12

Membre actif
10 Mars 2008
150
3
bonjour
j'aimerais que,svp, quelqu'un m'aide a comprendre le script que j'ai récupéré

quelques infos:

c'est un des script de l'application " sailling clicker"

(une appli qui qui sert a conecter son portable a l'ordinateur pour pouvoir le diriger via bluetooth)


j'aimerais surtout comprendre ou est la "commande" qui fait que si j'appuye sur la touche gauche ou 4 alors ca déplace la souris a gauche

Merci :)

le script:

property sIsHeld : false
property btnDown : false
property spd : 10
property scroll : 1
property scrollspeedup : 1
property zoom_mode : false
property the_model : ""
property the_class : ""

--- keymap

property keymap_map : {}

on get_keymap()
repeat with the_map in keymap_map
if a_model of the_map is the_model then return a_keymap of the_map
end repeat
if the_model is "P800" or the_model is "P900" then
set keymap_info to {leftMouseKeys:{"s" as Unicode text, "5" as Unicode text}, rightMouseKeys:{"0" as Unicode text, "f" as Unicode text, "*" as Unicode text}, upLeftKeys:{"1" as Unicode text}, upRightKeys:{"3" as Unicode text}, downLeftKeys:{"7" as Unicode text}, downRightKeys:{"9" as Unicode text}, leftKeys:{"<" as Unicode text, "4" as Unicode text}, rightKeys:{">" as Unicode text, "6" as Unicode text}, upKeys:{"2" as Unicode text}, downKeys:{"8" as Unicode text}, scrollUpKeys:{"^" as Unicode text}, scrollDownKeys:{"v" as Unicode text}, toggleScrollZoomKeys:{"c" as Unicode text}, screenShotKeys:{":c" as Unicode text}}
else if the_class is "PalmOSHandheld" then
set keymap_info to {leftMouseKeys:{":eek:" as Unicode text}, rightMouseKeys:{"f" as Unicode text, "*" as Unicode text}, upLeftKeys:{}, upRightKeys:{}, downLeftKeys:{}, downRightKeys:{}, leftKeys:{}, rightKeys:{}, upKeys:{}, downKeys:{}, scrollUpKeys:{"^" as Unicode text}, scrollDownKeys:{"v" as Unicode text}, toggleScrollZoomKeys:{"s" as Unicode text}, screenShotKeys:{}}
else
set keymap_info to {leftMouseKeys:{"s" as Unicode text, "5" as Unicode text}, rightMouseKeys:{"0" as Unicode text, "f" as Unicode text, "*" as Unicode text}, upLeftKeys:{"1" as Unicode text}, upRightKeys:{"3" as Unicode text}, downLeftKeys:{"7" as Unicode text}, downRightKeys:{"9" as Unicode text}, leftKeys:{"<" as Unicode text, "4" as Unicode text}, rightKeys:{">" as Unicode text, "6" as Unicode text}, upKeys:{"^" as Unicode text, "2" as Unicode text}, downKeys:{"v" as Unicode text, "8" as Unicode text}, scrollUpKeys:{"u" as Unicode text}, scrollDownKeys:{"d" as Unicode text}, toggleScrollZoomKeys:{"c" as Unicode text}, screenShotKeys:{":c" as Unicode text}}
end if
set new_entry to {a_model:the_model, a_keymap:keymap_info}
set keymap_map to keymap_map & {new_entry}
return keymap_info
end get_keymap

--- keymap descriptor record

property keymap_help_map : {}

on get_keymap_help()
repeat with the_map in keymap_help_map
if a_model of the_map is the_model then return a_keymap_help of the_map
end repeat
set the_keymap to my get_keymap()
set keymap_info to {¬
{key_code:upLeftKeys of the_keymap, key_title:"Move left/up", key_description:"Moves the mouse pointer left and up."}, ¬
{key_code:upRightKeys of the_keymap, key_title:"Move right/up", key_description:"Moves the mouse pointer right and up."}, ¬
{key_code:downLeftKeys of the_keymap, key_title:"Move left/down", key_description:"Moves the mouse pointer left and down."}, ¬
{key_code:downRightKeys of the_keymap, key_title:"Move right/down", key_description:"Moves the mouse pointer right and down."}, ¬
{key_code:leftKeys of the_keymap, key_title:"Move left", key_description:"Moves the mouse pointer left."}, ¬
{key_code:rightKeys of the_keymap, key_title:"Move right", key_description:"Moves the mouse pointer right."}, ¬
{key_code:downKeys of the_keymap, key_title:"Move down", key_description:"Moves the mouse pointer towards the bottom."}, ¬
{key_code:upKeys of the_keymap, key_title:"Move up", key_description:"Moves the mouse pointer towards the top."}, ¬
{key_code:leftMouseKeys of the_keymap, key_title:"Click/Drag", key_description:"Clicks the mouse button. Hold to grab/hold the mouse button; click again to release."}, ¬
{key_code:rightMouseKeys of the_keymap, key_title:"Ctrl-click", key_description:"Clicks the mouse button. Hold to grab/hold the mouse button while holding ctrl; click again to release."}, ¬
{key_code:scrollUpKeys of the_keymap, key_title:"Scroll up", key_description:"Well. Scrolls up... in a document"}, ¬
{key_code:toggleScrollZoomKeys of the_keymap, key_title:"Toggles zoom/scroll", key_description:"Selects whether to zoom or scroll."}, ¬
{key_code:screenShotKeys of the_keymap, key_title:"Screen capture", key_description:"Takes a screen shot of the Mac display."}, ¬
{key_code:scrollDownKeys of the_keymap, key_title:"Scroll down", key_description:"Well. Scrolls down... in a document."} ¬
}
set new_entry to {a_model:the_model, a_keymap_help:keymap_info}
set keymap_help_map to keymap_help_map & {new_entry}
return keymap_info
end get_keymap_help


tell application "SEC Helper"
set the_model to model of current terminal
set the_class to deviceclass of current terminal

if supports pen of current terminal then
set the_class to deviceclass of current terminal
if the_class is "PalmOSHandheld" then
enter keypad mode text "Mouse Control" & return & "(use the blank area like you'd use a trackpad; use up/down to scroll)" with pen deltas
else
enter keypad mode text "Mouse Control" & return & "(use the blank area like you'd use a trackpad, or use your handheld's directional control to move the mouse)" with pen deltas
end if
else
enter keypad mode text "Mouse Control" & return & "(# for help)"
end if
end tell


on keypad_was_dismissed()
tell application "SEC Helper"
simulate mouse button up number 1
simulate mouse button up number 2
end tell
end keypad_was_dismissed

on showHelp()
tell application "SEC Helper"
set the_keymap_info to my get_keymap_help()
show keypad help keymap the_keymap_info title "Mouse Help"
end tell
end showHelp

on begin_hold()
tell application "SEC Helper"
show screen message "Grab"
set btnDown to true
simulate mouse button down number 1
if supports pen of current terminal then
push keypad text "Mouse Control" & return & "mouse button down" & return & "(tap pen to release)"
else
push keypad text "Mouse Control" & return & "mouse button down"
end if
end tell
end begin_hold

on end_hold()
tell application "SEC Helper"
show screen message "Release"
set btnDown to false
simulate mouse button up number 1
if supports pen of current terminal then
push keypad text "Mouse Control" & return & "(use the blank area like you'd use a trackpad, or use your handheld's directional control to move the mouse)"
else
push keypad text "Mouse Control" & return & "(# for help)"
end if
end tell
end end_hold

on key_was_depressed(keyCode)
-- try
set the_keymap to my get_keymap()

tell application "SEC Helper"
if keyCode is in leftKeys of the_keymap then
simulate mouse movement x -|scroll| y 0 speed spd
else if keyCode is in rightKeys of the_keymap then
simulate mouse movement x |scroll| y 0 speed spd
else if keyCode is in upKeys of the_keymap then
simulate mouse movement x 0 y -|scroll| speed spd
else if keyCode is in downKeys of the_keymap then
simulate mouse movement x 0 y |scroll| speed spd

else if keyCode is in upLeftKeys of the_keymap then
simulate mouse movement x -|scroll| y -|scroll| speed spd
else if keyCode is in upRightKeys of the_keymap then
simulate mouse movement x |scroll| y -|scroll| speed spd
else if keyCode is in downLeftKeys of the_keymap then
simulate mouse movement x -|scroll| y |scroll| speed spd
else if keyCode is in downRightKeys of the_keymap then
simulate mouse movement x |scroll| y |scroll| speed spd

else if keyCode is in leftMouseKeys of the_keymap then
simulate mouse button down number 1
set sIsHeld to false
else if keyCode is in rightMouseKeys of the_keymap then
simulate mouse button down number 2
simulate mouse button up number 2
else if keyCode is in scrollUpKeys of the_keymap then
if zoom_mode then
simulate keyboard virtual keycode 24 modifiers {"option", "command"}
else
simulate mouse scroll wheel steps 10
end if
else if keyCode is in scrollDownKeys of the_keymap then
if zoom_mode then
simulate keyboard virtual keycode 27 modifiers {"option", "command"}
else
simulate mouse scroll wheel steps -10
end if
else if keyCode is "#" or keyCode is ":help" then
my showHelp()
end if
end tell
-- on error
-- beep
-- end try
return true
end key_was_depressed

on key_was_released(keyCode)
set scroll to 1
-- try
set the_keymap to my get_keymap()

tell application "SEC Helper"
if keyCode is in toggleScrollZoomKeys of the_keymap then
my toggleScrollZoom()
else if keyCode is in screenShotKeys of the_keymap then
my capture_screen()
else if keyCode is in leftMouseKeys of the_keymap then
if sIsHeld is false then
if btnDown is true then
my end_hold()
end if
simulate mouse button up number 1
end if
else
simulate mouse stop
end if
end tell
-- on error
-- beep
-- end try
set sIsHeld to false
return true
end key_was_released

on key_is_repeating(keyCode)
-- try
set the_keymap to my get_keymap()

tell application "SEC Helper"
if keyCode is in leftKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x -|scroll| y 0 speed spd
else if keyCode is in rightKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x |scroll| y 0 speed spd
else if keyCode is in upKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x 0 y -|scroll| speed spd
else if keyCode is in downKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x 0 y |scroll| speed spd

else if keyCode is in upLeftKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x -|scroll| y -|scroll| speed spd
else if keyCode is in upRightKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x |scroll| y -|scroll| speed spd
else if keyCode is in downLeftKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x -|scroll| y |scroll| speed spd
else if keyCode is in downRightKeys of the_keymap then
set |scroll| to |scroll| + scrollspeedup
simulate mouse movement x |scroll| y |scroll| speed spd
end if

if (keyCode is in leftMouseKeys of the_keymap) and sIsHeld is false then
if btnDown is true then
my end_hold()
else
my begin_hold()
end if
end if

if keyCode is in scrollUpKeys of the_keymap then
if zoom_mode then
simulate keyboard virtual keycode 24 modifiers {"option", "command"}
else
simulate mouse scroll wheel steps 10
end if
else if keyCode is in scrollDownKeys of the_keymap then
if zoom_mode then
simulate keyboard virtual keycode 27 modifiers {"option", "command"}
else
simulate mouse scroll wheel steps -10
end if
end if
end tell
-- on error
-- beep
-- end try
set sIsHeld to true
end key_is_repeating

on toggleScrollZoom()
tell application "SEC Helper"
if zoom_mode then
show screen message "Scrolling"
set zoom_mode to false
else
show screen message "Zooming"
set zoom_mode to true
end if
end tell
end toggleScrollZoom

on accelerate_value(value)
if value > 8 or value < -8 then
set value to value * 4
else if value > 4 or value < -4 then
set value to value * 2
end if
return value
end accelerate_value

on pen_was_moved(x_delta, y_delta)
set x_delta to my accelerate_value(x_delta)
set y_delta to my accelerate_value(y_delta)

tell application "SEC Helper"
simulate mouse movement x x_delta y y_delta speed 0
end tell
end pen_was_moved

on pen_was_tapped()
tell application "SEC Helper"
if btnDown then
my end_hold()
else
simulate mouse button down number 1
simulate mouse button up number 1
end if
end tell
end pen_was_tapped

on pen_was_locked()
my begin_hold()
end pen_was_locked

on capture_screen()
set the destination_folder to (path to "pdoc")
set the destination_path to POSIX path of the destination_folder
try
repeat with i from 1 to 10000
set the file_name to ("screen" & (i as string) & ".pdf")
alias ((destination_folder as string) & file_name)
end repeat
on error
set the target_path to the destination_path & the file_name
end try

do shell script ("screencapture " & target_path)

set my_path to (POSIX file target_path)
set my_picture to read (alias my_path) as picture

tell application "SEC Helper"
if supports keypad images of current terminal then
--- If the terminal can't show pictures, immediately show the image on the Mac.
enter keypad mode text "Captured Screen:" & return & target_path image my_picture image size huge
else
show screen message "Saved at " & target_path duration 8.0
end if
end tell
end capture_screen