Jump to content

Recommended Posts

Posted (edited)

Hello, I have read a lot of topic about this , but still not work on my code :( sorry, i'm newbie. I want Set Hotkey Stop ( F4)  and Start ( F5) while loop , this is my code :

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

#Region ### START Koda GUI section ### Form=
$Auto = GUICreate("xxxxxx", 626, 282, 203, 114)
Global $link1 = GUICtrlCreateLabel("xxx link", 16, 16, 96, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $linkinput = GUICtrlCreateInput("", 144, 16, 473, 21)
Global $Start = GUICtrlCreateButton("Start", 432, 104, 161, 41)
GUICtrlSetFont(-1, 12, 800, 0, "Tahoma")
Global $Exit = GUICtrlCreateButton("Exit", 432, 160, 161, 41)
GUICtrlSetFont(-1, 12, 800, 0, "Tahoma")
$Label1 = GUICtrlCreateLabel(" xxx v1.0", 232, 216, 186, 17)
$Label2 = GUICtrlCreateLabel("xxx", 16, 112, 121, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $numberofplayinput = GUICtrlCreateInput("", 147, 112, 89, 21)
Global $StatusBar1 = _GUICtrlStatusBar_Create($Auto)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 33)
Global $link2 = GUICtrlCreateLabel("xxx link 2", 16, 60, 110, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $linkinput2 = GUICtrlCreateInput("", 142, 57, 473, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Start
            $SaveLinkFromUser = GUICtrlRead($linkinput) 
            StartChrome()

         Case $Exit
            Exit 0

    EndSwitch
 WEnd

Func StartChrome()
 ;my code

 While $number 

    $number -= 1


 ;my code


WEnd

 EndFunc

Thanks all !

Edited by singcang
Posted

There are a couple ways of doing it, but the way i would do it, would be by having _ispressed and conditions in the main loop.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted
  On 7/17/2018 at 5:11 AM, careca said:

There are a couple ways of doing it, but the way i would do it, would be by having _ispressed and conditions in the main loop.

Expand  

this is code follow your reply , press F4 or F5 but nothing happend :sweating:

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <Misc.au3>


#Region ### START Koda GUI section ### Form=
$Auto = GUICreate("xxx", 626, 282, 203, 114)
Global $link1 = GUICtrlCreateLabel("xxx", 16, 16, 96, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $linkinput = GUICtrlCreateInput("", 144, 16, 473, 21)
Global $Start = GUICtrlCreateButton("Start", 432, 104, 161, 41)
GUICtrlSetFont(-1, 12, 800, 0, "Tahoma")
Global $Exit = GUICtrlCreateButton("Exit", 432, 160, 161, 41)
GUICtrlSetFont(-1, 12, 800, 0, "Tahoma")
$Label1 = GUICtrlCreateLabel("xxx", 232, 216, 186, 17)
$Label2 = GUICtrlCreateLabel("xxx", 16, 112, 121, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $numberofplayinput = GUICtrlCreateInput("", 147, 112, 89, 21)
Global $StatusBar1 = _GUICtrlStatusBar_Create($Auto)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 33)
Global $link2 = GUICtrlCreateLabel("xxx", 16, 60, 110, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $linkinput2 = GUICtrlCreateInput("", 142, 57, 473, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Start
            $SaveLinkFromUser = GUICtrlRead($linkinput)
            StartChrome()

         Case $Exit
            Exit

    EndSwitch
 WEnd

Func StartChrome()
 ShellExecute("chrome.exe",$SaveLinkFromUser, "--start-maximized") 
 Sleep(6000)

$number = GUICtrlRead($numberofplayinput)
Global $hDLL = DllOpen("user32.dll")

 While $number

       $number -= 1

If _IsPressed("73", $hDLL) Then

; my code 

        While _IsPressed("73", $hDLL)
            Sleep(250)
        WEnd

    ElseIf _IsPressed("74", $hDLL) Then
        MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The F5 Key was pressed, therefore we will close the application.")
        ExitLoop
    EndIf
    Sleep(250)

WEnd

DllClose($hDLL)




 EndFunc

 

  • Moderators
Posted

singcang,

Please do not bump your own threads within 24 hours.

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare.  You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online - so please be patient.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted
  On 7/17/2018 at 3:32 AM, singcang said:

Hello, I have read a lot of topic about this , but still not work on my code :( sorry, i'm newbie. I want Set Hotkey Stop ( F4)  and Start ( F5) while loop , this is my code :

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

#Region ### START Koda GUI section ### Form=
$Auto = GUICreate("xxxxxx", 626, 282, 203, 114)
Global $link1 = GUICtrlCreateLabel("xxx link", 16, 16, 96, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $linkinput = GUICtrlCreateInput("", 144, 16, 473, 21)
Global $Start = GUICtrlCreateButton("Start", 432, 104, 161, 41)
GUICtrlSetFont(-1, 12, 800, 0, "Tahoma")
Global $Exit = GUICtrlCreateButton("Exit", 432, 160, 161, 41)
GUICtrlSetFont(-1, 12, 800, 0, "Tahoma")
$Label1 = GUICtrlCreateLabel(" xxx v1.0", 232, 216, 186, 17)
$Label2 = GUICtrlCreateLabel("xxx", 16, 112, 121, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $numberofplayinput = GUICtrlCreateInput("", 147, 112, 89, 21)
Global $StatusBar1 = _GUICtrlStatusBar_Create($Auto)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 33)
Global $link2 = GUICtrlCreateLabel("xxx link 2", 16, 60, 110, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
Global $linkinput2 = GUICtrlCreateInput("", 142, 57, 473, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Start
            $SaveLinkFromUser = GUICtrlRead($linkinput) 
            StartChrome()

         Case $Exit
            Exit 0

    EndSwitch
 WEnd

Func StartChrome()
 ;my code

 While $number 

    $number -= 1


 ;my code


WEnd

 EndFunc

Thanks all !

Expand  
HotKeySet("f4",namefunc)

HotKeySet("f5",_ExitLoop)


Func _ExitLoop()
  ExitLoop
EndFunc

Try this, ando tell me

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...