Sign in to follow this  
Followers 0
miloOmelo

hotkeyset _IsPressed concern

3 posts in this topic

#1 ·  Posted (edited)

i want to press the Ins key or Numpad5 key and have it write on notepad two letters U and I (so it looks like this UI) at once and repeatedly even when not holding the hotkey , but it needs to stop when i press the hotkey again

so far i have succeded on making in write UIUIUIUIUIUIUIUIUI which is ok but it only works while i hold the Ins key

what i had in mind was make it start writing UIUIUIUIUIUI ..... .... without me holding the INS key down all the time , ok this can be done with a while loop like this 

while 1 

Send("{U up}")
Send("{I up}")
EndIf

but it needs to stop when the same hotkey is pressed again, so the same hot key that starts the thing has to make it stop

this is what i got so far

#include <Misc.au3>

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

HotKeySet("{INS}","Pressed")

Func Pressed()

Do
Send("{U down}")
Send("{I down}")

Until _IsPressed("2D", $hDLL)

; Send("{U up}")
; Send("{I up}")
EndFunc


While 1
Sleep(10)
If _IsPressed("2D", $hDLL) Then
Send("{U up}")
Send("{I up}")
EndIf
WEnd

a trick would be to have the first example and pause upause the script with a hotkey but that is not efficient and not so fast in speed

i searched lots of threads so far and help files with no success yet, eventhough the code might be very simple and i am missing the proper statements.

looking forward to your replys , regards

Edited by miloOmelo

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You mean something like this?

Global $vWrite
HotKeySet("{INS}", "ToggleWrite")

While 1
    Sleep(100)
Wend

Func ToggleWrite()
    WinActivate("Untitled - Notepad") ;~ or [CLASS:Notepad]

    $vWrite = Not $vWrite

    While $vWrite
        Sleep(100)
        Send("UI")
    WEnd

EndFunc
Edited by mrflibblehat

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

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  
Followers 0