Sign in to follow this  
Followers 0
squallA

why i press hotkey -> dont run func ?

3 posts in this topic

I have been creat a GUI and a small script to test it :)

#Region --- CodeWizard generated code Start ---
GUICtrlSetFont("controlID", 10, 400, 0, "Verdana")
#EndRegion --- CodeWizard generated code End ---

; 1 Mar 2006 - squallA
;AutoShell - SROVN

;Visual
#include <GuiConstants.au3>
GUICreate("MyGUI", 392, 171, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetIcon(@SystemDir & "\mspaint.exe", 0)
$a = GUICtrlCreateMenuitem("About", GUICtrlCreateMenu("Info"))
$Input_1 = GUICtrlCreateInput("", 40, 30, 230, 70)
$Group_2 = GUICtrlCreateGroup("Noi dung", 30, 10, 250, 100)
$Label_3 = GUICtrlCreateLabel("Thoi gian rao", 40, 120, 70, 20)
$Input_4 = GUICtrlCreateInput("", 110, 120, 40, 20)
$Label_5 = GUICtrlCreateLabel("s", 160, 120, 20, 20)
$Checkbox_6 = GUICtrlCreateCheckbox("Tat ca", 300, 30, 50, 20)
$Checkbox_7 = GUICtrlCreateCheckbox("Nhom", 300, 60, 50, 20)
$Checkbox_8 = GUICtrlCreateCheckbox("Hoi", 300, 90, 40, 20)
$Checkbox_9 = GUICtrlCreateCheckbox("Lien minh", 300, 110, 70, 30)
$Button_10 = GUICtrlCreateButton("Start", 180, 120, 70, 20)

;Exit
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $a Then MsgBox(0, "About", "  Creat by squallA" & @CRLF & "www.updatesofts.com")
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

;in game
WinWaitActive("Untitled - Notepad", "")
HotKeySet("`", "power")
$on=-1
While 2
If $on=1 Then 
ControlSend("Untitled - Notepad","","Edit1","4",1)
ControlSend("Untitled - Notepad","","Edit1","5",1)
EndIf
Wend
;on/off
Func power()
$on=-$on
EndFunc

I dont know why : after i run this file, i open notepad, click anywhere then press "`", it doesn't type 4,5 :whistle: ! Who can explain for me ? Thanks

Share this post


Link to post
Share on other sites



#Region --- CodeWizard generated code Start ---
;GUICtrlSetFont("controlID", 10, 400, 0, "Verdana");THIS IS OUT OF PLACE, AND DOESN'T ACTUALLY HAVE A CONTROL ID
#EndRegion --- CodeWizard generated code End ---

HotKeySet("`", "power")
Global $on
; 1 Mar 2006 - squallA
;AutoShell - SROVN

;Visual
#include <GuiConstants.au3>
GUICreate("MyGUI", 392, 171, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetIcon(@SystemDir & "\mspaint.exe", 0)
$a = GUICtrlCreateMenuitem("About", GUICtrlCreateMenu("Info"))
$Input_1 = GUICtrlCreateInput("", 40, 30, 230, 70)
$Group_2 = GUICtrlCreateGroup("Noi dung", 30, 10, 250, 100)
$Label_3 = GUICtrlCreateLabel("Thoi gian rao", 40, 120, 70, 20)
$Input_4 = GUICtrlCreateInput("", 110, 120, 40, 20)
$Label_5 = GUICtrlCreateLabel("s", 160, 120, 20, 20)
$Checkbox_6 = GUICtrlCreateCheckbox("Tat ca", 300, 30, 50, 20)
$Checkbox_7 = GUICtrlCreateCheckbox("Nhom", 300, 60, 50, 20)
$Checkbox_8 = GUICtrlCreateCheckbox("Hoi", 300, 90, 40, 20)
$Checkbox_9 = GUICtrlCreateCheckbox("Lien minh", 300, 110, 70, 30)
$Button_10 = GUICtrlCreateButton("Start", 180, 120, 70, 20)

;Exit
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $a Then MsgBox(0, "About", "    Creat by squallA" & @CRLF & "www.updatesofts.com")
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
    EndSelect
    If $on And WinActive('Untitled - Notepad') Then
        ControlSend("Untitled - Notepad","","Edit1","4",1)
        ControlSend("Untitled - Notepad","","Edit1","5",1)
    EndIf
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

Func power()
    $on = Not $on
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

uhm, thank you very much ! you replied very fast ^^!

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