Problemlösung bei 2.GUIs und Maus

  • Hallo:)

    ich programmiere für mich und meine Kollegen ein Tool um effizienter mit unserer CAD-Software arbeiten zukönnen.
    Ich bin schon nah am Ziel aber ein paar Probleme habe ich noch:

    1: Ich habe 2 GUIs, auf dem Ersten ist ein Button um auf das 2. zu kommen. Und dieses öffnet sich auch, nur wenn ich das 2. GUI schliesse beendet sich mein ganzes Programm.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("NLT", 105, 116, 192, 133, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 9, 8, 91, 17)
    $Label2 = GUICtrlCreateLabel("Status: On/Off", 18, 32, 73, 17)
    $Button1 = GUICtrlCreateButton("Tastenbelegung", 5, 72, 83, 17)
    $Button2 = GUICtrlCreateButton("Hilfe", 5, 96, 83, 17)
    $Label3 = GUICtrlCreateLabel("v.0.4", 40, 48, 28, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Nova Lüftungstool Tastenbelegung", 540, 230, 666, 394)
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 152, 32, 133, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Tastenbelegung", 160, 64, 103, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Eckig: Kanal=a; Bogen=s; Übergang=ü; Übergang eckig>rund=p; T-Stück=t; Hosenstück=h", 56, 104, 449, 17)
    $Label4 = GUICtrlCreateLabel("Rund: Rohr=w; Bogen=r; T-Stück=e; Übergang=u", 56, 144, 456, 17)
    $Label5 = GUICtrlCreateLabel("Konstruktionshilfe: Linie=l; K-Linie=k; Verbinder=v; Messen=m; Draggen=d; Drehen=y; Spiegeln=g", 56, 184, 463, 17)
    $Label6 = GUICtrlCreateLabel("Textmodus=q; Beenden=Einfg", 144, 200, 371, 17)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_Show, $Form2)

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    Problem 2: Kann ich bei einer Funktion NUR die Maus deaktivieren? Habe nur einen Befehl gefunden um den Input einfach zu blocken.

    Hier mein Code, während der Ausführung der Funktion darf ich die Maus nicht groß bewegen sonst kommt der Falsche Befehl dabei raus...

    Spoiler anzeigen
    [autoit]

    Func kanal()
    HotKeySet("a")
    HotKeySet("k")
    Send("!u")
    ;send ("r")
    ;send ("{right}")
    Send("k")
    Send("{ENTER}")
    Send("k")
    HotKeySet("a", "kanal")
    HotKeySet("k", "klinie")
    EndFunc ;==>kanal

    [/autoit]

    Ich hoffe, jemand hat die passenden Tipps :)

    Grüße

    Stuuhl

    Einmal editiert, zuletzt von Stuuhl (23. Januar 2013 um 17:02)

  • Hoppla...mein Fehler ^^ Moment

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $Form1 = GUICreate("NLT", 105, 116, 192, 133, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 9, 8, 91, 17)
    $Label2 = GUICtrlCreateLabel("Status: On/Off", 18, 32, 73, 17)
    $Button1 = GUICtrlCreateButton("Tastenbelegung", 5, 72, 83, 17)
    $Button2 = GUICtrlCreateButton("Hilfe", 5, 96, 83, 17)
    $Label3 = GUICtrlCreateLabel("v.0.4", 40, 48, 28, 17)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    $Form2 = GUICreate("Nova Lüftungstool Tastenbelegung", 540, 230, 666, 394)
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 152, 32, 133, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Tastenbelegung", 160, 64, 103, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Eckig: Kanal=a; Bogen=s; Übergang=ü; Übergang eckig>rund=p; T-Stück=t; Hosenstück=h", 56, 104, 449, 17)
    $Label4 = GUICtrlCreateLabel("Rund: Rohr=w; Bogen=r; T-Stück=e; Übergang=u", 56, 144, 456, 17)
    $Label5 = GUICtrlCreateLabel("Konstruktionshilfe: Linie=l; K-Linie=k; Verbinder=v; Messen=m; Draggen=d; Drehen=y; Spiegeln=g", 56, 184, 463, 17)
    $Label6 = GUICtrlCreateLabel("Textmodus=q; Beenden=Einfg", 144, 200, 371, 17)
    GUISetState(@SW_HIDE)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg($Form1)
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_Show, $Form2)
    While 1
    $nMsg = GUIGetMsg($Form2)
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_Show, $Form1)
    ExitLoop
    EndSwitch
    WEnd
    EndSwitch
    WEnd

    [/autoit]

    Bild1: Ich beim debuggen

    2 Mal editiert, zuletzt von General Kaboom (22. Januar 2013 um 13:44)

  • Hi, ich habe dein Problem nicht so ganz verstanden, aber aus General Kaboom's #2 Post hab ich ein wenig interpretiert...
    Hilft dir ggf. Dieses Beispiel weiter?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    ConsoleWrite(@CRLF)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $hGUI1 = GUICreate('Beispiel #1', 120, 40)
    $idButton = GUICtrlCreateButton('*-Klick-*', 10, 10, 100, 20)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $hGUI2 = GUICreate('Beispiel #2', 120, 40)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $avMsg = GUIGetMsg(1)
    Switch $avMsg[0]
    Case $GUI_EVENT_CLOSE
    If $avMsg[1] = $hGUI1 Then
    ConsoleWrite('!> Exit' & @CRLF & @CRLF)
    Exit
    ElseIf $avMsg[1] = $hGUI2 Then
    ConsoleWrite('+> Show GUI #1' & @CRLF)
    GUISetState(@SW_HIDE, $hGUI2)
    GUISetState(@SW_SHOW, $hGUI1)
    EndIf
    Case $idButton
    ConsoleWrite('+> Show GUI #2' & @CRLF)
    GUISetState(@SW_HIDE, $hGUI1)
    GUISetState(@SW_SHOW, $hGUI2)
    EndSwitch
    WEnd

    [/autoit]

    €dit: Huch, hatte nicht gesehen das General Kaboom ein Spoiler im letzten Post hat :whistling:

    Einmal editiert, zuletzt von Yjuq (22. Januar 2013 um 14:01)

  • Also ich hab Make-a-Grafiks Lösung benutzt und nun funzt es:) Vielen Dank euch beiden.

    Nun noch der Befehl _MouseTrap... Gibt es die Möglichkeit den Curser an der aktuellen Position zu"frieren"?

    Grüße

    Stuuhl

    EDIT: Habs zuspät gesehn General trotzdem vielen Dank:)

  • Hallo Stuuhl

    Hier
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Array.au3>
    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $Cursor_x, $Cursor_y, $File
    Global $Date = @MDAY & '.' & @MON & '.' & @YEAR
    Global $Time = 'Time: ' & @HOUR & ':' & @MIN

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate('Maus Coords', 200, 80, -1, -1) ;Haupt Gui
    GUICtrlCreateLabel('x:', 10, 10, 10, 15)
    GUICtrlCreateLabel('y:', 10, 25, 10, 15)
    $Label_x = GUICtrlCreateLabel('0', 20, 10, 60, 14)
    $Label_y = GUICtrlCreateLabel('0', 20, 25, 60, 14)
    $Save = GUICtrlCreateButton('Speichern = F12', 10, 50, 180, 20) ;Zi8mlich nutzlos aber naja immerhin n Hinweis
    GUISetState(@SW_SHOW, $hGui)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Save
    _Save()
    EndSwitch
    Sleep(50)
    GUICtrlSetData($Label_x, MouseGetPos(0)) ;Gibt alle 0,05Secunden die X Possition vom Curser auf $Label_x über
    GUICtrlSetData($Label_y, MouseGetPos(1)) ;Gibt alle 0,05Secunden die Y Possition vom Curser auf $Label_y über
    $dll = DllOpen('user32.dll')
    If _IsPressed('7B', $dll) Then ;Wenn F12 Gedrückt wird dann
    _Save() ;Ruf Function _Save() auf
    _MouseTrap() ;Gibt die Maus wieder frei
    EndIf
    If _IsPressed('7A', $dll) Then ;Wenn F11 Gedrückt wird dann
    _MouseTrap(GUICtrlRead($Label_x), GUICtrlRead($Label_y), GUICtrlRead($Label_x) + 1, GUICtrlRead($Label_y) + 1) ;Fange Maus auf den Coord X & Y auf $Label_x / $Label_y und $Label_x +1(Pixel) / $Label_y +1(Pixel)
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Save()
    FileWrite('Maus_Pos_Protokol.txt', '---------------------' & @CRLF)
    FileWrite('Maus_Pos_Protokol.txt', $Date & @CRLF)
    FileWrite('Maus_Pos_Protokol.txt', '---------------------' & @CRLF)
    FileWrite('Maus_Pos_Protokol.txt', '=====================' & @CRLF)
    FileWrite('Maus_Pos_Protokol.txt', $Time & 'x: ' & GUICtrlRead($Label_x) & @CRLF)
    FileWrite('Maus_Pos_Protokol.txt', $Time & 'y: ' & GUICtrlRead($Label_y) & @CRLF)
    FileWrite('Maus_Pos_Protokol.txt', '=====================' & @CRLF)
    EndFunc ;==>_Save

    [/autoit]

    Hab ich Ihrwan mal gemacht, alls ich nochnichts von

    [autoit]

    ControlClick

    [/autoit]


    wusste :D und für dich geupdated (_MouseTrap Hinzugefügt)
    Mit
    F12 = Läst deine maus wieder Frei und Erstellt ein Protokol eintrag, welcher sich dort befinden wird wo das Script / .exe ist.
    F11 = _MousTrap (Fängt deine Maus auf der Cursor Possition)


    ** Ich bin nicht dafür verantwortlich was mit dem Tool gemacht wird.
    Greez

    *Edit:
    1: -Mann diese Schreibfehler ._.
    2: -Habs noch Kommentare dazu Geschrieben

    4 Mal editiert, zuletzt von Skilkor (23. Januar 2013 um 01:08)

  • Vielen Dank!:)
    Habs eingebaut, funktioniert auch nur ist jetzt der MouseTrap Befehl nur auf die Postion die ich beim Starten mit der Maus hab beschränkt.
    Kann ich das leistungssparend umsetzen das er dauert die aktuelle Mausposition übernimmt?

    Im Moment istes so:

    [autoit]

    Global $Cursor_x = MouseGetPos(0)
    Global $Cursor_y = MouseGetPos(1)

    [/autoit]
    Spoiler anzeigen
    [autoit]

    Func kanal()

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("a")
    HotKeySet("k")
    _MouseTrap($Cursor_x, $Cursor_y, $Cursor_x + 1, $Cursor_y + 1)
    Send("!u")
    ;send ("r")
    ;send ("{right}")
    Send("k")
    Send("{ENTER}")
    Send("k")
    HotKeySet("a", "kanal")
    HotKeySet("k", "klinie")
    _MouseTrap()

    EndFunc ;==>kanal

    [/autoit]

    Grüße
    Stuuhl

    • Offizieller Beitrag


    Das sollte man so auf gar keinen Fall verwenden. Gerade für solche Fälle gibt es ein Flag in der Funktion GuiGetMsg(), wie im Bsp. von Make-Grafik gezeigt.

  • Es funktioniert aber astrein :)

    Hat jemand ne Lösung für das _Mousetrap Problem?:)

    Grüße

    Stuuhl

  • Mein _MouseTrap Befehl funktioniert nur an dem Punkt wo der Cursor am Anfang des Programmes ist...
    Soll ja aber immer an aktueller Position sein...

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Array.au3>
    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("NLT", 105, 116, 192, 133, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 9, 8, 91, 17)
    $lblstatus = GUICtrlCreateLabel("Status: On", 18, 32, 73, 17)
    $Button1 = GUICtrlCreateButton("Tastenbelegung", 5, 72, 83, 17)
    $Button2 = GUICtrlCreateButton("Hilfe", 5, 96, 83, 17)
    $Label3 = GUICtrlCreateLabel("v.0.4", 40, 48, 28, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Nova Lüftungstool Tastenbelegung", 540, 230, 666, 394, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 152, 32, 133, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Tastenbelegung", 160, 64, 103, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Eckig: Kanal=a; Bogen=s; Übergang=ü; Übergang eckig>rund=p; T-Stück=t; Hosenstück=h", 56, 104, 449, 17)
    $Label4 = GUICtrlCreateLabel("Rund: Rohr=w; Bogen=r; T-Stück=e; Übergang=u", 56, 144, 456, 17)
    $Label5 = GUICtrlCreateLabel("Konstruktionshilfe: Linie=l; K-Linie=k; Verbinder=v; Messen=m; Draggen=d; Drehen=y; Spiegeln=g", 56, 184, 463, 17)
    $Label6 = GUICtrlCreateLabel("Textmodus=q; Beenden=Einfg", 144, 200, 371, 17)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form3 = GUICreate("Nova Lüftungstool Hilfe", 369, 146, 192, 114, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 48, 16, 133, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Hilfe", 48, 48, 31, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Programmierer E-Mail-Adresse: Daniel.Machner@t-online.de", 48, 80, 285, 17)
    $Label4 = GUICtrlCreateLabel("(c) by Daniel Machner", 48, 104, 108, 17)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    WinSetTrans($Form1, "", 200)
    Global $bPause
    Global $Cursor_x = MouseGetPos(0)
    Global $Cursor_y = MouseGetPos(1)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    HotKeySet("q", "pause")
    HotKeySet("{INS}", "ende")
    _HotKeys(1)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $avMsg = GUIGetMsg(1)
    Switch $avMsg[0]
    Case $GUI_EVENT_CLOSE
    If $avMsg[1] = $Form1 Then
    Exit
    ElseIf $avMsg[1] = $Form2 Then
    GUISetState(@SW_HIDE, $Form3)
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_SHOW, $Form1)
    ElseIf $avMsg[1] = $Form3 then
    GUISetState(@SW_HIDE, $Form3)
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_SHOW, $Form1)

    EndIf
    Case $Button1
    GUISetState(@SW_HIDE, $Form3)
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    Case $Button2
    GUISetState(@SW_SHOW, $Form3)
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    ;~ Sleep(50)
    ;~ GUICtrlSetData($Cursor_x, MouseGetPos(0)) ;Gibt alle 0,05Secunden die X Possition vom Curser auf $Label_x über
    ;~ GUICtrlSetData($Cursor_y, MouseGetPos(1))
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While
    Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////System

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _HotKeys($bState = False)
    If $bState Then
    HotKeySet("a", "kanal")
    HotKeySet("s", "bogen")
    HotKeySet("v", "verbinder")
    HotKeySet("w", "rohr")
    HotKeySet("ur", "urohr")
    HotKeySet("r", "rbogen")
    HotKeySet("l", "linie")
    HotKeySet("k", "klinie")
    HotKeySet("ü", "uegang")
    HotKeySet("e", "trund")
    HotKeySet("m", "messen")
    HotKeySet("t", "teckig")
    HotKeySet("p", "uegangeckigrund")


    HotKeySet("y", "drehen")
    HotKeySet("g", "spiegeln")
    HotKeySet("d", "draggen")


    Else
    HotKeySet("a")
    HotKeySet("s")
    HotKeySet("v")
    HotKeySet("w")
    HotKeySet("u")
    HotKeySet("r")
    HotKeySet("l")
    HotKeySet("k")
    HotKeySet("ü")
    HotKeySet("e")
    HotKeySet("m")
    HotKeySet("t")
    HotKeySet("p")

    HotKeySet("y")
    HotKeySet("g")
    HotKeySet("d")


    EndIf
    EndFunc ;==>_HotKeys

    [/autoit] [autoit][/autoit] [autoit]

    Func pause()
    If Not $bPause Then
    _HotKeys()
    GUICtrlSetData($Lblstatus,"Status: Off")
    Else
    _HotKeys(1)

    GUICtrlSetData($Lblstatus,"Status: On")
    EndIf
    $bPause = Not $bPause
    EndFunc ;==>pause

    [/autoit] [autoit][/autoit] [autoit]

    Func ende()
    Exit
    EndFunc ;==>ende

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////Kanal

    [/autoit] [autoit][/autoit] [autoit]

    Func kanal()

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("a")
    HotKeySet("k")
    _MouseTrap($Cursor_x, $Cursor_y);, $pos[0] + 1, $pos[1] + 1)
    Send("!u")
    ;send ("r")
    ;send ("{right}")
    Send("k")
    Send("{ENTER}")
    Send("k")
    HotKeySet("a", "kanal")
    HotKeySet("k", "klinie")
    _MouseTrap()

    EndFunc ;==>kanal

    [/autoit] [autoit][/autoit] [autoit]

    Func bogen()
    HotKeySet("k")
    _MouseTrap($Cursor_x, $Cursor_y);, $Cursor_x + 1, $Cursor_y + 1)
    Send("!u")
    Send("b")
    Send("b")
    Send("{ENTER}")
    Send("k")
    HotKeySet("k", "klinie")
    _MouseTrap()
    EndFunc ;==>bogen

    [/autoit] [autoit][/autoit] [autoit]

    Func uegang()
    HotKeySet("a")
    HotKeySet("k")
    HotKeySet("r")
    _MouseTrap($Cursor_x, $Cursor_y, $Cursor_x + 1, $Cursor_y + 1)
    Send("!u")
    Send("r")
    Send("{right}")
    Send("{DOWN}")
    Send("{DOWN}")
    Send("{DOWN}")
    Send("{DOWN}")
    Send("{ENTER}")
    Send("k")
    HotKeySet("a", "kanal")
    HotKeySet("k", "klinie")
    HotKeySet("r", "rbogen")
    _MouseTrap()
    EndFunc ;==>uegang

    Func uegangeckigrund()
    HotKeySet("r")
    HotKeySet("k")
    HotKeySet("ü")
    _MouseTrap($Cursor_x, $Cursor_y, $Cursor_x + 1, $Cursor_y + 1)
    send ("!u")
    send ("r")
    send ("{right}")
    send ("ü")
    send ("ü")
    send ("{ENTER}")
    send ("k")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    HotKeySet("ü", "uegang")
    _MouseTrap()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func teckig()
    HotKeySet("r")
    HotKeySet("t")
    HotKeySet("k")
    _MouseTrap($Cursor_x, $Cursor_y, $Cursor_x + 1, $Cursor_y + 1)
    Send("!u")
    Send("r")
    Send("{RIGHT}")
    Send("t")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("t", "teckig")
    HotKeySet("k", "klinie")
    _MouseTrap()
    EndFunc ;==>teckig

    [/autoit] [autoit][/autoit] [autoit]

    ;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////Rohr

    [/autoit] [autoit][/autoit] [autoit]

    Func rohr()
    HotKeySet("r")
    HotKeySet("k")
    Send("!u")
    Send("r")
    Send("r")
    Send("{RIGHT}")
    Send("{ENTER}")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    EndFunc ;==>rohr

    [/autoit] [autoit][/autoit] [autoit]

    Func rbogen()
    HotKeySet("r")
    HotKeySet("k")
    Send("!u")
    Send("r")
    Send("r")
    Send("{right}")
    Send("r")
    Send("{ENTER}")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    EndFunc ;==>rbogen

    [/autoit] [autoit][/autoit] [autoit]

    Func trund()
    HotKeySet("a")
    HotKeySet("r")
    HotKeySet("k")
    Send("!u")
    Send("r")
    Send("r")
    Send("{ENTER}")
    Send("a")
    Send("k")
    HotKeySet("a", "kanal")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    EndFunc ;==>trund

    [/autoit] [autoit][/autoit] [autoit]

    Func urohr()
    HotKeySet("r")
    HotKeySet("k")
    HotKeySet("ü")
    Send("!u")
    Send("r")
    Send("r")
    Send("{right}")
    Send("ü")
    Send("{ENTER}")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    HotKeySet("ü", "uegang")
    EndFunc ;==>urohr

    [/autoit] [autoit][/autoit] [autoit]

    ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////Konstruktionshilfen

    [/autoit] [autoit][/autoit] [autoit]

    Func linie()
    HotKeySet("l")
    Send("!+l")
    Send("l")
    Send("l")
    HotKeySet("l", "linie")
    EndFunc ;==>linie

    [/autoit] [autoit][/autoit] [autoit]

    Func klinie()
    HotKeySet("k")
    HotKeySet("l")
    Send("!+l")
    Send("l")
    Send("k")
    HotKeySet("k", "klinie")
    HotKeySet("l", "linie")
    EndFunc ;==>klinie

    [/autoit] [autoit][/autoit] [autoit]

    Func verbinder()
    HotKeySet("v")
    Send("!u")
    Send("v")
    Send("v")
    Send("v")
    Send("{ENTER}")
    HotKeySet("v", "verbinder")
    EndFunc ;==>verbinder

    [/autoit] [autoit][/autoit] [autoit]

    Func messen()
    Send("!m")
    EndFunc ;==>messen

    [/autoit] [autoit][/autoit] [autoit]

    Func drehen()
    send ("!y")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func spiegeln()
    send ("!x")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func draggen()
    send ("!d")
    EndFunc

    [/autoit]

    Bitte nicht über schlampige Programmierung meckern, ich bin noch nicht solange dabei und lerne von Funktion zu Funktion... :pinch:

    Grüße
    Stuuhl

  • Ehmm, die Mausposition IN der Funktion einfach neu setzen?
    Entschuldige wenn ich dir jetzt zu nahe trete, aber ein wenig mitdenken muss man schon...

    Also:
    Einfach die Koordinaten erneut in den Variablen bei Funktionsaufruf abspeichern.

  • Weill du die _MouseGetPos() nicht updatest.

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Array.au3>
    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("NLT", 105, 116, 192, 133, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 9, 8, 91, 17)
    $lblstatus = GUICtrlCreateLabel("Status: On", 18, 32, 73, 17)
    $Button1 = GUICtrlCreateButton("Tastenbelegung", 5, 72, 83, 17)
    $Button2 = GUICtrlCreateButton("Hilfe", 5, 96, 83, 17)
    $Label3 = GUICtrlCreateLabel("v.0.4", 40, 48, 28, 17)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    #region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("Nova Lüftungstool Tastenbelegung", 540, 230, 666, 394, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 152, 32, 133, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Tastenbelegung", 160, 64, 103, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Eckig: Kanal=a; Bogen=s; Übergang=ü; Übergang eckig>rund=p; T-Stück=t; Hosenstück=h", 56, 104, 449, 17)
    $Label4 = GUICtrlCreateLabel("Rund: Rohr=w; Bogen=r; T-Stück=e; Übergang=u", 56, 144, 456, 17)
    $Label5 = GUICtrlCreateLabel("Konstruktionshilfe: Linie=l; K-Linie=k; Verbinder=v; Messen=m; Draggen=d; Drehen=y; Spiegeln=g", 56, 184, 463, 17)
    $Label6 = GUICtrlCreateLabel("Textmodus=q; Beenden=Einfg", 144, 200, 371, 17)
    GUISetState(@SW_HIDE)
    #endregion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    #region ### START Koda GUI section ### Form=
    $Form3 = GUICreate("Nova Lüftungstool Hilfe", 369, 146, 192, 114, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Nova Lüftungstool", 48, 16, 133, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Hilfe", 48, 48, 31, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Programmierer E-Mail-Adresse: Daniel.Machner@t-online.de", 48, 80, 285, 17)
    $Label4 = GUICtrlCreateLabel("(c) by Daniel Machner", 48, 104, 108, 17)
    GUISetState(@SW_HIDE)
    #endregion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    WinSetTrans($Form1, "", 200)
    Global $bPause

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    HotKeySet("q", "pause")
    HotKeySet("{INS}", "ende")
    _HotKeys(1)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $avMsg = GUIGetMsg(1)
    Switch $avMsg[0]
    Case $GUI_EVENT_CLOSE
    If $avMsg[1] = $Form1 Then
    Exit
    ElseIf $avMsg[1] = $Form2 Then
    GUISetState(@SW_HIDE, $Form3)
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_SHOW, $Form1)
    ElseIf $avMsg[1] = $Form3 Then
    GUISetState(@SW_HIDE, $Form3)
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_SHOW, $Form1)

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Case $Button1
    GUISetState(@SW_HIDE, $Form3)
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    Case $Button2
    GUISetState(@SW_SHOW, $Form3)
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    Global $Cursor_x = MouseGetPos(0)
    Global $Cursor_y = MouseGetPos(1)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////System

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _HotKeys($bState = False)
    If $bState Then
    HotKeySet("a", "kanal")
    HotKeySet("s", "bogen")
    HotKeySet("v", "verbinder")
    HotKeySet("w", "rohr")
    HotKeySet("ur", "urohr")
    HotKeySet("r", "rbogen")
    HotKeySet("l", "linie")
    HotKeySet("k", "klinie")
    HotKeySet("ü", "uegang")
    HotKeySet("e", "trund")
    HotKeySet("m", "messen")
    HotKeySet("t", "teckig")
    HotKeySet("p", "uegangeckigrund")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    HotKeySet("y", "drehen")
    HotKeySet("g", "spiegeln")
    HotKeySet("d", "draggen")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Else
    HotKeySet("a")
    HotKeySet("s")
    HotKeySet("v")
    HotKeySet("w")
    HotKeySet("u")
    HotKeySet("r")
    HotKeySet("l")
    HotKeySet("k")
    HotKeySet("ü")
    HotKeySet("e")
    HotKeySet("m")
    HotKeySet("t")
    HotKeySet("p")

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("y")
    HotKeySet("g")
    HotKeySet("d")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndIf
    EndFunc ;==>_HotKeys

    [/autoit] [autoit][/autoit] [autoit]

    Func pause()
    If Not $bPause Then
    _HotKeys()
    GUICtrlSetData($lblstatus, "Status: Off")
    Else
    _HotKeys(1)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($lblstatus, "Status: On")
    EndIf
    $bPause = Not $bPause
    EndFunc ;==>pause

    [/autoit] [autoit][/autoit] [autoit]

    Func ende()
    Exit
    EndFunc ;==>ende

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////Kanal

    [/autoit] [autoit][/autoit] [autoit]

    Func kanal()

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("a")
    HotKeySet("k")
    _MouseTrap($Cursor_x, $Cursor_y);, $pos[0] + 1, $pos[1] + 1)
    Send("!u")
    ;send ("r")
    ;send ("{right}")
    Send("k")
    Send("{ENTER}")
    Send("k")
    HotKeySet("a", "kanal")
    HotKeySet("k", "klinie")
    _MouseTrap()

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>kanal

    [/autoit] [autoit][/autoit] [autoit]

    Func bogen()
    HotKeySet("k")
    _MouseTrap($Cursor_x, $Cursor_y);, $Cursor_x + 1, $Cursor_y + 1)
    Send("!u")
    Send("b")
    Send("b")
    Send("{ENTER}")
    Send("k")
    HotKeySet("k", "klinie")
    _MouseTrap()
    EndFunc ;==>bogen

    [/autoit] [autoit][/autoit] [autoit]

    Func uegang()
    HotKeySet("a")
    HotKeySet("k")
    HotKeySet("r")
    _MouseTrap($Cursor_x, $Cursor_y, $Cursor_x + 1, $Cursor_y + 1)
    Send("!u")
    Send("r")
    Send("{right}")
    Send("{DOWN}")
    Send("{DOWN}")
    Send("{DOWN}")
    Send("{DOWN}")
    Send("{ENTER}")
    Send("k")
    HotKeySet("a", "kanal")
    HotKeySet("k", "klinie")
    HotKeySet("r", "rbogen")
    _MouseTrap()
    EndFunc ;==>uegang

    [/autoit] [autoit][/autoit] [autoit]

    Func uegangeckigrund()
    HotKeySet("r")
    HotKeySet("k")
    HotKeySet("ü")
    _MouseTrap($Cursor_x, $Cursor_y, $Cursor_x + 1, $Cursor_y + 1)
    Send("!u")
    Send("r")
    Send("{right}")
    Send("ü")
    Send("ü")
    Send("{ENTER}")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    HotKeySet("ü", "uegang")
    _MouseTrap()
    EndFunc ;==>uegangeckigrund

    [/autoit] [autoit][/autoit] [autoit]

    Func teckig()
    HotKeySet("r")
    HotKeySet("t")
    HotKeySet("k")
    _MouseTrap($Cursor_x, $Cursor_y, $Cursor_x + 1, $Cursor_y + 1)
    Send("!u")
    Send("r")
    Send("{RIGHT}")
    Send("t")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("t", "teckig")
    HotKeySet("k", "klinie")
    _MouseTrap()
    EndFunc ;==>teckig

    [/autoit] [autoit][/autoit] [autoit]

    ;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////Rohr

    [/autoit] [autoit][/autoit] [autoit]

    Func rohr()
    HotKeySet("r")
    HotKeySet("k")
    Send("!u")
    Send("r")
    Send("r")
    Send("{RIGHT}")
    Send("{ENTER}")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    EndFunc ;==>rohr

    [/autoit] [autoit][/autoit] [autoit]

    Func rbogen()
    HotKeySet("r")
    HotKeySet("k")
    Send("!u")
    Send("r")
    Send("r")
    Send("{right}")
    Send("r")
    Send("{ENTER}")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    EndFunc ;==>rbogen

    [/autoit] [autoit][/autoit] [autoit]

    Func trund()
    HotKeySet("a")
    HotKeySet("r")
    HotKeySet("k")
    Send("!u")
    Send("r")
    Send("r")
    Send("{ENTER}")
    Send("a")
    Send("k")
    HotKeySet("a", "kanal")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    EndFunc ;==>trund

    [/autoit] [autoit][/autoit] [autoit]

    Func urohr()
    HotKeySet("r")
    HotKeySet("k")
    HotKeySet("ü")
    Send("!u")
    Send("r")
    Send("r")
    Send("{right}")
    Send("ü")
    Send("{ENTER}")
    Send("k")
    HotKeySet("r", "rbogen")
    HotKeySet("k", "klinie")
    HotKeySet("ü", "uegang")
    EndFunc ;==>urohr

    [/autoit] [autoit][/autoit] [autoit]

    ;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////Konstruktionshilfen

    [/autoit] [autoit][/autoit] [autoit]

    Func linie()
    HotKeySet("l")
    Send("!+l")
    Send("l")
    Send("l")
    HotKeySet("l", "linie")
    EndFunc ;==>linie

    [/autoit] [autoit][/autoit] [autoit]

    Func klinie()
    HotKeySet("k")
    HotKeySet("l")
    Send("!+l")
    Send("l")
    Send("k")
    HotKeySet("k", "klinie")
    HotKeySet("l", "linie")
    EndFunc ;==>klinie

    [/autoit] [autoit][/autoit] [autoit]

    Func verbinder()
    HotKeySet("v")
    Send("!u")
    Send("v")
    Send("v")
    Send("v")
    Send("{ENTER}")
    HotKeySet("v", "verbinder")
    EndFunc ;==>verbinder

    [/autoit] [autoit][/autoit] [autoit]

    Func messen()
    Send("!m")
    EndFunc ;==>messen

    [/autoit] [autoit][/autoit] [autoit]

    Func drehen()
    Send("!y")
    EndFunc ;==>drehen

    [/autoit] [autoit][/autoit] [autoit]

    Func spiegeln()
    Send("!x")
    EndFunc ;==>spiegeln

    [/autoit] [autoit][/autoit] [autoit]

    Func draggen()
    Send("!d")
    EndFunc ;==>draggen

    [/autoit]

    Ich kanns nicht wirklich "Austesten", aber so sollte es funktionieren....
    Falls es zu CPU Lastig, setz einfach ein Sleep(50) nach den Global $Cursor_y = MouseGetPos(1) auf Zeile 79, das bringt die GUIGetMsg() nicht durcheinander

    Greez