Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[PROBLEM] Przypisanie Do &Button1 funkcji


Rekomendowane odpowiedzi

Opublikowano

mam taki kod Z przypisanym buttonem itp itd, ale gdy wcisnę start, to on sie nie włącza. Dlaczego, daje kod:

 

MsgBox(1, "Tytul", "Wiadomosc")
MsgBox(0, "Info", "F5 Start F6-Stop")
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Klikacz", 168, 164, 396, 276)
$Group1 = GUICtrlCreateGroup("", 0, 80, 137, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("Info", 0, 96, 83, 17, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Klikacz wciska", 0, 8, 74, 17)
$Label2 = GUICtrlCreateLabel("X co 100ms", 0, 32, 60, 17)
$Label3 = GUICtrlCreateLabel("Spacja co 200ms", 0, 56, 86, 17)
$Group2 = GUICtrlCreateGroup("", 89, 0, 7, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label4 = GUICtrlCreateLabel("1000ms = 1s", 96, 8, 64, 17)
$Button1 = GUICtrlCreateButton("Start", 0, 128, 65, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Stop", 72, 128, 65, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet("{F5}", "start")
HotKeySet("{F6}", "stop")
Global Const $time = 200
Global Const $time2 = 100
Global Const $klawisz = "{SPACE}"
Global Const $klawisz2 = "{xxxx}"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
  Exit
   Case $Button1
							    HotKeySet("{F5}", "start")
   Case $Button3
								 HotKeySet("{F6}", "stop")
   Case $Button2
							    MsgBox(0, "Info", "Klikacz by" & @CRLF & "A. M." & @CRLF & "na cele naukowe")
EndSwitch
WEnd
Func start()
AdlibRegister("kl1", $time)
AdlibRegister("kl2", $time2)
EndFunc
Func stop()
AdlibUnregister("kl1")
AdlibUnregister("kl2")
EndFunc
Func kl1()
 Send($klawisz)
EndFunc
Func kl2()
 Send($klawisz2)
EndFunc

 

No chodzi o ten kawałek gdzie mam case &Button1 to gdy go wcisnę nie włącza się, nie klika samo. Piszę bo potrzebuje pomoc, na informatykę potrzebuje :P. Jeszcze wytłumaczyć co jak robi lae to noproblem. Z góry dzięki za pomoc.

6fc086389b796c47.jpg
Siedzę na mpc gdy jest czas, dzięki temu dużo się od was uczę dzięki!!

Opublikowano

Problem w instrukcji "case".

Po wcisnieciu buttona przypisujesz odpowiedni klawisz do funkcji. Jezeli chcesz ja wywolac to po prostu jej uzyj: jakas_funckja()

i gotowe...

Weteran
Opublikowano

AdlibRegister i HotKey dawaj na początku kodu, nie w środku.

 

Mój błąd.

Tak hotkey dajesz na początek kodu, a w funkcji buttona dajesz nazwę funkcji.

1329036830-U154499.png
Opublikowano

@edit1

 

Zgubiłem się :D. Jak to ma wyglądać, dałoby radę przedstawić tu u mnie na kodzie, bo jak daje funkcję do buttona to mi jakiś błąd wywala.

 

@edit2

 

No mam jak wcisnę to idzie:

MsgBox(1, "Tytul", "Wiadomosc")
MsgBox(0, "Info", "F5 Start F6-Stop")
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Klikacz", 168, 164, 396, 276)
$Group1 = GUICtrlCreateGroup("", 0, 80, 137, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("Info", 0, 96, 83, 17, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Klikacz wciska", 0, 8, 74, 17)
$Label2 = GUICtrlCreateLabel("X co 100ms", 0, 32, 60, 17)
$Label3 = GUICtrlCreateLabel("Spacja co 200ms", 0, 56, 86, 17)
$Group2 = GUICtrlCreateGroup("", 89, 0, 7, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label4 = GUICtrlCreateLabel("1000ms = 1s", 96, 8, 64, 17)
$Button1 = GUICtrlCreateButton("Start", 0, 128, 65, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Stop", 72, 128, 65, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet("{F5}", "start")
HotKeySet("{F6}", "stop")
Global Const $time = 200
Global Const $time2 = 100
Global Const $klawisz = "{SPACE}"
Global Const $klawisz2 = "{xxxx}"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
  Exit
   Case $Button1
								AdlibRegister("start")
   Case $Button3
								 AdlibRegister("stop")
   Case $Button2
								MsgBox(0, "Info", "Klikacz by" & @CRLF & "A. M." & @CRLF & "na cele naukowe")
EndSwitch
WEnd
Func start()
AdlibRegister("kl1", $time)
AdlibRegister("kl2", $time2)
EndFunc
Func stop()
AdlibUnregister("kl1")
AdlibUnregister("kl2")
EndFunc
Func kl1()
 Send($klawisz)
EndFunc
Func kl2()
 Send($klawisz2)
EndFunc

 

Tylko coś mi nie chodzi, bo jak wcisnę start, wciska x, wcisnę stop wciska x i spacje, wcuisne start to sie wyłacza i jakieś inne różne kombinacje w różny sposób włączają różne rzeczy. // problem dalej jest, działa, ale takie kombinacje robi jak napisałem, brak mi pomysłów -.-

6fc086389b796c47.jpg
Siedzę na mpc gdy jest czas, dzięki temu dużo się od was uczę dzięki!!

Weteran
Opublikowano

Bo to dziwnie jakoś robisz.. o wstawianiu adlibregister pod działanie button'a pierwsze słyszę, ale mogę się mylić.

Na dodatek w funkcji jaką wykonuje adlibregister, są kolejne adlibregistery, czyli coś nie gra.

1329036830-U154499.png
Opublikowano

bezsendu to jest wogole:d

 Case $Button1
																	AdlibRegister("start")
	   Case $Button3
																	 AdlibRegister("stop")

 

 

 

co to ma byc?? gdzie jest podany czas zapetlania?

 

 

case $buton1
start() ;<tak wywolujesz funkcje a nie adlibem...

 AdlibRegister("nazwa_funkcji",czas w mili sek)

 

 

po 2 po co ci gui do takiego czegos zawalasz sobie tylko program jest zbedne:P

uzyj sobie timeru... bo masz tu troche zle porobione

 

 

 

 


$x=0
$y=0
$robx=200
$roby=100

while 1
$x+=1
$y+=1
if $x>=$robx then
send('klaisz')
$x=0
endif

if $y>=$roby then
send('klaisz')
$y=0
endif
sleep(100)
wend

Do
$wiek+=1
Until ŻycieGetMsg() = -3

zbieram +

Opublikowano

bezsendu to jest wogole:d

 Case $Button1
																	AdlibRegister("start")
	   Case $Button3
																	 AdlibRegister("stop")

 

 

 

co to ma byc?? gdzie jest podany czas zapetlania?

 

 

case $buton1
start() ;<tak wywolujesz funkcje a nie adlibem...

 AdlibRegister("nazwa_funkcji",czas w mili sek)

 

 

po 2 po co ci gui do takiego czegos zawalasz sobie tylko program jest zbedne:P

uzyj sobie timeru... bo masz tu troche zle porobione

 

 

 

 


$x=0
$y=0
$robx=200
$roby=100

while 1
$x+=1
$y+=1
if $x>=$robx then
send('klaisz')
$x=0
endif

if $y>=$roby then
send('klaisz')
$y=0
endif
sleep(100)
wend

 

Działają już przyciski, ale nie rozumiem tego, bo niżej mam tą całą funkcje kl1, time itp. o co z tym chodzi:


$x=0
$y=0
$robx=200
$roby=100

while 1
$x+=1
$y+=1
if $x>=$robx then
send('klaisz')
$x=0
endif

if $y>=$roby then
send('klaisz')
$y=0
endif
sleep(100)
wend

 

A ten teraz kod co działa wygląda tak:

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=beta
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
MsgBox(1, "Tytul", "Wiadomosc")
MsgBox(0, "Info", "F5 Start F6-Stop")
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Klikacz", 168, 164, 396, 276)
$Group1 = GUICtrlCreateGroup("", 0, 80, 137, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("Info", 0, 96, 83, 17, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Klikacz wciska", 0, 8, 74, 17)
$Label2 = GUICtrlCreateLabel("X co 100ms", 0, 32, 60, 17)
$Label3 = GUICtrlCreateLabel("Spacja co 200ms", 0, 56, 86, 17)
$Group2 = GUICtrlCreateGroup("", 89, 0, 7, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label4 = GUICtrlCreateLabel("1000ms = 1s", 96, 8, 64, 17)
$Button1 = GUICtrlCreateButton("Start", 0, 128, 65, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Stop", 72, 128, 65, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet("{F5}", "start")
HotKeySet("{F6}", "stop")
Global Const $time = 200 ;<Czas zapetlania
Global Const $time2 = 100 ;<Czas zapetlania
Global Const $klawisz = "{SPACE}"
Global Const $klawisz2 = "{xxxx}"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
  Exit
 Case $Button1
  start ()
 Case $Button3
  stop ()
 Case $Button2
  MsgBox(0, "Info", "Klikacz by" & @CRLF & "A. M." & @CRLF & "na cele naukowe")
EndSwitch
WEnd
Func start()
AdlibRegister("kl1", $time)
AdlibRegister("kl2", $time2)
EndFunc   ;==>start
Func stop()
AdlibUnRegister("kl1")
AdlibUnRegister("kl2")
EndFunc   ;==>stop
Func kl1()
Send($klawisz)
EndFunc   ;==>kl1
Func kl2()
Send($klawisz2)
EndFunc   ;==>kl2

Jak byś mógł, wprowadziłbyś ten twój kod do mnie, tylko musi być z gui niestety ;(

6fc086389b796c47.jpg
Siedzę na mpc gdy jest czas, dzięki temu dużo się od was uczę dzięki!!

Opublikowano

A tak się zastanawiam jak zrobić żeby Był ten przyciks start stop, było pole input, tam wpisujemy np X, robimy start i wciska X. Ktosby by wiedział jak to działa?

6fc086389b796c47.jpg
Siedzę na mpc gdy jest czas, dzięki temu dużo się od was uczę dzięki!!

Opublikowano

Tak. To działa tak, że po wciśnięciu start jest uruchamiany skrypt wciskający znak wczytywany z inputa, a po wciśnięciu Stop skrypt ten jest zatrzymywany

 

Clue. użyj zmiennej logicznej

Opublikowano

No to muszę szukać co to zmienna logiczna :D. GUI już mam, więc 20% jest.

 

 

@edit

Czy taka zmienna istnieje bo znaleźć nie mogę :D

 

@edit2

Proszę pomóżcie to dokończyć, żeby po wpisaniu przycisku i czasu go klikało, proszę, muszę to oddać jako prace po za materiałem, Błagam.

 

MsgBox(0, "Informacja", "Za wszelkie szkody nie odpowiadam, oczywiście szkody w grze" & @CRLF & "Z poważaniem, dla mpcforum")
#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Klikacz", 338, 297, 344, 240)
$Button1 = GUICtrlCreateButton("Start", 0, 264, 65, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Stop", 72, 264, 65, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Info", 144, 272, 83, 17, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("V 1.0.0 Beta", 240, 272, 63, 17)
$Label2 = GUICtrlCreateLabel("Przycisk Pierwszy", 8, 8, 159, 17)
$Label3 = GUICtrlCreateLabel("Przycisk Drugi", 8, 72, 143, 17)
$Label4 = GUICtrlCreateLabel("Przycisk Trzeci", 8, 136, 147, 17)
$Group1 = GUICtrlCreateGroup("", 0, 24, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 0, 88, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("", 0, 152, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("", 0, 248, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input1 = GUICtrlCreateInput("", 0, 32, 321, 21)
$Input2 = GUICtrlCreateInput("", 0, 96, 321, 21)
$Input3 = GUICtrlCreateInput("", 0, 160, 321, 21)
$Group5 = GUICtrlCreateGroup("", 0, 184, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label5 = GUICtrlCreateLabel("Co ile. Czas podawaj w ms 1s=1000ms", 0, 200, 215, 17)
$Input4 = GUICtrlCreateInput("przycisk 1", 8, 224, 73, 21)
$Input5 = GUICtrlCreateInput("przycisk 2", 96, 224, 73, 21)
$Input6 = GUICtrlCreateInput("przycisk 3", 184, 224, 73, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
  Exit
 Case $Button2
  MsgBox(0, "Info", "Klikacz by" & @CRLF & "misiecki2 - trochę kodu i całe GUI" & @CRLF & "xxx - Większość Kodu")
EndSwitch
WEnd

 

Tylko tyle mam :(, już sam nw co robić.

6fc086389b796c47.jpg
Siedzę na mpc gdy jest czas, dzięki temu dużo się od was uczę dzięki!!

Opublikowano

zmienna logiczna to taka sama zmienna jak inne, tylko przyjmuje wartości true/false

 

po kliknięciu w button start zmieniaj jej wartość na true, po naciśnięciu w stop na false.

w pętli głównej daj if ta zmienna = true wykonaj polecenia

Opublikowano

Sprobój jakoś tak aczkolwiek mi to nie działa bo gdzieś błąd popełniłem WAZNE PAMIETAJ O DOLACZENIU BIBLIOTEKI TIMERS.AU3 Z DZIALU GOTOWE KODY tam poszukaj Timers.au3 i wrzuc sobie do folderu z projektem!


MsgBox(0, "Informacja", "Za wszelkie szkody nie odpowiadam, oczywiście szkody w grze" & @CRLF & "Z poważaniem, dla mpcforum")
#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Klikacz", 338, 297, 344, 240)
$Button1 = GUICtrlCreateButton("Start", 0, 264, 65, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Stop", 72, 264, 65, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Info", 144, 272, 83, 17, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("V 1.0.0 Beta", 240, 272, 63, 17)
$Label2 = GUICtrlCreateLabel("Przycisk Pierwszy", 8, 8, 159, 17)
$Label3 = GUICtrlCreateLabel("Przycisk Drugi", 8, 72, 143, 17)
$Label4 = GUICtrlCreateLabel("Przycisk Trzeci", 8, 136, 147, 17)
$Group1 = GUICtrlCreateGroup("", 0, 24, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 0, 88, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("", 0, 152, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("", 0, 248, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input1 = GUICtrlCreateInput("", 0, 32, 321, 21)
$Input2 = GUICtrlCreateInput("", 0, 96, 321, 21)
$Input3 = GUICtrlCreateInput("", 0, 160, 321, 21)
$Group5 = GUICtrlCreateGroup("", 0, 184, 321, 9)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label5 = GUICtrlCreateLabel("Co ile. Czas podawaj w ms 1s=1000ms", 0, 200, 215, 17)
$Input4 = GUICtrlCreateInput("przycisk 1", 8, 224, 73, 21)
$Input5 = GUICtrlCreateInput("przycisk 2", 96, 224, 73, 21)
$Input6 = GUICtrlCreateInput("przycisk 3", 184, 224, 73, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
  Exit
  Case $Button1
_Timer_SetTimer($Form1,$Input4,"przycisk1")
_Timer_SetTimer($Form1,$Input5,"przycisk2")
_Timer_SetTimer($Form1,$Input6,"przycisk3")
 Case $Button2
  MsgBox(0, "Info", "Klikacz by" & @CRLF & "misiecki2 - trochę kodu i całe GUI" & @CRLF & "xxx - Większość Kodu")
EndSwitch
WEnd

Func przycisk1()
Send ("$input1")
EndFunc
Func przycisk2()
Send ("$input2")
EndFunc
Func przycisk3()
Send ("$input3")
EndFunc

Opublikowano

mozna to zrobic wszystko 1 butonem

 

GUICreate('')
$buton = GUICtrlCreateButton("start", 5, 5, 100, 20)
GUISetState()
$x = True

While 1
   Switch GUIGetMsg()
       Case $buton
           $x = Not $x
           If $x = False Then GUICtrlSetData($buton, "stop")
           If $x = true Then GUICtrlSetData($buton, "start")
       case -3
           Exit
   EndSwitch

WEnd

dodaj sobie w if'a zeby wykonywal jakas petle (pod GUICtrlSetData($buton, "stop")) i bedzie gotowe:)

Do
$wiek+=1
Until ŻycieGetMsg() = -3

zbieram +

Opublikowano

jak to moze dzialac... skoro masz $input4 a nie guictrlread($input4)?? moze dlatego nie dziala:)

Do
$wiek+=1
Until ŻycieGetMsg() = -3

zbieram +

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...