teayan Posted April 4, 2020 Share Posted April 4, 2020 i want to add this code to this script, it makes sense to add it because it func error when I add it to the line below. expandcollapse popup#include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> #include <EditConstants.au3> Global $login, $info ; nếu login thành công thì chuyển sang GUI info if (_Login()) Then _Info() EndIf Global $g_bPaused = False HotKeySet("{F6}", "TogglePause") Func _Login() $login = GUICreate("Simple System Demo",318,151,-1,-1,-1,-1) GUICtrlCreateLabel("Tài khoản:",20,30,84,21,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") GUICtrlSetBkColor(-1,"-2") GUICtrlCreateLabel("Mật khẩu:",20,61,84,21,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") GUICtrlSetBkColor(-1,"-2") $login_acc = GUICtrlCreateInput("",104,25,194,26,-1,$WS_EX_CLIENTEDGE) GUICtrlSetFont(-1,13,400,0,"Times New Roman") $login_pass = GUICtrlCreateInput("",104,56,194,26,$ES_PASSWORD,$WS_EX_CLIENTEDGE) GUICtrlSetFont(-1,13,400,0,"Times New Roman") $btn_login = GUICtrlCreateButton("Đăng nhập",194,100,105,30,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") $btn_reg = GUICtrlCreateButton("Đăng ký",83,100,105,30,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") GUISetState(@SW_SHOW,$login) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $btn_reg ; Mở trang đăng ký ShellExecute($__SS_URL &"\reg") Case $btn_login if GUICtrlRead($login_acc) <> "" And GUICtrlRead($login_pass) <> "" Then $login_web = _SS_Login(GUICtrlRead($login_acc), GUICtrlRead($login_pass)) ; chuyển sang gui khác if $login_web == True Then GUIDelete($login) Return True EndIf Else MsgBox(16,"Lỗi","Vui lòng nhập đầy đủ thông tin bên trên") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Return False EndFunc Func _Info() ; kiểm tra đã đăng nhập chưa, nếu đã đăng nhập thì $__SS_INFO != NULL if $__SS_INFO == Null Then Exit $hansudung = "vĩnh viễn" if _Return_Json("date_left",$__SS_INFO) <> 'NULL' Then $hansudung = _Return_Json("date_left",$__SS_INFO) $lansudung = "vĩnh viễn" if _Return_Json("times_left",$__SS_INFO) <> 'NULL' Then $lansudung = _Return_Json("times_left",$__SS_INFO) $info = GUICreate("Simple System Demo",427,212,-1,-1,-1,-1) $txt1 = GUICtrlCreateLabel("" ,20,30,340,21,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") GUICtrlSetBkColor(-1,"-2") $txt2 = GUICtrlCreateLabel("Hạn sử dụng đến: "& $hansudung,20,61,340,21,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") GUICtrlSetBkColor(-1,"-2") $txt3 = GUICtrlCreateLabel("Số lần sử dụng còn lại: "& $lansudung,20,91,340,21,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") GUICtrlSetBkColor(-1,"-2") GUICtrlSetData($txt1, "Xin chào "& _Return_Json("name",$__SS_INFO)) GUICtrlSetData($txt2, "Hạn sử dụng đến: "& $hansudung) GUICtrlSetData($txt3, "Số lần sử dụng còn lại: "& $lansudung) $btn_use = GUICtrlCreateButton("SỬ DỤNG",100,160,105,30,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") $btn_exit = GUICtrlCreateButton("THOÁT",216,160,105,30,-1,-1) GUICtrlSetFont(-1,13,400,0,"Times New Roman") GUISetState(@SW_SHOW,$info) $info_old = $__SS_INFO While 1 ; kiểm tra xem info có bị thay đổi hay ko if $__SS_INFO <> $info_old Then $info_old = $__SS_INFO $hansudung = "vĩnh viễn" if _Return_Json("date_left",$__SS_INFO) <> 'NULL' Then $hansudung = _Return_Json("date_left",$__SS_INFO) $lansudung = "vĩnh viễn" if _Return_Json("times_left",$__SS_INFO) <> 'NULL' Then $lansudung = _Return_Json("times_left",$__SS_INFO) GUICtrlSetData($txt1, "Xin chào "& _Return_Json("name",$__SS_INFO)) GUICtrlSetData($txt2, "Hạn sử dụng đến: "& $hansudung) GUICtrlSetData($txt3, "Số lần sử dụng còn lại: "& $lansudung) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $btn_use ; kiểm tra đã được cấp phép sử dụng hay chưa, nếu rồi thì $__SS_TOKEN!= NULL, nếu chưa thì gọi hàm cấp phép sử dụng if $__SS_TOKEN == Null Then if (_SS_CreateToken()) Then MsgBox(64,"Thông báo","Sử dụng thành công, bấm vào nút này để sử dụng tính năng ") GUICtrlSetData($btn_use,"...") EndIf Else MsgBox(64,"Random","Số random "& Random(1,10000,1)) EndIf Case $GUI_EVENT_CLOSE, $btn_exit Exit EndSwitch WEnd EndFunc I want to click on this button < $btn_use = GUICtrlCreateButton("SỬ DỤNG",100,160,105,30,-1,-1) >, it will show the func line that I want to add eg I want to add a lin Func TogglePause() $g_bPaused = Not $g_bPaused While $g_bPaused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause but it func error Can you help me fix it. Link to comment Share on other sites More sharing options...
Aelc Posted April 4, 2020 Share Posted April 4, 2020 (edited) Hotkeyset("{F6}","TogglePause") Global $g_bpaused = False set this before if (_Login()) Then _Info() EndIf and insert the func anywhere you want i don't know what you mean with "the button will show the func line you want to add" Edited April 4, 2020 by Aelc why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
teayan Posted April 5, 2020 Author Share Posted April 5, 2020 I tried but failed it failed. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 5, 2020 Share Posted April 5, 2020 @teayan Look at the error below, and look at your script. Done? Now, look again at those two things for about 10 times. Ain't found the error? Look another 10 times. While you don't find the error, always look at the syntax of your script. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 5, 2020 Share Posted April 5, 2020 @teayan Look at the error below, and look at your script. Done? Now, look again at those two things for about 10 times. Ain't found the error? Look another 10 times. While you don't find the error, always look at the syntax of your script. 12 hours ago, Aelc said: and insert the func anywhere you want Not really "anywhere", since the error is caused from that "anywhere". Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
teayan Posted April 5, 2020 Author Share Posted April 5, 2020 17 minutes ago, FrancescoDiMuro said: @teayan Look at the error below, and look at your script. Done? Now, look again at those two things for about 10 times. Ain't found the error? Look another 10 times. While you don't find the error, always look at the syntax of your script. Not really "anywhere", since the error is caused from that "anywhere". I just learned about autoit, I tried everything but not you can help me? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 5, 2020 Share Posted April 5, 2020 @teayan What I said is for let you learn from your errors, it wasn't mean to offend you or anything else Every statement has its own structure, so, for example, an "If...Else...EndIf" statement is structured like this: If <condition> Then ; Instructions if <condition> is True Else ; Instructions if <condition> is False EndIf The error in your script starts at line 147, where you declare a function inside an If statement, which you can't do. If you post (and not attach) the entire script instead of attaching screenshots of it, we could help more. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Aelc Posted April 5, 2020 Share Posted April 5, 2020 (edited) im sorry thought it was clear that it can't be in the same func since he got two seperated funcs already actually he just copy pasted some stuff i guess. didnt thought about this so put it anywhere but not inside another func every func is declared for itself so you should read the func helpfile first Edited April 5, 2020 by Aelc why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now