Jump to content

need help counting hotkey presses


Recommended Posts

I'm writing a script that uses the second example of the GUICTRLCREATEPIC function from the help file. The script as it is is working great, its meant to test the position of a box displayed in a window. What i need however is a way to count the hotkey (left, right, up, down) presses. The point of doing this is i'm trying to find out how far right and how far down the $pic has to travel to be in the right position. Therefore:

Right should be X position +1

Left should be X position -1

Down should be Y position +1

Up should be Y position -1

I will set the ENTER key to display a message box with the final result of X and Y

unfortunately i can think of a function that will count the presses for me (think my brain is overloaded from the gui concepts i've picked up today) can anyone help. Here is a snippet from my script:

if stringinstr($cmdlineraw, "debug") then
$gui=GUICreate("test transparentpic", 96, 96, 0+$offsetx, 60+$offsety)
$pic=GUICreate("", 96, 96, $offsetx-1, 39+$offsety,BitOr($WS_POPUP,$SS_GRAYFRAME),BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$handle)
GUICtrlCreatePic("debugbox.gif",0,0,0,0)

GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_HIDE,$gui)

HotKeySet("{ESC}", "main")
HotKeySet("{LEFT}", "left")
HotKeySet("{RIGHT}", "right")
HotKeySet("{DOWN}", "down")
HotKeySet("{UP}", "up")
HotKeySet("{ENTER}","enter")
$picPos = WinGetPos($pic)
$guiPos = WinGetPos($gui)

do
    $msg = GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE
Exit
ENDIF

Func left ()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0]-1,$picPos[1])
EndFunc

Func right()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0]+1,$picPos[1])
EndFunc

Func down()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0],$picPos[1]+1)
EndFunc

Func up()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0],$picPos[1]-1)
EndFunc
Edited by sonicxtacy02
Link to comment
Share on other sites

this seemd incorrect

$gui=GUICreate("test transparentpic", 96, 96, 0+$offsetx, 60+$offsety)

$pic=GUICreate("", 96, 96, $offsetx-1, 39+$offsety,BitOr($WS_POPUP,$SS_GRAYFRAME),BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$handle)

should it be $gui ?????

at the top you could globalize two variables

Global $Left, $top

then in the functions you could

Func up()
    $picPos = WinGetPos($pic)
$Top = $Top -1
    WinMove($pic,"",$picPos[0],$picPos[1]-1)
EndFunc

etc

8)

NEWHeader1.png

Link to comment
Share on other sites

this seemd incorrect

$gui=GUICreate("test transparentpic", 96, 96, 0+$offsetx, 60+$offsety)

$pic=GUICreate("", 96, 96, $offsetx-1, 39+$offsety,BitOr($WS_POPUP,$SS_GRAYFRAME),BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$handle)

should it be $gui ?????

at the top you could globalize two variables

Global $Left, $top

then in the functions you could

Func up()
    $picPos = WinGetPos($pic)
$Top = $Top -1
    WinMove($pic,"",$picPos[0],$picPos[1]-1)
EndFunc

etc

8)

Thank you that worked fine. And i want the $pic to work with $handle cause thats the program i need to find the location from. the script works fine as it stands.
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...