Sign in to follow this  
Followers 0
itaypro121

Need help with While and IsPressed

9 posts in this topic

I have a problem relating my code, I have just started coding and I would like for someone here help me with one.

Well basically I need a while loop that everytime I press the key Alt(12) it will press the key x ( 58), So for example I press and hold alt it will press and hold x, I release the alt it releases the x kind of bind one key to another, I could not make it work :(, Please someone write me an example code for me to undertand..

Thanks in advance!

Share this post


Link to post
Share on other sites



Welcome to the AutoIt Forum itaypro121!

Can you show us what you have tried, along with what you are trying to automate with this?

Thanks,

MikahS 


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

While 1
    Sleep(10)
    If _IsPressed("12", $hDLL) Then
        Send("{58")
        Send("{58")
        Send("{58}")
    Else
        Send("{58}")
        Send("{58")
        Send("{58}")
    EndIf
WEnd

DllClose($hDLL)
Please help me make this do what I'm trying to - and again I'm trying to make an automode that makes one key press another and do the same actions I do with that key to other one, For example, If I press Alt I want it to press x, if I release alt I want it to release x,

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites

itaypro121,

When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

You're missing curly brackets on a couple of those send functions.

Also, any chance you could let us know what it is for, might give us a better idea of how to help you out. :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You're missing curly brackets on a couple of those send functions.

 

Also, any chance you could let us know what it is for, might give us a better idea of how to help you out.  :)

 

Oki, Well I have a program that does something when I press the bottum 'x' but 'x' is annoying to press! and 'x' cannot be changed! so I want to make a program that press the 'x' when I presss alt

 

This is the source code of the script with the 'x' but I cannot find a way to change the 'x' to alot

 

<snip>

Edited by Melba23
Code removed

Share this post


Link to post
Share on other sites

itaypro121,

Unfortunately you appear to have missed the >Forum rules on your way in. Please read them now (there is also a link at bottom right of each page) - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

See you soon with a legitimate question I hope. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0