Jump to content

[Solved ]if Problem !!!


zxtnt09
 Share

Recommended Posts

Hi guys,

i have an issue !

1 ) i use that and its fine : 

if $ok then 
Opt("GUIOnEventMode",0)
else 
error()
endif

2 ) now i want need sleep for 5sec , i was use that but it was make delay and make it back to Opt("GUIOnEventMode",0) !!

script for dly i used : 

if $ok then
      Opt("GUIOnEventMode",0)
      Sleep(5000)
      Opt("GUIOnEventMode",1)
else
error()
endif

i don't like that , i want delay run when script was load successfuly ,

it's meant => 

1 ) Time for loading program  example: 1 sec

2 ) After 5sec ( or X Sec ) program was loaded => Opt("GUIOnEventMode",1) change.

thanks for helping and sorry for my bad english.

=========================

Solved By Myself 

i Should Use That : 

Func buttonloginclick()
    Local $username, $password
    $username = GUICtrlRead($inputusername)
    If NOT $username Then
        _showerror("Enter Your Username!", $inputusername)
        Return False
    EndIf
    $password = GUICtrlRead($inputpassword)
    If NOT $password Then
        _showerror("Enter Your Password!", $inputpassword)
        Return False
    EndIf
    GUICtrlSetState($inputusername, $gui_disable)
    GUICtrlSetState($inputpassword, $gui_disable)
    GUICtrlSetState($buttonlogin, $gui_disable)
    Local $data, $request
    $data = "username=" & urlencode($username)
    $data &= "&password=" & urlencode($password)
    $request = _httprequest($endpoint_login, "POST", $data)
    If $debug_mode Then _arraydisplay($request)
    Local $json = json_decode($request[2])
    Local $success = json_get($json, '["success"]')
    GUICtrlSetState($inputusername, $gui_enable)
    GUICtrlSetState($inputpassword, $gui_enable)
    GUICtrlSetState($buttonlogin, $gui_enable)
    If $success Then
      Opt("GUIOnEventMode",0)
        GUICtrlSetState($inputusername, $gui_disable)
        GUICtrlSetState($inputpassword, $gui_disable)
        GUICtrlSetData($buttonlogin, "Logout")
        GUICtrlSetOnEvent($buttonlogin, "Logout")

; i Was Should That :)
If $success Then
            Sleep (5000)
         Opt("GUIOnEventMode",1)
         EndIF
; i Was Should That :)

        togglecontrol(1)
        Return True
    Else
        Local $errorcode = json_get($json, '["data"]')
        If $errorcode = -1 Then
            _showerror("Your username or password is incorrect!", $inputusername)
            Return False
        Else
            _showerror("You have already logged in at other device. Please logout first!")
            Return False
        EndIf
    EndIf
 EndFunc

Maybe It was help someone <3

Edited by zxtnt09
Link to comment
Share on other sites

@Ihab_InjeCtor that code is plain wrong. You cannot create a function with the same name as an existing native function.

@zxtnt09 I don't entirely understand the question. Using Sleep() pauses the whole script and that might include whatever is loading. Perhaps if you posted more of your code, it would be easier to see what you are trying to do.

Edited by czardas
Link to comment
Share on other sites

@Ihab_InjeCtor that code is plain wrong. You cannot create a function with the same name as an existing native function.

I don't entirely understand the question. Using Sleep() pauses the whole script and that might include whatever is loading. Perhaps if you posted more of your code, it would be easier to see what you are trying to do.

Oh sorry for my bad english , 

i think my question was clear , please see that

Func buttonloginclick()
    Local $username, $password
    $username = GUICtrlRead($inputusername)
    If NOT $username Then
        _showerror("Enter Your Username!", $inputusername)
        Return False
    EndIf
    $password = GUICtrlRead($inputpassword)
    If NOT $password Then
        _showerror("Enter Your Password!", $inputpassword)
        Return False
    EndIf
    GUICtrlSetState($inputusername, $gui_disable)
    GUICtrlSetState($inputpassword, $gui_disable)
    GUICtrlSetState($buttonlogin, $gui_disable)
    Local $data, $request
    $data = "username=" & urlencode($username)
    $data &= "&password=" & urlencode($password)
    $request = _httprequest($endpoint_login, "POST", $data)
    If $debug_mode Then _arraydisplay($request)
    Local $json = json_decode($request[2])
    Local $success = json_get($json, '["success"]')
    GUICtrlSetState($inputusername, $gui_enable)
    GUICtrlSetState($inputpassword, $gui_enable)
    GUICtrlSetState($buttonlogin, $gui_enable)
    If $success Then
;~ GUI enable after login
      Opt("GUIOnEventMode",0)
;~ GUI enable after login
        GUICtrlSetState($inputusername, $gui_disable)
        GUICtrlSetState($inputpassword, $gui_disable)
        GUICtrlSetData($buttonlogin, "Logout")
        GUICtrlSetOnEvent($buttonlogin, "Logout")
        togglecontrol(1)
        Return True
    Else
        Local $errorcode = json_get($json, '["data"]')
        If $errorcode = -1 Then
            _showerror("Your username or password is incorrect!", $inputusername)
            Return False
        Else
            _showerror("You have already logged in at other device. Please logout first!")
            Return False
        EndIf
    EndIf
 EndFunc

this code :

;~ GUI enable after login
      Opt("GUIOnEventMode",0)
;~ GUI enable after login

changing after 1minute to : 

;~ GUI enable after login
      Opt("GUIOnEventMode",1)
;~ GUI enable after login
Edited by zxtnt09
Link to comment
Share on other sites

Can you post a runnable script? It makes things much easier if we don't have to reinvent the wheel to figure out what's going wrong.

Also, what is this supposed to be doing, because your comments don't go with the code inside them?

;~ GUI enable after login
      Opt("GUIOnEventMode",0)
;~ GUI enable after login

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Can you post a runnable script? It makes things much easier if we don't have to reinvent the wheel to figure out what's going wrong.

Also, what is this supposed to be doing, because your comments don't go with the code inside them?

;~ GUI enable after login
      Opt("GUIOnEventMode",0)
;~ GUI enable after login

 

Hi,

i was create a gui and i went to create user/password for that,

after i try to user "GUICtrlSetState" for hide username/password after "Login success" The problem came into existence,

and i search why it have problem ? ... after some times i found the problem,

i found the problem is from 'Opt("GUIOnEventMode",1)' and it's meant i should disable that for my script,

because if it was "Enabled" my script went die( not worked !! ).

and after thinking , i found that way how can i do !

i try to disable OPT and reEnable After some times ( example 5 minutes ),

but now i think it's not a good way!,

anyway it was worked for me, maybe helping someone else.

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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