Sign in to follow this  
Followers 0
ljkkda

If Then

5 posts in this topic

hi

i cant get it to work...

so what i want is if i press the y key the message box with that right activate

and if i press n the message box with wrong sorry!

i know i can do that with hotkeys but i want to do that with this method is this possible?

if  "y"  then 
MsgBox(4096,"","Thats right") 
            
ElseIf "n" Then 
MsgBox(4096,"","Wrong sorry")   
            
EndIf

thx :D

Share this post


Link to post
Share on other sites



If you're dead-set on avoiding Hotkeys for something like this, you can use _IsPressed().

Adapted from the helpfile:

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250   )
    If _IsPressed("59", $dll) Then
          MsgBox(4096,"", "Thats right")
        ExitLoop
    ElseIf _IsPressed("4E", $dll) Then
          MsgBox(4096,"", "Wrong sorry")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

_IsPressed will use 100% of your CPU, stick with HotKeySet()

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

A MessageBox...

$answer = MsgBox(0x24, '', 'Choose yes or no')

If $answer = 6 Then
    ; Yes pressed
ElseIf $answer = 7 Then
    ; No was pressed
EndIf

Alt + y is for yes and Alt + n is for no. No hotkeys or ispressed needed.

:D

Edited by MHz

Share this post


Link to post
Share on other sites

thx @ Skruge

but it really use much of cpu i wonder about that...! can anyone tell why?

and thx @ MHz

that is a better way to do what i want :D

ljkkda

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