|
You last visited: Today at 08:14
Advertisement
Hilfe bei hotkey und button funktion
Discussion on Hilfe bei hotkey und button funktion within the AutoIt forum part of the Coders Den category.
05/21/2020, 17:03
|
#1
|
elite*gold: 0
Join Date: Oct 2008
Posts: 116
Received Thanks: 94
|
Hilfe bei hotkey und button funktion
Hallo kann mir jemand helfen und mir vielleicht sagen wieso mein Script nicht funktioniert weder die Hotkeys noch die Buttons funktionieren
Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\user\desktop\form1.kxf
$Form1_1 = GUICreate("TEST TEXT", 220, 309, 316, 243)
$startb = GUICtrlCreateButton("Start", 40, 16, 139, 49)
GUICtrlSetOnEvent($startb,"_start")
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$******= GUICtrlCreateButton("Stop", 40, 80, 139, 49)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$exitb = GUICtrlCreateButton("Kill ME!", 40, 144, 139, 49)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("TEXT", 40, 208, 155, 17)
$Label2 = GUICtrlCreateLabel("TEXT", 40, 224, 79, 17)
$Label3 = GUICtrlCreateLabel("Up - Start", 40, 240, 47, 17)
$Label4 = GUICtrlCreateLabel("Down - Stop", 40, 256, 47, 17)
$Label5 = GUICtrlCreateLabel("ESC - Exit", 40, 272, 51, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $exitb
Exit
Case $startb
_start()
Case $******
_pause()
EndSwitch
WEnd
While 1
sleep(100)
WEnd
HotKeySet("{UP}","_start")
HotKeySet("{DOWN}","_pause")
HotKeySet("{ESC}","Exit")
Global $go = 0
While 1
if $go = 0 Then
Sleep (100)
Else
_move()
EndIf
WEnd
Func _start()
$go = 1
EndFunc
Func _pause()
$go = 0
EndFunc
Func _move()
While 1
MouseMove( 300, 300)
Sleep(2500)
MouseMove( 600, 300)
Sleep(2500)
WEnd
EndFunc
|
|
|
05/21/2020, 17:07
|
#2
|
elite*gold: 0
Join Date: Sep 2016
Posts: 451
Received Thanks: 76
|
Der Code zum setzen wird nie erreicht.
While 1
sleep(100)
Wend
ist eine Endlosschleife
|
|
|
05/21/2020, 18:27
|
#3
|
elite*gold: 0
Join Date: Oct 2008
Posts: 116
Received Thanks: 94
|
Quote:
Originally Posted by SyntaxBreaker
Der Code zum setzen wird nie erreicht.
While 1
sleep(100)
Wend
ist eine Endlosschleife
|
auch ohne die schleife funktioniert es nicht da stimmt was mit der GUI nicht
sobald ich die gui entferne funktioniert es
oder
wen ich die Buttons in der GUI die Funktion umschreibe von
Code:
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $exitb
_exit()
Case $startb
_start()
Case $pauseb
_pause()
EndSwitch
WEnd
Auf
Code:
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $exitb
_exit()
Case $startb
_move() ;so Startet es
Case $pauseb
_pause() ;funktioniert gar nicht while 1 sleep(100) wend bringt keine Änderung Auch ohne GUI keine Funktion
EndSwitch
WEnd
irgendwie wird Global $go = 0 nicht auf 1 gestellt oder es wird gestellt aber die funktion _move() wird nicht aktiviert
|
|
|
05/22/2020, 05:08
|
#4
|
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
|
Sir let me explain what a while loop is because i think you forgot.
So that means that while loops are bad and shouldn't be used?, of course not, but that is not the way that they should be used.
You can achive same result with only one loop and a bunch of ifs.
If you want your code more readable, then divide and conquer (split functionality in simple functions and call them inside your loop)
Lets forget about the gui for now
Ex:
But what about the gui, well... you can easily put it all together in one loop
Just give me the f****** code
And here is the final result:
Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\user\desktop\form1.kxf
$Form1_1 = GUICreate("TEST TEXT", 220, 309, 316, 243)
$startb = GUICtrlCreateButton("Start", 40, 16, 139, 49)
GUICtrlSetOnEvent($startb,"_start")
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$stopb = GUICtrlCreateButton("Stop", 40, 80, 139, 49)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$exitb = GUICtrlCreateButton("Kill ME!", 40, 144, 139, 49)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("TEXT", 40, 208, 155, 17)
$Label2 = GUICtrlCreateLabel("TEXT", 40, 224, 79, 17)
$Label3 = GUICtrlCreateLabel("Up - Start", 40, 240, 47, 17)
$Label4 = GUICtrlCreateLabel("Down - Stop", 40, 256, 47, 17)
$Label5 = GUICtrlCreateLabel("ESC - Exit", 40, 272, 51, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;should stay in top before any loop if not wont work
HotKeySet("{UP}","_start")
HotKeySet("{DOWN}","_pause")
HotKeySet("{ESC}","_exit")
Global $go = False
While 1
;is good practice parsing gui input first.
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $exitb
Exit
Case $startb
_start()
Case $stopb
_pause()
EndSwitch
if $go == True Then
Sleep (100)
Else
_move()
EndIf
WEnd
Func _exit()
Exit 0
EndFunc
Func _start()
$go = True
EndFunc
Func _pause()
$go = False
EndFunc
Func _move()
MouseMove( 300, 300)
Sleep(2500)
MouseMove( 600, 300)
Sleep(2500)
EndFunc
Edit: i messed up with the second image should be false on _pause, fixed in code anyway
|
|
|
 |
Similar Threads
|
★Hotkey Creator★ Create your own hotkey executing your preferred action
05/01/2015 - Coding Releases - 2 Replies
Deutsch
Ich möchte dir meinen Hotkey Creator v 1.0 vorstellen, mit welchem es möglich ist, eigene hotkeys zu definieren, die eine von dir ausgewählte Aktion ausführen.
Mögliche Aktionen:
- Webseite öffnen
- Programm oder Dokument ausführen
- Aktives Fenster verstecken
- Pfad öffnen
- Bildschirm sperren
|
[B] Push Button [S] 10 e*gold/Button; 25 e*g/psd+Button
09/20/2013 - elite*gold Trading - 4 Replies
Moin,
Hier könnt ihr folgenden Push Button kaufen:
http://i.epvpimg.com/YlrYe.jpg
Pro Button wären das 10e*g, pro Button mit .psd dazu 25e*g.
Wenn ihr einen Button kaufen wollt, schreibt mir eine PN, damit ich den Namen ändern kann, alles hochladen kann und euch dann per Treasure schicken kann. ;)
Schrift kann auch geändert werden. Dazu einfach in der PN schreiben, welche Schrift ihr haben wollt^^
|
[Frage]Bei Button Func mit Hotkey einbauen
07/01/2011 - AutoIt - 6 Replies
Hallo erstma,
ich komm mal wieder mit einer meiner Fragen:
Ich hab hier ein Script zu übung:
#include <GUIConstants.au3>
Global $FileTestScript = FileExists(@ScriptDir & "\Testscript.au3")
Global $File2GUI1L2B = FileExists(@ScriptDir & "\2GUI1L2B.au3")
HotKeySet("{F1}","Erstellen")
|
Hilfe bei Send Funktion mit Stop Funktion
04/02/2011 - AutoIt - 11 Replies
Hallo Elitepvpers
ich habe ein Problem und Mein Problem ist das mein Text einfach weiter schreibt wenn ich mit HotKey verwende... gib es keine Funktion das der Text einmal kommt und nicht wenn man einmal die HotKey das er 10 min das selbe schreibt :confused:
|
All times are GMT +1. The time now is 08:14.
|
|