Jump to content

HotKeySet help.


CyNDeR
 Share

Recommended Posts

I'm trying to write a small script to aid me in using PixelChecksum in other scripts. What i want it to do is take the x/y positions and copy the strings into the clipboard. What i have so far is:

$left = MouseGetPos(0)
$top = MouseGetPos(1)
$right = MouseGetPos(0)
$bottom = MouseGetPos(1)
$sum = PixelChecksum($left, $top, $right, $bottom)
ClipPut(StringFormat("PixelChecksum(%d, %d, %d, %d) = %d", $left, $top, $right, $bottom, $sum))

I'm just not sure how to make it work with hotkeys. Like, when i press "6" it gets the value for $left, "7" for $top, etc..

My scripts: Random Painter

Link to comment
Share on other sites

well thats how not sure if its all 100% right i didnt check i might have a typo

hotkeyset("{NUMPAD6}", "Left")
hotkeyset("{NUMPAD7}", "Top")
hotkeyset("{NUMPAD8}", "Right")
hotkeyset("{NUMPAD9}", "Bottom")
hotkeyset("{NUMPAD0}", "Get")

Func Left()
$left = MouseGetPos(0)
EndFunc
Func Top()
$top = MouseGetPos(1)
EndFunc
Func Right()
$right = MouseGetPos(0)
EndFunc
Func Bottom()
$bottom = MouseGetPos(1)
EndFunc
Func Get()
$sum = PixelChecksum($left, $top, $right, $bottom)
ClipPut(StringFormat("PixelChecksum(%d, %d, %d, %d) = %d", $left, $top, $right, $bottom, $sum))
EndFunc
Link to comment
Share on other sites

Look at HotKeySet() in the helpfile.

Basically you script would look similar to this:

HotKeySet('^a', '_GetCoords')
HotKeySet('{ESC}', '_Exit')

While 1 
Sleep(2000)
WEnd

Func _GetCoords()
$left = MouseGetPos(0)
$top = MouseGetPos(1)
$right = MouseGetPos(0)
$bottom = MouseGetPos(1)
$sum = PixelChecksum($left, $top, $right, $bottom)
ClipPut(StringFormat("PixelChecksum(%d, %d, %d, %d) = %d", $left, $top, $right, $bottom, $sum))
EndFunc

Func _Exit()
Exit
EndFunc

EDIT: I guess narayanjr's code is more like what you asked for but what I wrote is probably more user friendly because you don't have to get the value for each position. Also, if you try using his code I think you'll need to declare $left, $top, $right and $bottom at the top

EDIT2: By the way, I choose Ctrl + a for my hotkey... not really sure why...

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Pieced it together with ideas from both of you, thank you! This will save me lots of time. <_< Final code is:

hotkeyset("{NUMPAD6}", "Left")
hotkeyset("{NUMPAD7}", "Top")
hotkeyset("{NUMPAD8}", "Right")
hotkeyset("{NUMPAD9}", "Bottom")
hotkeyset("{NUMPAD0}", "Get")

$left = MouseGetPos(0)
$top = MouseGetPos(1)
$right = MouseGetPos(0)
$bottom = MouseGetPos(1)
$sum = PixelChecksum($left, $top, $right, $bottom)
While 1
    Sleep(500)
WEnd
Func Left()
$left = MouseGetPos(0)
ToolTip("Got Left", 0, 0)
EndFunc
Func Top()
$top = MouseGetPos(1)
ToolTip("Got Top", 0, 0)
EndFunc
Func Right()
$right = MouseGetPos(0)
ToolTip("Got Right", 0, 0)
EndFunc
Func Bottom()
$bottom = MouseGetPos(1)
ToolTip("Got Bottom", 0, 0)
EndFunc
Func Get()
ClipPut(StringFormat("PixelChecksum(%d, %d, %d, %d) = %d", $left, $top, $right, $bottom, $sum))
ToolTip("Done!", 0, 0)
Sleep(3000)
Exit
EndFunc

My scripts: Random Painter

Link to comment
Share on other sites

Looking at you're code I think you're missing an update for $checkSum. If I didn't miss anything $sum is the same thing throughout the whole program.

Also, this you probably know this, but you don't need to exit your script if you want to reuse it a couple times. That would save you the trouble of restarting it to get a new PixelCheckSum().

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Looking at you're code I think you're missing an update for $checkSum. If I didn't miss anything $sum is the same thing throughout the whole program.

Also, this you probably know this, but you don't need to exit your script if you want to reuse it a couple times. That would save you the trouble of restarting it to get a new PixelCheckSum().

Yeah, i had found out it didnt work, and was trying to figure it out when i checked this post, lol. I didnt even think about it not quitting, its late, lol. Now the script works great, thanks to both of you.

HotKeySet("{NUMPAD6}", "Left")
HotKeySet("{NUMPAD7}", "Top")
HotKeySet("{NUMPAD8}", "Right")
HotKeySet("{NUMPAD9}", "Bottom")
HotKeySet("{NUMPAD0}", "Get")
$left = MouseGetPos(0)
$top = MouseGetPos(1)
$right = MouseGetPos(0)
$bottom = MouseGetPos(1)
$sum = PixelChecksum($left, $top, $right, $bottom)
While 1
    Sleep(500)
WEnd
Func Left()
    $left = MouseGetPos(0)
    ToolTip("Got Left", 0, 0)
EndFunc   ;==>Left
Func Top()
    $top = MouseGetPos(1)
    ToolTip("Got Top", 0, 0)
EndFunc   ;==>Top
Func Right()
    $right = MouseGetPos(0)
    ToolTip("Got Right", 0, 0)
EndFunc   ;==>Right
Func Bottom()
    $bottom = MouseGetPos(1)
    ToolTip("Got Bottom", 0, 0)
EndFunc   ;==>Bottom
Func Get()
    $sum = PixelChecksum($left, $top, $right, $bottom)
    ClipPut(StringFormat("PixelChecksum(%d, %d, %d, %d) = %d", $left, $top, $right, $bottom, $sum))
    ToolTip("Done!", 0, 0)
    Sleep(3000)
EndFunc   ;==>Get

The only thing about it is i have to move the mouse out the way before i hit 0 or the checksum will be off. Maybe i'll do a MoveMouse() or something. <_<

My scripts: Random Painter

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...